Chapter 14 Working with Java


Defining interfaces and classes for EJBs

An EJB comprises a number of specific interfaces and implementation classes. Interfaces of an EJB are always exposed, you define a public interface and expose it. You can attach an interface or class to only one EJB at a time.

EJB component interfaces are shown as circles linked to the EJB component side by an horizontal or a vertical line:


Interfaces provide a remote, or a local view as shown in the table below:

View Interface
Remote view Remote home interface
Remote interface
Local view Local home interface
Local interface

The symbol of an interface can be moved, and the link from the EJB component to the interface can be extended. When an interface realizes an EJB component, the interface is necessarily visible.

Note   Displaying the interface properties
You can double-click the circle, symbol of an interface to display the interface property sheet.

Classes have no symbol in the component diagram, unlike interfaces. However, the relationship between the class and the EJB component is visible from the Classes page of the EJB component property sheet, and from the Components tabbed page in the Dependencies page of the class property sheet.

The following table displays the stereotypes used to automatically identify EJB interfaces and classes:

Stereotype Describes
<<EJBRemoteHome>> The remote home interface
<<EJBRemote>> The remote interface
<<EJBLocalHome>> The local home interface
<<EJBLocal>> The local interface
<<EJBEntity>> The bean class of an entity bean
<<EJBSession>> The bean class of a session bean
<<EJBMessageDriven>> The bean class of a message driven bean
<<EJBPrimaryKey>> The primary key class of an entity bean

Naming conventions

A naming convention is a common model option that you can define in the Model Options dialog box. It is useful to set rules in order to enforce predefined name formats for all the objects within a model. You can specify naming convention for related interfaces and classes in your object language in the Settings→Namings category, available from Language→Edit Current Object Language.

For more information on naming conventions, see section Defining naming conventions, in chapter Managing Models in the General Features Guide .


Template names are instantiated with respect to the corresponding component and assigned to the newly created objects. If an unattached interface or class, matching a given name and classifier type already exists in the model, it is automatically attached to the EJB.

Steps To define an interface or a class for an EJB:

  1. Right-click the EJB component in the diagram and select EJB from the contextual menu.

    The component property sheet opens to the EJB page.

    Interfaces and classes are created and attached to the EJB.


    You can use the Create tool beside the interface or the class name to recreate an interface or a class if it is set to <None>.
  2. Click the Properties button beside the interface or the class name box that you want to define.

    The interface or the class property sheet appears.
  3. Select properties as required.

    The interfaces and classes definitions are added to the current EJB component definition.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.