...
The root XML element in the openejb-jar-2.2.xsd schema is the <openejb-jar-2.2> element. The top-level XML elements of the <openejb-jar> root element are described in the sections below. 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. A typical deployment for openejb-jar.xml can be presented as follows:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | openejb-jar.xml Example |
---|
borderStyle | solid |
---|
| xml |
---|
|
<openejb-jar
xmlns:openejb="http://openejb.apache.org/xml/ns/gopenejb-jar-2.2"
targetNamespace="http://openejb.apache.org/xml/ns/gopenejb-jar-2.2"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
xmlns:security="http://geronimo.apache.org/xml/ns/security-2.0"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:pkgen="http://openejb.apache.org/xml/ns/gpkgen-2.1"
version="1.0">
...
</openejb-jar>
|
...
An example openejb-jar.xml file is shown below using the <sys:environment> element:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <sys:environment> Example | borderStyle | solid |
---|
| xml |
---|
|
<openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">
<sys:environment>
<sys:moduleId>
<sys:groupId>default</sys:groupId>
<sys:artifactId>openejb-jar-1</sys:artifactId>
<sys:version>2.0</sys:version>
<sys:type>ear</sys:type>
</sys:moduleId>
<sys:dependencies>
<sys:dependency>
<sys:groupId>org.apache.geronimo.testsuite</sys:groupId>
<sys:artifactId>agent-ds</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
<sys:dependency>
<sys:groupId>org.apache.geronimo.configs</sys:groupId>
<sys:artifactId>tomcat6</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
</sys:dependencies>
</sys:environment>
</openejb-jar>
|
...
The <naming:cmp-connection-factory> element is used to specify a JDBC connection pool that should be used by Container Managed Persistence (CMP) entity beans to connect to a database. Since the <naming:cmp-connection-factory> element points to a database pool using the same syntax a resource reference uses, there are multiple methods available to refer to the connection pool. It can be specified by a simple name using the <resource-link> element, by pattern using the <pattern> element, or finally by URL using the <url> element. The resource-link handles most common resource situations where the JDBC pools are deployed as J2EE connectors in the same application, or deployed standalone in the same server. But pattern or URL can be use for any. An example openejb-jar.xml using all three techniques is shown:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <naming:cmp-connection-factory> Example | borderStyle |
---|
| solid | xml |
---|
|
<openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2">
<sys:environment>
<sys:moduleId>
<sys:groupId>default</sys:groupId>
<sys:artifactId>openejb-jar-1</sys:artifactId>
<sys:version>2.0</sys:version>
<sys:type>ear</sys:type>
</sys:moduleId>
<sys:dependencies>
<sys:dependency>
<sys:groupId>org.apache.geronimo.testsuite</sys:groupId>
<sys:artifactId>agent-ds</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
<sys:dependency>
<sys:groupId>org.apache.geronimo.configs</sys:groupId>
<sys:artifactId>tomcat6</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
</sys:dependencies>
</sys:environment>
<!-- Begin configuration for Container Managed Persistence (CMP) -->
<naming:cmp-connection-factory>
<naming:pattern>
<naming:groupId>resourcelocator-pattern-groupid</naming:groupId>
<naming:artifactId>resourcelocator-pattern-artifactid</naming:artifactId>
<naming:version>resourcelocator-pattern-version</naming:version>
<naming:module>resourcelocator-pattern-module</naming:module>
<naming:name>resourcelocator-pattern-name</naming:name>
</naming:pattern>
<naming:resource-link>resourcelocator-resourcelink</naming:resource-link>
<naming:url>resourcelocator-url</naming:url>
</naming:cmp-connection-factory>
<!-- End configuration for Container Managed Persistence (CMP) -->
</openejb-jar>
|
...
The <ejb-ql-compiler-factory> element is used to specify the name of a Java class that can compile EJB-QL (Query Language) queries into SQL statements for a particular database product. This must be the fully-qualified class name of a class that implements org.tranql.sql.EJBQLCompilerFactory. The default is for the Derby database, which ships with Geronimo, although it may work for other database products as well. An example openejb-jar.xml using the <ejb-ql-compiler-factory> XML element is shown:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <ejb-ql-compiler-factory> Example | borderStyle | solid |
---|
| xml |
---|
|
<openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2">
<sys:environment>
<sys:moduleId>
<sys:groupId>default</sys:groupId>
<sys:artifactId>openejb-jar-1</sys:artifactId>
<sys:version>2.0</sys:version>
<sys:type>ear</sys:type>
</sys:moduleId>
<sys:dependencies>
<sys:dependency>
<sys:groupId>org.apache.geronimo.testsuite</sys:groupId>
<sys:artifactId>agent-ds</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
<sys:dependency>
<sys:groupId>org.apache.geronimo.configs</sys:groupId>
<sys:artifactId>tomcat6</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
</sys:dependencies>
</sys:environment>
<!-- Begin configuration for Container Managed Persistence (CMP) -->
<naming:cmp-connection-factory>
<naming:pattern>
<naming:groupId>resourcelocator-pattern-groupid</naming:groupId>
<naming:artifactId>resourcelocator-pattern-artifactid</naming:artifactId>
<naming:version>resourcelocator-pattern-version</naming:version>
<naming:module>resourcelocator-pattern-module</naming:module>
<naming:name>resourcelocator-pattern-name</naming:name>
</naming:pattern>
<naming:resource-link>resourcelocator-resourcelink</naming:resource-link>
<naming:url>resourcelocator-url</naming:url>
</naming:cmp-connection-factory>
<ejb-ql-compiler-factory>ejbqlcompilerfactory</ejb-ql-compiler-factory>
<!-- End configuration for Container Managed Persistence (CMP) -->
</openejb-jar>
|
...
The <db-syntax-factory> element is used to specify the name of a Java class that can customize CMP SQL statements for a particular database product. This must be the fully-qualified class name of a class that implements org.tranql.sql.DBSyntaxFactory. The default is for the Derby database, which ships with Geronimo, although it may work for other database products as well. An example openejb-jar.xml using the <db-syntax-factory> XML element is shown:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <db-syntax-factory> Example | borderStyle | solid |
---|
| xml |
---|
|
<openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2">
<sys:environment>
<sys:moduleId>
<sys:groupId>default</sys:groupId>
<sys:artifactId>openejb-jar-1</sys:artifactId>
<sys:version>2.0</sys:version>
<sys:type>ear</sys:type>
</sys:moduleId>
<sys:dependencies>
<sys:dependency>
<sys:groupId>org.apache.geronimo.testsuite</sys:groupId>
<sys:artifactId>agent-ds</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
<sys:dependency>
<sys:groupId>org.apache.geronimo.configs</sys:groupId>
<sys:artifactId>tomcat6</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
</sys:dependencies>
</sys:environment>
<!-- Begin configuration for Container Managed Persistence (CMP) -->
<naming:cmp-connection-factory>
<naming:pattern>
<naming:groupId>resourcelocator-pattern-groupid</naming:groupId>
<naming:artifactId>resourcelocator-pattern-artifactid</naming:artifactId>
<naming:version>resourcelocator-pattern-version</naming:version>
<naming:module>resourcelocator-pattern-module</naming:module>
<naming:name>resourcelocator-pattern-name</naming:name>
</naming:pattern>
<naming:resource-link>resourcelocator-resourcelink</naming:resource-link>
<naming:url>resourcelocator-url</naming:url>
</naming:cmp-connection-factory>
<ejb-ql-compiler-factory>ejbQlCompilerFactory</ejb-ql-compiler-factory>
<db-syntax-factory>dbSyntaxFactory</db-syntax-factory>
<!-- End configuration for Container Managed Persistence (CMP) -->
</openejb-jar>
|
...
The <enforce-foreign-key-constraints> element is effectively a true/false element – if it's present that means true, and if it's not present, that means false. If true, then Geronimo will make a special effort to execute insert, update, and delete statements in an order consistent with the foreign keys between tables. If false, then Geronimo will execute statements in any order, though still within the same transaction. This element should be present if the underlying database enforces foreign keys at the moment a statement is executed instead of at the end of the transaction. An example openejb-jar.xml setting the <db-syntax-factory> XML element to "true" is shown:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <enforce-foreign-key-constraints> Example | borderStyle |
---|
| solid | xml |
---|
|
<openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2">
<sys:environment>
<sys:moduleId>
<sys:groupId>default</sys:groupId>
<sys:artifactId>openejb-jar-1</sys:artifactId>
<sys:version>2.0</sys:version>
<sys:type>ear</sys:type>
</sys:moduleId>
<sys:dependencies>
<sys:dependency>
<sys:groupId>org.apache.geronimo.testsuite</sys:groupId>
<sys:artifactId>agent-ds</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
<sys:dependency>
<sys:groupId>org.apache.geronimo.configs</sys:groupId>
<sys:artifactId>tomcat6</sys:artifactId>
<sys:version>2.1.1</sys:version>
<sys:type>car</sys:type>
</sys:dependency>
</sys:dependencies>
</sys:environment>
<!-- Begin configuration for Container Managed Persistence (CMP) -->
<naming:cmp-connection-factory>
<naming:pattern>
<naming:groupId>resourcelocator-pattern-groupid</naming:groupId>
<naming:artifactId>resourcelocator-pattern-artifactid</naming:artifactId>
<naming:version>resourcelocator-pattern-version</naming:version>
<naming:module>resourcelocator-pattern-module</naming:module>
<naming:name>resourcelocator-pattern-name</naming:name>
</naming:pattern>
<naming:resource-link>resourcelocator-resourcelink</naming:resource-link>
<naming:url>resourcelocator-url</naming:url>
</naming:cmp-connection-factory>
<ejb-ql-compiler-factory>ejbQlCompilerFactory</ejb-ql-compiler-factory>
<db-syntax-factory>dbSyntaxFactory</db-syntax-factory>
<enforce-foreign-key-constraints/>
<!-- End configuration for Container Managed Persistence (CMP) -->
</openejb-jar>
|
...
The <enterprise-beans> element used to specify references by <entity>, <session>, or <message-driven> EJB's. For example, a EJB Entity Bean would be specified similarly as below in an openejb-jar.xml file:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <entity> Example | borderStyle | solid |
---|
| xml |
---|
|
<enterprise-beans>
<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>
|
A EJB Session Bean would be specified similarly as below in an openejb-jar.xml file:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <session> Example | borderStyle | solid |
---|
| xml |
---|
|
<enterprise-beans>
<session>
<ejb-name>RetrieveEmployeeInfoBean</ejb-name>
<business-remote>examples.session.stateless_dd.RetrieveEmployeeInfo</business-remote>
<ejb-class>examples.session.stateless_dd.RetrieveEmployeeInfoBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<res-ref-name>jdbc/DataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</session>
</enterprise-beans>
|
And an EJB Message-driven Bean would be specified similarly as below in an openejb-jar.xml file:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <message-driven> Example | borderStyle | solid |
---|
| xml |
---|
|
<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>
|
...
The <activation-config> XML element is used to specify any configuration data (in the form of name/value pairs) required by the resource adapter in order to supply messages to the MDB. For example:
Code Block |
---|
| xml |
---|
borderStyle | solid |
---|
title | <activation-config> Example | borderStyle | solid |
---|
| xml |
---|
|
<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>
|