![]() |
Creating Enterprise JavaBeansTM (EJB) without appropriate tools is a complex process and involves repetitive ways of writing the bean skeleton code, business logic, defining relationships, creating interfaces and specific XML packaging and deployment descriptors.
Studio provides Bean Wizard that eliminates all system-level coding and abstracts the bean creation process to specifying the bean type and writing the business logic.
This document describes the basic approach to writing EJBs in Studio that keeps them in a ready-to-deploy state. Bean Wizard generates source code for EJBs in such a way that it can be included in an assembled application without requiring further source adaptations or recompilation.
Studio allows you to create the following EJBs and their components using the Bean Wizard defined based on EJB 2.0 specification:
Studio stores beans in EJB modules and Java modules. Express Development keeps the following EJB modules in a ready-to-deploy state:
Following elements are displayed under the module in the respective bean package hierarchy:
The business methods are always written in the bean class in Editor. Interfaces are generated automatically and compiled each time a bean is generated, business methods are added, and code compiled.
Bean properties node encapsulates application logic of the bean and describes the enterprise bean and runtime attributes. There can be more than one bean properties node for a single bean class as the node is created for each EJB name of the bean.
The EJB name is used to specify an enterprise bean name which must be unique to the module or JAR.
To open Bean Properties panel, right click on a bean properties node and click Open or double click on the node.
Properties set here get added to the bean when it is added to a JAR; Changes made here do not affect the bean source. Changes in bean code such as removal of get/set methods corresponding to Container Managed Persistence (CMP) and Container Managed Relationships (CMR) are identified when the bean code is compiled. Compiling the bean code reflects the latest CMRs and CMFs in Bean Properties panel.
Respective bean properties are displayed on the left tree. Bean attributes that can be set are:
The properties that can be set only through the Bean Properties panel are:
A few other properties that can be set are bean display name, bean class, remote class, home class, local home class, local class, primary key, APS Name, and JNDI name in the main panel of the bean.
For bean properties node to function properly, the bean should be compiled.
Changes made to the bean in Bean Properties dialog are not reflected in the JAR if the bean concerned has already been added to the JAR. To achieve this, remove the bean from the JAR and add it again. Also, changes made in the JAR do not affect the bean properties globally.
Bean Properties dialog allows you to enter deploy time information. Information that can be supplied to bean properties that pertain to Deployment are:
This allows you to specify JNDI name of the EJB reference and resource reference while creating a bean and carries this information forward to the deployment time.
When sources for a bean class is imported into a desk, bean properties node does not get created in the desk corresponding to the imported bean class.
To create bean properties for the Bean Class, right click on the specific Bean source file and select Create Bean Properties.
Enter EJB name for the bean; select bean type. Checking the option Open in Bean Properties creates the Bean Properties on the desk, and opens the Bean Properties panel. Creating Bean Properties in this way, creates properties with partial information.
Cloning feature is used to create beans from the existing beans, with a different EJB name. Having different EJB names gives a different identity to the new bean. Cloning a bean typically consists of creating a copy of bean properties with a new EJBName, and copying all its Java files if required. The resulting bean does not retain finder query mapping for EJB 1.1, OR mapping, and the user has to provide new values if the destination module is the same as the source module. This information is retained if destination module is different from source module.
Source files are not copied if the new bean is in the same module as source bean. In this case only a new bean properties node gets added to the desk.
To clone a bean, right click on bean properties node and select Clone Bean. In the Clone panel, enter the following information:
The list of destination modules is filtered to prevent the beans from being cloned into folders that cannot accept them. Restrictions include:
Cloning a CMP 2.0 bean that has relationships with other beans requires all beans along with source bean, to be cloned. In cases where the beans have relationships, all the beans in the CMR Graph are shown. Providing new EJB names ensure that the source and target CMR graphs are complete and ready-to-deploy.
Target bean properties are always written in the file system irrespective of their existence in destination module
Click Clone to start cloning operation; click Close to close the panel.
| Pramati Technologies © Copyright |
|