|
The J2EE Assistant in Studio helps the developer add references to the Bean classes, JSP Pages and Servlets. The three different types of references that can be added are EJB references, resource references, resource environment references.
Using the J2EE Assistant to add these references, generates the lookup code at the cursor position based on the inputs provided by the developer, adds these entries to the required XML files, imports the relevant classes (in the bean class only), and also initializes the required variables. Using the J2EE Assistant minimizes the number of errors that are committed, by the developer, and also removes any oversights of the developer.
EJB References are used for the declaration of a reference to an enterprise bean's home. The declaration consists of:
To add the EJB Reference, position the cursor at the place where the reference is to be added, and then click on J2EE Assistant > Add EJB Reference from the main menu. The shortcut key that may be used is Ctrl + Alt + Q. This brings up the Add EJB Reference panel, where the following information needs to be filled:
Link Select the JNDI name for the reference to be created. The JNDI name is used to link an ejb reference to the target enterprise bean. This is the name of the target enterprise bean, and is unique.
Remote Interfaces Choose this option to add the ejb reference to the remote interface of the bean. If the bean does not have a remote interface, the option is disabled.
Local Interfaces Choose this option to add the ejb reference to the local interface of the bean. If the bean does not have a local interface, the option is disabled.
Name Enter the name of the EJB Reference to be added in this field. The name must be unique within the same module. Entering a name which is already being used for a different bean disables the OK button, and prompts the user by coloring the reference name in red and displaying an appropriate error message.
Clicking on OK after filling in all the required details adds the lookup code at the cursor position, adds the required import statement for the home/local class being looked up, declares the initial context variable, ic to the code, and therefore the classpath of the bean class file must contain the classes of the beans being looked up.
Resource reference contains a declaration of enterprise bean's or web component's reference to an external resource. It consists of an optional description, the resource manager connection factory reference name, the indication of the resource manager connection factory type expected by the code, the type of authentication (Application or Container), and an optional specification of the shareability of connections obtained from the resource (Shareable or Unshareable).
To add the Resource Reference, position the cursor at the place where the reference is to be added, and then click on J2EE Assistant > Add Resource Reference from the main menu. The shortcut key that may be used is Ctrl + Alt + W. This brings up the Add Resource Reference panel, where the following information needs to be filled:
Link Select the reference link from the list in the combo box. The list contains all the data resources and mail resources that have been defined in the Desk.
Name Enter the name of the resource reference to be added in this field.
Clicking on OK adds the lookup code at the place where the cursor was positioned, adds the required import statements for the javax.sql.DataSource, declares the initial context variable - ic, and therefore the classpath of the bean class file must contain the classes of the beans being looked up.
The resource environment reference contains a declaration of an enterprise bean's reference to an administered object associated with a resource in the enterprise bean's or the web component's environment.
To add the Resource Environment Reference, position the cursor at the place where the reference is to be added, and then click on J2EE Assistant > Add Resource Environment Reference from the main menu. The shortcut key that may be used is Ctrl + Alt + E. This brings up the Add Resource Environment Reference panel, where the following information needs to be filled:
Link Select the reference link from the list in the combo box. The list contains all the JMS resources that have been defined in the Desk.
Name Enter the name of the resource environment reference in this field. The name must be unique in the module.
Clicking on OK adds the lookup code at the place where the cursor was positioned, adds the required import statements, declares the initial context variable - ic, and therefore the classpath of the bean class file must contain the classes of the beans being looked up.
Use this feature to browse for different types of enterprise beans in the Desk. Click on J2EE Assistant > Bean Browser from the main menu or press on Ctrl + Alt + A on the keyboard. This pops up the Bean Browser dialog, which by default, displays all the beans in the Desk
To view beans after sorting them using the different criterions, use the following:
Selecting a specific module name from the combo box displays only those beans that exist in that module
The OK button is disabled till a bean is selected. Select the bean from the list, and click on OK to open the bean class file in the Display Panel.
Use this feature to select beans and the type of interface (remote or local) that are to be included in facade. Click on J2EE Assistant > Session Facade from the main menu, or press Ctrl + Alt + S on the keyboard. This pops up the Create Session Facade dialog. The dialog is divided in two parts:
Check the options - Home and Local Home against the bean name to include them in the facade. If the interface type is not available for a bean, then that specific checkbox displays the text NA (not available).
The OK button is disabled till a bean is selected. Check against the bean name, the interface type for that bean, and the session bean to create the facade and then click OK.
This generates the lookup code for all the beans selected in the setSessionContext method of the selected session facade bean. Selecting beans that have already been declared in the Create Session Facade dialog, does not generate the look up code for these beans.
The list of variables is initialized for the remote/local interfaces of the beans being looked up, and their classes are included in the classpath of the module of the facade bean. If the beans being looked up belong to a package other than the session facade bean, the beans are imported in the facade beans.
Selecting a specific bean in the Select Facade Bean field makes that bean's row uneditable in the table. Similarly seleting a CMP 1.1 bean in an EJB 1.1 module, makes the entire local interface column uneditable in the table.
Value Object is an object that contains the fields that represent the EJB's accessor methods. Use this J2EE Assistant feature to create a value object for a specific CMP. This feature supports both CMP 1.1 and CMP 2.0 type of bean. Click on J2EE Assistant > Create Value Object on the main menu, or right click on the bean's properties file in the Explore Panel and select Create Value Object. This pops up the Value Object Dialog. The menu items are enabled only when the selected bean in the Explore Panel is a CMP Bean.
Creating a Value Object for a CMP Bean includes creation of the following:
The Create Value Object dialog that pops up has the following fields that the user fills as per the requirement:
To create the getter and setter methods for the value object in the bean interfaces, check the options provided:
Selecting the getter/setter options creates the getter/setter for the Value Object in the corresponding interface. The bean code is also updated automatically
Click OK after filling in all the details in the dialog. This button is disabled when none of the checkboxes are selected. To cancel the command, click on Cancel.
Some of the intelligent features that the J2EE Assistant provides are:
| Pramati Technologies © Copyright |
|