Discuss this tutorial. Printable version (PDF).
Go to Contents page. Go to previous page. Go up a level. Go to next page.

 

Implementation


This section describes how container-managed persistence (CMP) is implemented in the FBS 10g. In addition to the deployment descriptor information described in the Design section, this is what you must implement for each bean that uses container-managed persistence:

  • Bean implementation class, which implements javax.ejb.EntityBean and declares accessor methods to get and set the bean's attribute values. Depending on the direction, you may need to declare methods to get and set the bean or collection of beans at the other end of the relationship. The implementation of the ejbCreate method calls the various set methods when the bean is instantiated. Example: PreferencesBean.java

  • Local interface, which publishes the bean's public methods and makes them available to beans in the same container. Example: PreferencesLocal.java

  • HomeLocal interface, which provides methods for finding and creating bean instances. Example: PreferencesHomeLocal.java

Given these classes and interfaces and a deployment descriptor, the container provider's tools will generate the Java code and support files required to implement container-managed persistence. OC4J provides such tools, and they can be used with Oracle9i JDeveloper. JDeveloper also provides wizards that generate CMP code based on developer-provided table names.

When the implementation is complete, create an EJB JAR file containing the bean, its interfaces, and deployment descriptor. Then create an EAR file and deploy it to the container.

At runtime, the container manages the bean's data by interacting with the datasource, typically a relational database. The FBS 10g specifies datasource names in the <J2EE_HOME>/config/data-sources.xml and <SAMPLE_HOME>/etc/Connection.properties files. If the persistent data is saved to or restored from a database and you are not using the defaults provided by the container, you must ensure that the correct tables exist for the bean. In the default scenario, the container creates the table and columns for yor data based on deployment descriptor and datasource information.


Discuss this tutorial. Printable version (PDF).
Go to Contents page. Go to previous page. Go up a level. Go to next page.
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy