Home

  

Product

  

Buy

  

Support

 First Line 
 FAQs 
 Tutorials 
 Registered Users 
 User Guide 
 Knowledge Base 

News

  

Press

  

Downloads

  

Contact

  

Company

  

Partners

  

Resources

 
 

User Guide - Enterprise Java Beans

Index    Previous   <<>>  Next
  
9.1 Overview

9.2 Adding an EJB

9.3 Editing an EJB

9.4 Removing an EJB

9.5 Home methods (J2EE 1.3 only)

9.6 Finders (Entity EJB only)

9.7 Select methods (J2EE 1.3 CMP only)

9.8 Create methods (Entity EJB only)

9.9 Environment entries

9.10 Bean references

9.11 Resource references

9.12 Resource environment references

9.13 Types

  9.1  OverviewTo top of page

JCodeBox allows you to create all of the available Enterprise Java Bean (EJB) types:

  • Entity beans (BMP and CMP)
  • Session beans (stateful and stateless)
  • Message driven beans (MDB)

To define an EJB you need to complete the define <<EJB type>> dialog i.e. define Session EJB (v2.0). If you are defining entity beans you can define more than one at a time (depending on available entities) and bypass the define <<EJB type>> dialog - default values will be provided based on the underlying entity name (see the Adding an EJB section for further details).

From the define <<EJB type>> dialog you can add many features to your EJB such as patterns, finders (entity only) and environment entries. You can also add code elements such as business methods, imports and variables. Once defined, you can preview your EJB to see the exact code that will be created.

  9.2  Adding an EJBTo top of page

  1. Adding an EJB
    • Right mouse click on Business Tier in the define application dialog
    • Select Add BMP EJB/CMP EJB/Stateless Session EJB/Facade/Stateful Session EJB/Facade/Message Driven Bean/Facade from the popup menu
    • Or

    • Select the Action=>Tier menu option from the main menu in the define application dialog
    • Select Business Tier and press next
    • Select Add BMP EJB/CMP EJB/Stateless Session EJB/Facade/Stateful Session EJB/Facade/Message Driven Bean/Facade and press finish
    • The define <<EJB type>> EJB/Bean dialog is displayed.

      Settings tab

    • Press the Select button. The select modelsource dialog is displayed.
    • Select a modelsource from the list
    • Press OK. The EJB dialog will be populated with values based on the selected modelsource name.
    • Modify the EJB package name text field if required
    • Modify the EJB bean name text field if required
    • Modify the EJB bean JNDI name text field if required (entity and session beans only)
    • Modify the EJB bean description name text field if required
    • Modify the EJB home interface text field if required (entity and session beans only)
    • Modify the EJB remote interface text field if required (entity and session beans only)
    • Modify the EJB local home text field if required (entity and session beans only) (J2EE 1.3 only)
    • Modify the EJB local text field if required (entity and session beans only) (J2EE 1.3 only)
    • Modify the EJB bean class text field if required
    • Modify the EJB primary key class text field if required (entity beans only)
    • Modify the EJB data source JNDI text field if required. This is linked to a resource reference on the resources tab. (entity beans only)
    • Enter some documentation for this EJB if required
    • Modify the EJB destination JNDI name text field if required (message beans only)
    • Select the transaction type for your EJB (message beans only)
    • Select the destination type for your EJB (message beans only)
    • Select the subscription durability for your EJB (message beans only)
    • Fields tab (entity beans only)

    • Change the field type for bean fields (if required) by double clicking on the correct cell in the correct fields table (primary key or data) and typing the new value. The value entered must be a valid Java data type.
    • Change the field name for bean fields (if required) by double clicking on the correct cell in the correct fields table (primary key or data) and typing the new value. The value entered must be a valid Java identifier.
    • Patterns tab (entity and session beans only)

    • Use the patterns buttons to add/edit/remove patterns for your EJB.
    • Use the home methods buttons to add/edit/remove home methods for your EJB (described in more detail later in the chapter). (J2EE 1.3 only)
    • Find/Create tab (entity beans only)

    • Use the finders buttons to add/edit/remove finders for your EJB (described in more detail later in the chapter).
    • Use the select methods buttons to add/edit/remove select methods for your EJB (described in more detail later in the chapter). (J2EE 1.3 CMP only)
    • Use the create methods buttons to add/edit/remove create methods for your EJB (described in more detail later in the chapter).
    • Code tab

    • Use the imports buttons to add/edit/remove imports for your EJB. The application button allows you to add imports for other components in your application.
    • Use the class variables buttons to add/edit/remove variables for your EJB.
    • Use the methods buttons to add/edit/remove methods for your EJB.
    • Resources tab

    • Use the environment entries buttons to add/edit/remove environment entries for your EJB. (described in more detail later in the chapter)
    • Use the bean references buttons to add/edit/remove bean references for your EJB (described in more detail later in the chapter).
    • Use the resource references buttons to add/edit/remove resource references for your EJB (described in more detail later in the chapter).
    • Use the resource environment references buttons to add/edit/remove resource environment references for your EJB (described in more detail later in the chapter).
    • Types tab

    • Use the Types tab to add/edit/remove inherited/implemented types for the different parts of your EJB. (described in more detail later in the chapter)
    • Press OK to save your EJB
    • Your EJB is now displayed in the Business Tier of the define application dialog.

  2. Adding multiple EJBs (entity beans only)
    • Right mouse click on Business Tier in the define application dialog
    • Select Add multiple BMP/CMP EJBs from the popup menu
    • Or

    • Select the Action=>Tier menu option from the main menu in the define application dialog
    • Select Business Tier and press next
    • Select Add multiple BMP/CMP EJBs and press finish
    • The select modelsource dialog is displayed.

    • Select the required modelsources from the list (use the shift key to select multiple modelsources).
    • Press OK. Your EJBs will be automatically defined and displayed in the Business Tier of the define application dialog.

  9.3  Editing an EJBTo top of page

  • Right mouse click on the EJB in the define application dialog
  • Select Edit from the popup menu
  • Or

  • Select the Action=>Component menu option from the main menu in the define application dialog
  • Select Business Tier and press next
  • Select the EJB you would like to edit and press next
  • Select Edit and press finish
  • The define <<EJB type>> EJB/Bean dialog is displayed.

  • Follow the instructions in the previous section (Adding an EJB) to make changes to your EJB.
  • Press OK to save your EJB
  • Your EJB has now been updated and is displayed in the Business Tier of the define application dialog.

  9.4  Removing an EJBTo top of page

  • Right mouse click on the EJB in the define application dialog
  • Select Remove from the popup menu
  • Press Yes if the remove component dialog is displayed
  • Or

  • Select the Action=>Component menu option from the main menu in the define application dialog
  • Select Business Tier and press next
  • Select the EJB you would like to remove and press next
  • Select Remove and press finish
  • Press Yes if the remove component dialog is displayed
  • The EJB will be removed from the Business Tier of the define application dialog.

  9.5  Home methods (J2EE 1.3 only)To top of page

  1. Adding a home method
    • Press the Add (home methods) button in the define EJB dialog
    • The define home method dialog is displayed
    • Select the target interface
    • Press the edit (method) button. The define method dialog is displayed
    • Complete the define method dialog and press OK.
    • Press OK on the define home method dialog.
    • Your home method will be displayed in the home methods list.

  2. Editing a home method
    • Select the home method you would like to edit.
    • Press the Edit (home methods) button
    • The define home method dialog is displayed
    • Select the target interface
    • Press the edit (method) button. The define method dialog is displayed
    • Complete the define method dialog and press OK.
    • Press OK on the define home method dialog.
    • Your updated home method will be displayed in the home methods list.

  3. Removing a home method
    • Select the home method you would like to remove.
    • Press the Remove (home methods) button
    • Your home method will be removed from the home methods list.

  9.6  Finders (Entity EJB only)To top of page

  1. Adding a finder (J2EE 1.2 and BMP J2EE 1.3)
    • Press the Add (finder) button in the define EJB dialog
    • The define finder dialog is displayed
    • Enter a finder name in the finder name text field
    • Select the finder return type
    • Select the target interface (BMP J2EE 1.3 only)
    • Press the Add field button. The select field dialog is displayed
    • Select a field and press OK
    • Repeat the previous 2 steps for each field you would like to add to your finder
    • To edit the criteria of a field, select the field and press the Edit field (criteria) button (or double click on the field). The set field criteria dialog is displayed
    • Complete the set field criteria dialog and press OK and press OK
    • Select a field and press OK
    • To remove a field, select the field and press the Remove field button
    • Press OK to close the define finder dialog
    • Your finder will be displayed in the finders list.

  2. Editing a finder (J2EE 1.2 and BMP J2EE 1.3)
    • Select the finder you would like to edit.
    • Press the Edit (finders) button
    • The define finder dialog is displayed
    • Modify the finder name in the finder name text field if required
    • Select the finder return type
    • Select the target interface (BMP J2EE 1.3 only)
    • Modify the finder fields using the Add field, Edit field (criteria) and Remove field buttons
    • Press OK to close the define finder dialog
    • Your updated finder will be displayed in the finders list.

  3. Deleting a finder (J2EE 1.2 and BMP J2EE 1.3)
    • Select the finder you would like to delete.
    • Press the Delete (finders) button
    • Your finder will be removed from the finders list.

  4. Adding a finder (CMP J2EE 1.3)
    • Press the Add (finder) button in the define EJB dialog
    • The define finder dialog is displayed
    • Enter a finder name in the finder name text field
    • Press the Add (parameter) button. The define parameter dialog is displayed
    • Enter a parameter type and parameter name and press OK
    • Repeat the previous 2 steps for each parameter you would like to add to your finder
    • Select the finder return type
    • Select the target interface
    • Enter the EJB-QL for your finder
    • Press OK to close the define finder dialog
    • Your finder will be displayed in the finders list.

  5. Editing a finder (CMP J2EE 1.3)
    • Select the finder you would like to edit.
    • Press the Edit (finders) button
    • The define finder dialog is displayed
    • Modify the finder name in the finder name text field if required
    • Modify the finder parameters using the Add and Remove (parameters) buttons
    • Select the finder return type
    • Select the target interface
    • Modify the EJB-QL for your finder as required
    • Press OK to close the define finder dialog
    • Your updated finder will be displayed in the finders list.

  6. Deleting a finder (CMP J2EE 1.3)
    • Select the finder you would like to delete.
    • Press the Delete (finders) button
    • Your finder will be removed from the finders list.

  9.7  Select methods (J2EE 1.3 CMP only)To top of page

  1. Adding a select method
    • Press the Add (select) button in the define EJB dialog
    • The define select dialog is displayed
    • Enter a select name in the select name text field
    • Press the Add (parameter) button. The define parameter dialog is displayed
    • Enter a parameter type and parameter name and press OK
    • Repeat the previous 2 steps for each parameter you would like to add to your select
    • Enter the select return type in the return type text field
    • Select the return type mapping
    • Enter the EJB-QL for your select
    • Press OK to close the define select dialog
    • Your select will be displayed in the selects list.

  2. Editing a select
    • Select the select you would like to edit.
    • Press the Edit (select) button
    • The define select dialog is displayed
    • Modify the select name in the select name text field if required
    • Modify the select parameters using the Add and Remove (parameters) buttons
    • Modify the select return type in the select return type text field if required
    • Select the return type mapping
    • Modify the EJB-QL for your select as required
    • Press OK to close the define select dialog
    • Your updated select will be displayed in the selects list.

  3. Deleting a select
    • Select the select you would like to delete.
    • Press the Delete (selects) button
    • Your select will be removed from the selects list.

  9.8  Create methods (Entity EJB only)To top of page

  1. Adding a create method
    • Press the Add (create methods) button in the define EJB dialog
    • The define create method dialog is displayed
    • Enter a name for this create method in the creator name text field
    • Press the Add/Remove fields button. The select create method fields dialog is displayed
    • Move the fields you would like in this create method from the available fields list to the selected fields list using the arrow buttons. Press OK
    • Press OK to close the define create method dialog
    • Your create method will be displayed in the create methods list.

  2. Editing a create method
    • Select the create method you would like to edit.
    • Press the Edit (create method) button
    • The define create method dialog is displayed
    • Modify the create method name in the creator name text field if required
    • Press the Add/Remove fields button. The select create method fields dialog is displayed
    • Move the fields you would like in this create method from the available fields list to the selected fields list using the arrow buttons. Press OK
    • Press OK to close the define create method dialog
    • Your updated create method will be displayed in the create methods list.

  3. Deleting a create method
    • Select the create method you would like to delete.
    • Press the Delete (create method) button
    • Your create method will be removed from the create methods list.

  9.9  Environment entriesTo top of page

  1. Adding an environment entry
    • Press the Add (environment entries) button in the define EJB dialog
    • The define environment entry dialog is displayed
    • Enter a name for this environment entry in the name text field
    • Select the environment entry type
    • Enter a value for this environment entry in the value text field
    • Press OK to close the define environment entry dialog
    • Your environment entry will be displayed in the environment entries list.

  2. Editing an environment entry
    • Select the environment entry you would like to edit.
    • Press the Edit (environment entries) button
    • The define environment entry dialog is displayed
    • Modify the environment entry name in the name text field if required
    • Select the environment entry type
    • Modify the environment entry value in the value text field if required
    • Press OK to close the define environment entry dialog
    • Your updated environment entry will be displayed in the environment entries list.

  3. Deleting an environment entry
    • Select the environment entry you would like to delete.
    • Press the Delete (environment entries) button
    • Your environment entry will be removed from the environment entries list.

  9.10  Bean referencesTo top of page

  1. Adding a bean reference
    • Press the Add (bean references) button in the define EJB dialog
    • J2EE 1.2

    • The select enterprise bean dialog is displayed
    • Select the bean you would like to make a reference to and press OK.
    • J2EE 1.3

    • The select bean reference wizard is displayed
    • Select the bean you would like to make a reference to and press next.
    • Select the type (remote/local) you would like the reference to have and press finish.
    • Your bean reference will be displayed in the bean references list.

  2. Deleting a bean reference
    • Select the bean reference you would like to delete.
    • Press the Delete (bean references) button
    • Your bean reference will be removed from the bean references list.

  9.11  Resource referencesTo top of page

  1. Adding a resource reference
    • Press the Add (resource references) button in the define EJB dialog
    • The define resource reference dialog is displayed
    • Enter a name for this resource reference in the name text field
    • Enter a type for this resource reference in the type text field
    • Select the authorisation for this resource reference
    • Press OK to close the define resource reference dialog
    • Your resource reference will be displayed in the resource references list.

  2. Editing a resource reference
    • Select the resource reference you would like to edit.
    • Press the Edit (resource references) button
    • The define resource reference dialog is displayed
    • Modify the resource reference name in the name text field if required
    • Modify the resource reference type in the type text field if required
    • Select the authorisation for this resource reference
    • Press OK to close the define resource reference dialog
    • Your updated resource reference will be displayed in the resource references list.

  3. Deleting a resource reference
    • Select the resource reference you would like to delete.
    • Press the Delete (resource references) button
    • Your resource reference will be removed from the resource references list.

  9.12  Resource environment referencesTo top of page

  1. Adding a resource environment reference
    • Press the Add (resource environment references) button in the define EJB dialog
    • The define resource environment reference dialog is displayed
    • Enter a name for this resource environment reference in the name text field
    • Enter a type for this resource environment reference in the type text field
    • Press OK to close the define resource environment reference dialog
    • Your resource environment reference will be displayed in the resource environment references list.

  2. Editing a resource environment reference
    • Select the resource environment reference you would like to edit.
    • Press the Edit (resource environment references) button
    • The define resource environment reference dialog is displayed
    • Modify the resource environment reference name in the name text field if required
    • Modify the resource environment reference type in the type text field if required
    • Press OK to close the define resource environment reference dialog
    • Your updated resource environment reference will be displayed in the resource environment references list.

  3. Deleting a resource environment reference
    • Select the resource environment reference you would like to delete.
    • Press the Delete (resource environment references) button
    • Your resource environment reference will be removed from the resource environment references list.

  9.13  TypesTo top of page

The types tab allows you to maintain inherited/implemented types for the different parts of your EJB (i.e. primary key class, home interface, bean class, etc). The following types can be maintained:

  1. Bean class parent class
    • Enter the parent class in the parent class field in the bean class section

  2. Bean class interfaces
    • Use the add/edit/remove buttons in the bean class section to maintain interfaces your bean class should implement
    • The Add and Edit buttons display the Add/Edit bean class interface dialog

  3. Primary key class parent class (entity beans only)
    • Enter the parent class in the parent class field in the primary key class section

  4. Primary key class interfaces
    • Use the add/edit/remove buttons in the primary key class section to maintain interfaces your primary key class should implement
    • The Add and Edit buttons display the Add/Edit primary key class interface dialog

  5. Home interface implemented interfaces
    • Use the add/edit/remove buttons in the home interface section to maintain interfaces your home interface should extend
    • The Add and Edit buttons display the Add/Edit home interface interface dialog

  6. Remote interface implemented interfaces
    • Use the add/edit/remove buttons in the remote interface section to maintain interfaces your remote interface should extend
    • The Add and Edit buttons display the Add/Edit remote interface interface dialog

  7. Local home interface implemented interfaces (J2EE 1.3 only)
    • Use the add/edit/remove buttons in the local home interface section to maintain interfaces your local home interface should extend
    • The Add and Edit buttons display the Add/Edit local home interface interface dialog

  8. Local interface implemented interfaces (J2EE 1.3 only)
    • Use the add/edit/remove buttons in the local interface section to maintain interfaces your local interface should extend
    • The Add and Edit buttons display the Add/Edit local interface interface dialog

Index    Previous   <<>>  Next

[an error occurred while processing this directive]