Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

The deployment plan should always use the OpenEJB namespace, and it typically requires elements from the Geronimo Naming, Geronimo Security, and Geronimo System namespaces. Additionally, it has a required attribute to identify its configuration name, and an optional attribute to select a parent configuration. A typical deployment for openejb-jar.xml can be presented as follows:

Code Block
xml
borderStylesolid
titleopenejb-jarborderStylesolid
xml
<openejb-jar
 	xmlns:openejb="http://www.openejb.org/xml/ns/openejb-jar-2.1"
 	targetNamespace="http://www.openejb.org/xml/ns/openejb-jar-2.1"
 	xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
 	xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
 	xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1"
 	xmlns:pkgen="http://www.openejb.org/xml/ns/pkgen-2.0"
 	version="1.0">
 	...
 </openejb-jar>

...

Here is the ejb-jar.xml for the above sample :

solid
No Format
borderStyle
titleejb-jar.xml
borderStylesolid

Geronimo v1.1 deployment plan for the above sample

solid
No Format
borderStyle
titleopenejb.jar
borderStylesolid

Steps to deploying the sample

...

The following openejb-jar.xml has taken from the http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html
This example is using a EJB session bean and how it has implemented inside the openejb-jar.xml

Code Block
xml
borderStylesolid
titleopenejb-jar.xmlborderStylesolid
xml
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
    <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId>
            <dep:groupId>default</dep:groupId>
            <dep:artifactId>BankEJB</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>car</dep:type>
        </dep:moduleId>
        <dep:dependencies/>
        <dep:hidden-classes/>
        <dep:non-overridable-classes/>
    </dep:environment>
    <cmp-connection-factory>
        <resource-link>BankPool</resource-link>
    </cmp-connection-factory>
    <enterprise-beans>
        <session>
            <ejb-name>BankManagerFacadeBean</ejb-name>
            <jndi-name>org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean</jndi-name>
            <ejb-ref>
                <ref-name>ejb/Customer</ref-name>
                <ejb-link>Customer</ejb-link>
            </ejb-ref>
            <ejb-ref>
                <ref-name>ejb/Account</ref-name>
                <ejb-link>Account</ejb-link>
            </ejb-ref>
            <ejb-ref>
                <ref-name>ejb/ExchangeRate</ref-name>
                <ejb-link>ExchangeRate</ejb-link>
            </ejb-ref>
        </session>
 	 

        <entity>
            <ejb-name>Account</ejb-name>
            <local-jndi-name>AccountLocalEntity</local-jndi-name>
            <table-name>Account</table-name>
 	 

            <cmp-field-mapping>
                <cmp-field-name>accountNumber</cmp-field-name>
                <table-column>ACC_NO</table-column>
            </cmp-field-mapping>
 	 

            <cmp-field-mapping>
                <cmp-field-name>accountType</cmp-field-name>
                <table-column>ACC_TYPE</table-column>
            </cmp-field-mapping>
 	 

            <cmp-field-mapping>
                <cmp-field-name>customer</cmp-field-name>
                <table-column>CUSTID_FK</table-column>
            </cmp-field-mapping>
 	 

            <cmp-field-mapping>
                <cmp-field-name>balance</cmp-field-name>
                <table-column>BALANCE</table-column>
            </cmp-field-mapping>
 	 

            <resource-ref>
                <ref-name>jdbc/BankDataSource</ref-name>
                <resource-link>BankPool</resource-link>
            </resource-ref>
        </entity>
 	 

        <entity>
            <ejb-name>Customer</ejb-name>
            <local-jndi-name>CustomerLocalEntity</local-jndi-name>
            <table-name>Customer</table-name>
 	 

            <cmp-field-mapping>
                <cmp-field-name>customerId</cmp-field-name>
                <table-column>CUST_ID</table-column>
            </cmp-field-mapping>
 	 

            <cmp-field-mapping>
                <cmp-field-name>customerName</cmp-field-name>
                <table-column>CUST_NAME</table-column>
            </cmp-field-mapping>
 	 

            <resource-ref>
                <ref-name>jdbc/BankDataSource</ref-name>
                <resource-link>BankPool</resource-link>
            </resource-ref>
        </entity>
 	 

        <entity>
            <ejb-name>ExchangeRate</ejb-name>
            <local-jndi-name>ExchangeRate</local-jndi-name>
            <resource-ref>
                <ref-name>jdbc/BankDataSource</ref-name>
                <resource-link>BankPool</resource-link>
            </resource-ref>
        </entity>
    </enterprise-beans>
 	 

    <relationships>
        <ejb-relation>
            <ejb-relation-name>Customer-Account</ejb-relation-name>
            <ejb-relationship-role>
                <ejb-relationship-role-name>Account-to-Customer</ejb-relationship-role-name>
                <relationship-role-source>
                    <ejb-name>Account</ejb-name>
                </relationship-role-source>
                <cmr-field>
                    <cmr-field-name>customer</cmr-field-name>
                </cmr-field>
                <foreign-key-column-on-source/>
                <role-mapping>
                    <cmr-field-mapping>
                        <key-column>CUST_ID</key-column>
                        <foreign-key-column>CUSTID_FK</foreign-key-column>
                    </cmr-field-mapping>
                </role-mapping>
            </ejb-relationship-role>
        </ejb-relation>
 	 

    </relationships>
 	 

</openejb-jar>

...

In order to deploy a JMS/MDB with Geronimo it's required to create a JMS resource plan.The purpose of creating the JMS plan is that from the geronimo server end you will be accessing JMS/MDB resource using this plan which will define all the definitions for the connection factories and the Queues/Topics

Code Block
xmlborderStylesolid
titleJMS_resource_plan.xml
borderStylesolid
xml
 
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1">
    <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId>
            <dep:groupId>samples</dep:groupId>
            <dep:artifactId>jms-resources</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>rar</dep:type>
        </dep:moduleId>
        <dep:dependencies>
            <dep:dependency>
                <dep:groupId>geronimo</dep:groupId>
                <dep:artifactId>activemq-broker</dep:artifactId>
                <dep:type>car</dep:type>
            </dep:dependency>
        </dep:dependencies>
    </dep:environment>
    <resourceadapter>
        <resourceadapter-instance>
            <resourceadapter-name>CommonConnectionFactory</resourceadapter-name>
            <config-property-setting name="Password">geronimo</config-property-setting>
            <config-property-setting name="UserName">geronimo</config-property-setting>
            <nam:workmanager xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1">
                <nam:gbean-link>DefaultWorkManager</nam:gbean-link>
            </nam:workmanager>
        </resourceadapter-instance>
        <outbound-resourceadapter>
            <connection-definition>
                <connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>
                <connectiondefinition-instance>
                    <name>CommonConnectionFactory</name>
                    <connectionmanager>
                        <xa-transaction>
                            <transaction-caching/>
                        </xa-transaction>
                        <single-pool>
                            <match-one/>
                        </single-pool>
                    </connectionmanager>
                </connectiondefinition-instance>
            </connection-definition>
        </outbound-resourceadapter>
    </resourceadapter>
    <adminobject>
        <adminobject-interface>javax.jms.Queue</adminobject-interface>
        <adminobject-class>org.activemq.message.ActiveMQQueue</adminobject-class>
        <adminobject-instance>
            <message-destination-name>OrderQueue</message-destination-name>
            <config-property-setting name="PhysicalName">OrderQueue</config-property-setting>
        </adminobject-instance>
        <adminobject-instance>
            <message-destination-name>ConsignmentQueue</message-destination-name>
            <config-property-setting name="PhysicalName">ConsignmentQueue</config-property-setting>
        </adminobject-instance>
    </adminobject>
    <adminobject>
        <adminobject-interface>javax.jms.Topic</adminobject-interface>
        <adminobject-class>org.activemq.message.ActiveMQTopic</adminobject-class>
    </adminobject>
</connector>

Geronimo web console provides the needful to create a JMS resource plan structure and it's required to fill your bunisess logic to map to fill your requirements.Once you log in to the web console in your left hand side navigation you will find a JMS resource link under services.In this application there is a MDB that will listen on OrderQueue. openejb-jar.xml defines Geronimo specific JMS resource services available of that MDB. It links OrderRecv MDB with OrderQueue via CommonConnectionFactory.This Article will be discussing further details of the relationship of the JMS resource plan and the openejb-jar.xml in Resolving references session(link this to the topic)

Code Block
xmlborderStylesolid
titleopenejb-jar.xml
borderStylesolid
xml
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
    xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
    <sys:environment>
        <sys:moduleId>
            <sys:groupId>samples</sys:groupId>
            <sys:artifactId>OrderEjb</sys:artifactId>
            <sys:version>1.0</sys:version>
            <sys:type>car</sys:type>
        </sys:moduleId>
        <sys:dependencies>
            <sys:dependency>
                <sys:groupId>geronimo</sys:groupId>
                <sys:artifactId>activemq-broker</sys:artifactId>
                <sys:type>car</sys:type>
            </sys:dependency>
            <sys:dependency>
                <sys:groupId>samples</sys:groupId>
                <sys:artifactId>jms-resources</sys:artifactId>
                <sys:version>1.0</sys:version>
                <sys:type>rar</sys:type>
            </sys:dependency>
        </sys:dependencies>
        <sys:hidden-classes/>
        <sys:non-overridable-classes/>
    </sys:environment>
    <enterprise-beans>
        <message-driven>
            <ejb-name>OrderRecvMDB</ejb-name>
            <resource-adapter>
                <resource-link>CommonConnectionFactory</resource-link>
            </resource-adapter>
            <activation-config>
                <activation-config-property>
                    <activation-config-property-name>destination</activation-config-property-name>
                    <activation-config-property-value>OrderQueue</activation-config-property-value>
                </activation-config-property>
                <activation-config-property>
                    <activation-config-property-name>destinationType</activation-config-property-name>
                    <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
                </activation-config-property>
            </activation-config>
        </message-driven>
    </enterprise-beans>
</openejb-jar>

...

The Scenario of the Sample is a Web Client(JSP) which locate and access a EJB by referring it locally.Simply it has used home interface to locate the EJB(service) and the remote interface has used to invoke methods on the EJB. The remote interface is just like a ordinary Remote Method Invocation interface (RMI). This EJB service is used only by the JSP web client which is run in the same Geronimo server (same JVM). Let's discuss how the EJB locally in deployment plans

Code Block
xmlborderStylesolid
titleweb.xml
borderStylesolid
xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>
 	MyTImeWeb</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <!-- To refer local EJB's -->
    <ejb-local-ref>
        <ejb-ref-name>ejb/MyTimeBean</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <local-home>mytimepak.MyTimeLocalHome</local-home>
        <local>mytimepak.MyTimeLocal</local>
        <ejb-link>MyTimeBean</ejb-link>
    </ejb-local-ref>
</web-app>

As above shown in the web.xml file <ejb-local-ref> tag has used to define and set the values for locally referring EJB interfaces MyTimeLocalHome and MyTimeLocal.As you can see in the following geronimo-web.xml has not defined any entry for it that means for there is not server specific entry need to be define for a EJB reference.

Code Block
xmlborderStylesolid
titlegeronimo-web.xml
borderStylesolid
xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1"
xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
    <sys:environment>
        <sys:moduleId>
            <sys:groupId>default</sys:groupId>
            <sys:artifactId>MyTimeWeb</sys:artifactId>
            <sys:version>1.0</sys:version>
            <sys:type>car</sys:type>
        </sys:moduleId>
    </sys:environment>
    <context-root>/mytime</context-root>
</web-app>
Code Block
xmlborderStylesolid
titleejb-jar.xml
borderStylesolid
xml
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_1" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
 	http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">
    <description>Example of a session bean</description>
    <display-name>MyTimeBeanEJBName</display-name>
    <enterprise-beans>
        <session id="Session_MyTime">
            <description>An EJB named MyTimeBean</description>
            <display-name>MyTimeBeanName</display-name>
            <ejb-name>MyTimeBean</ejb-name>
            <local-home>mytimepak.MyTimeLocalHome</local-home>
            <local>mytimepak.MyTimeLocal</local>
            <ejb-class>mytimepak.MyTimeBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
        </session>
    </enterprise-beans>
</ejb-jar>

...

Each resource reference must have a ref-name, which is used to match the definition in the openejb-jar.xml to the resource reference in ejb-jar.xml. Specifically, the value here must match the res-ref-name in the resource-ref in ejb-jar.xml.

Code Block
xmlborderStylesolid
titleExcerpt from openejb-jar.xml
borderStylesolid
xml
<entity>
 	....
    <resource-ref>
        <ref-name>jdbc/BankDataSource</ref-name>
        <resource-link>BankPool</resource-link>
    </resource-ref>
</entity>

...

This element can be used to identify any resource deployed as a J2EE connector (including JDBC pools and JMS connection factories). The value specified here should match the connectiondefinition-instance/name element in the Geronimo deployment plan for the connector.

Code Block
xmlborderStylesolid
titleExcerpt from openejb-jar.xml
borderStylesolid
xml
<entity>
    <ejb-name>ExchangeRate</ejb-name>
    <local-jndi-name>ExchangeRate</local-jndi-name>
    <resource-ref>
        <ref-name>jdbc/BankDataSource</ref-name>
        <resource-link>BankPool</resource-link>
    </resource-ref>
</entity>

...

Message Listener allows a listener to be notified when a message arrives. Contrary to the pull-style of channels, some building blocks (e.g., PullPushAdapter) provide an event-like, push-style message delivery model. In this case, the entity to be notified of message reception needs to provide a callback to be invoked whenever a message has been received. The MessageListener interface provides a method to do so

Code Block
xmlborderStylesolid
titleopenejb-jar.xml
borderStylesolid
xml
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1"
    xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1"
    xmlns:security="http://geronimo.apache.org/xml/ns/security-1.1"
    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.1">
    <sys:environment>
        <sys:moduleId>
            <sys:groupId>samples</sys:groupId>
            <sys:artifactId>OrderEjb</sys:artifactId>
            <sys:version>1.0</sys:version>
            <sys:type>car</sys:type>
        </sys:moduleId>
        <sys:dependencies>
            <sys:dependency>
                <sys:groupId>geronimo</sys:groupId>
                <sys:artifactId>activemq-broker</sys:artifactId>
                <sys:type>car</sys:type>
            </sys:dependency>
            <sys:dependency>
                <sys:groupId>samples</sys:groupId>
                <sys:artifactId>jms-resources</sys:artifactId>
                <sys:version>1.0</sys:version>
                <sys:type>rar</sys:type>
            </sys:dependency>
        </sys:dependencies>
        <sys:hidden-classes/>
        <sys:non-overridable-classes/>
    </sys:environment>
    <enterprise-beans>
        <message-driven>
            <ejb-name>OrderRecvMDB</ejb-name>
            <resource-adapter>
                <resource-link>CommonConnectionFactory</resource-link>
            </resource-adapter>
            <activation-config>
                <activation-config-property>
                    <activation-config-property-name>destination</activation-config-property-name>
                    <activation-config-property-value>OrderQueue</activation-config-property-value>
                </activation-config-property>
                <activation-config-property>
                    <activation-config-property-name>destinationType</activation-config-property-name>
                    <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
                </activation-config-property>
            </activation-config>
        </message-driven>
    </enterprise-beans>
</openejb-jar>

...

For reference, here's a snippet from a JMS connector deployment plan that matches the EJB JAR configuration above and this can be generated using the geronimo web console.One can identify the <moduleId> ,<dependency> and <adminobject> are mapped the ejb-jar.xml.

Code Block
xmlborderStylesolid
titlejms-resource-plan.xml
borderStylesolid
xml
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1">
    <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId>
            <dep:groupId>samples</dep:groupId>
            <dep:artifactId>jms-resources</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>rar</dep:type>
        </dep:moduleId>
        <dep:dependencies>
            <dep:dependency>
                <dep:groupId>geronimo</dep:groupId>
                <dep:artifactId>activemq-broker</dep:artifactId>
                <dep:type>car</dep:type>
            </dep:dependency>
        </dep:dependencies>
    </dep:environment>
    <resourceadapter>
        <resourceadapter-instance>
            <resourceadapter-name>CommonConnectionFactory</resourceadapter-name>
            <config-property-setting name="Password">geronimo</config-property-setting>
            <config-property-setting name="UserName">geronimo</config-property-setting>
            <nam:workmanager xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1">
                <nam:gbean-link>DefaultWorkManager</nam:gbean-link>
            </nam:workmanager>
        </resourceadapter-instance>
        <outbound-resourceadapter>
            <connection-definition>
                <connectionfactory-interface>javax.jms.QueueConnectionFactory</connectionfactory-interface>
                <connectiondefinition-instance>
                    <name>CommonConnectionFactory</name>
                    <connectionmanager>
                        <xa-transaction>
                            <transaction-caching/>
                        </xa-transaction>
                        <single-pool>
                            <match-one/>
                        </single-pool>
                    </connectionmanager>
                </connectiondefinition-instance>
            </connection-definition>
        </outbound-resourceadapter>
    </resourceadapter>
    <adminobject>
        <adminobject-interface>javax.jms.Queue</adminobject-interface>
        <adminobject-class>org.activemq.message.ActiveMQQueue</adminobject-class>
        <adminobject-instance>
            <message-destination-name>OrderQueue</message-destination-name>
            <config-property-setting name="PhysicalName">OrderQueue</config-property-setting>
        </adminobject-instance>
        <adminobject-instance>
            <message-destination-name>ConsignmentQueue</message-destination-name>
            <config-property-setting name="PhysicalName">ConsignmentQueue</config-property-setting>
        </adminobject-instance>
    </adminobject>
    <adminobject>
        <adminobject-interface>javax.jms.Topic</adminobject-interface>
        <adminobject-class>org.activemq.message.ActiveMQTopic</adminobject-class>
    </adminobject>
</connector>

...

Following openejb-jar.xml has taken from the http://cwiki.apache.org/GMOxDOC11/ejb-sample-application.html.It has defined the dependencies in the <environment> segment and <cmp-connection-factory> is set to the Data Base plan.

Code Block
xmlborderStylesolid
titleopenejb-jar.xml
borderStylesolid
xml
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
    <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
        <dep:moduleId>
            <dep:groupId>default</dep:groupId>
            <dep:artifactId>BankEJB</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>car</dep:type>
        </dep:moduleId>
        <dep:dependencies/>
        <dep:hidden-classes/>
        <dep:non-overridable-classes/>
    </dep:environment>
    <cmp-connection-factory>
        <resource-link>BankPool</resource-link>
    </cmp-connection-factory>
    <enterprise-beans>
        <session>
            <ejb-name>BankManagerFacadeBean</ejb-name>
            <jndi-name>org.apache.geronimo.samples.bank.ejb.BankManagerFacadeBean</jndi-name>
            <ejb-ref>
                <ref-name>ejb/Customer</ref-name>
                <ejb-link>Customer</ejb-link>
            </ejb-ref>
            <ejb-ref>
                <ref-name>ejb/Account</ref-name>
                <ejb-link>Account</ejb-link>
            </ejb-ref>
            <ejb-ref>
                <ref-name>ejb/ExchangeRate</ref-name>
                <ejb-link>ExchangeRate</ejb-link>
            </ejb-ref>
        </session>
 	 

        <entity>
            <ejb-name>Account</ejb-name>
            <local-jndi-name>AccountLocalEntity</local-jndi-name>
            <table-name>Account</table-name>
 	 

            <cmp-field-mapping>
                <cmp-field-name>accountNumber</cmp-field-name>
                <table-column>ACC_NO</table-column>
            </cmp-field-mapping>
 	 

            <cmp-field-mapping>
                <cmp-field-name>accountType</cmp-field-name>
                <table-column>ACC_TYPE</table-column>
            </cmp-field-mapping>
 	 

            <cmp-field-mapping>
                <cmp-field-name>customer</cmp-field-name>
                <table-column>CUSTID_FK</table-column>
            </cmp-field-mapping>
 	 

            <cmp-field-mapping>
                <cmp-field-name>balance</cmp-field-name>
                <table-column>BALANCE</table-column>
            </cmp-field-mapping>
 	 

            <resource-ref>
                <ref-name>jdbc/BankDataSource</ref-name>
                <resource-link>BankPool</resource-link>
            </resource-ref>
        </entity>
 	 

        <entity>
            <ejb-name>Customer</ejb-name>
            <local-jndi-name>CustomerLocalEntity</local-jndi-name>
            <table-name>Customer</table-name>
 	 

            <cmp-field-mapping>
                <cmp-field-name>customerId</cmp-field-name>
                <table-column>CUST_ID</table-column>
            </cmp-field-mapping>
 	 

            <cmp-field-mapping>
                <cmp-field-name>customerName</cmp-field-name>
                <table-column>CUST_NAME</table-column>
            </cmp-field-mapping>
 	 

            <resource-ref>
                <ref-name>jdbc/BankDataSource</ref-name>
                <resource-link>BankPool</resource-link>
            </resource-ref>
        </entity>
 	 

        <entity>
            <ejb-name>ExchangeRate</ejb-name>
            <local-jndi-name>ExchangeRate</local-jndi-name>
            <resource-ref>
                <ref-name>jdbc/BankDataSource</ref-name>
                <resource-link>BankPool</resource-link>
            </resource-ref>
        </entity>
    </enterprise-beans>
 	 

    <relationships>
        <ejb-relation>
            <ejb-relation-name>Customer-Account</ejb-relation-name>
            <ejb-relationship-role>
                <ejb-relationship-role-name>Account-to-Customer</ejb-relationship-role-name>
                <relationship-role-source>
                    <ejb-name>Account</ejb-name>
                </relationship-role-source>
                <cmr-field>
                    <cmr-field-name>customer</cmr-field-name>
                </cmr-field>
                <foreign-key-column-on-source/>
                <role-mapping>
                    <cmr-field-mapping>
                        <key-column>CUST_ID</key-column>
                        <foreign-key-column>CUSTID_FK</foreign-key-column>
                    </cmr-field-mapping>
                </role-mapping>
            </ejb-relationship-role>
        </ejb-relation>
 	 

    </relationships>
 	 

</openejb-jar>

Let's consider the CMP mapping implementation of the following code which is excerpt from the above openejb-jar.xml

solid
Code Block
borderStyle
titleExcerpt from openejb-jar.xml
borderStylesolid
<entity>
    <ejb-name>Customer</ejb-name>
    <local-jndi-name>CustomerLocalEntity</local-jndi-name>
    <table-name>Customer</table-name>
 	 

    <cmp-field-mapping>
        <cmp-field-name>customerId</cmp-field-name>
        <table-column>CUST_ID</table-column>
    </cmp-field-mapping>
 	 

    <cmp-field-mapping>
        <cmp-field-name>customerName</cmp-field-name>
        <table-column>CUST_NAME</table-column>
    </cmp-field-mapping>
 	 

    <resource-ref>
        <ref-name>jdbc/BankDataSource</ref-name>
        <resource-link>BankPool</resource-link>
    </resource-ref>
</entity>

Each DataBase mapping are configured with in the <cmp-field-mapping> and <cmp-field-mapping> is set to the customerId which is deployment plan specific reference for the name of the data field."CUS_ID" is the actual name of the data base field in the DataBase.

solid
Code Block
borderStyle
titleBankDB.sql
borderStylesolid
CREATE TABLE customer(
 	CUST_ID VARCHAR(15) PRIMARY KEY,
 	CUST_NAME VARCHAR(40)
 	);