Monday, 4 May 2009

9-How to Develop Bean-Managed-Persistence Entity Beans

FILE: jndi.properties
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.factory.url.pkgs=weblogic.jndi.factories:weblogic.corba.j2ee.naming.url:weblogic.corba.client.naming
java.naming.provider.url=t3://localhost:7101
java.naming.security.principal=weblogic
java.naming.security.credentials=weblogic

FILE: ejb-jar.xml
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN'
'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>


<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>StudentEJB</ejb-name>
<home>bmpex.StudentHome</home>
<remote>bmpex.Student</remote>
<ejb-class>bmpex.StudentEJB</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<env-entry>
<env-entry-name>param/StudentDAOClass</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>bmpex.StudentDAOPB</env-entry-value>
</env-entry>
<resource-ref>
<res-ref-name>myJDBCDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!--resource-env-ref>
<resource-env-ref-name>myJDBCDataSource</resource-env-ref-name>
<resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type>
</resource-env-ref-->


</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>StudentEJB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

FILE: weblogic-ejb-jar.xml
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 7.0.0 EJB//EN'
'http://www.bea.com/servers/wls700/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>StudentEJB</ejb-name>
<reference-descriptor>
<resource-description>
<res-ref-name>myJDBCDataSource</res-ref-name>
<jndi-name>styejbDB</jndi-name>
</resource-description>
</reference-descriptor>
<jndi-name>bmpex/Student</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>