...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8" ?> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"> <description>Stateless Session Bean Example</description> <display-name>Stateless Session Bean Example</display-name> <enterprise-beans> <session> <ejb-name>RetrieveOrderInfoBean</ejb-name> <business-local> examples.session.stateless_dd.RetrieveOrderInfo </business-local> <ejb-class> examples.session.stateless_dd.RetrieveOrderInfoBean </ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> <resource-ref> <res-ref-name>jdbc/DB2DataSource</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> <interceptors> <interceptor> <interceptor-class> examples.session.stateless_dd.RetrieveOrderCallbacks </interceptor-class> <post-construct> <lifecycle-callback-method>construct</lifecycle-callback-method> </post-construct> <pre-destroy> <lifecycle-callback-method>destroy</lifecycle-callback-method> </pre-destroy> </interceptor> </interceptors> <assembly-descriptor> <interceptor-binding> <ejb-name>RetrieveOrderInfoBean</ejb-name> <interceptor-class> examples.session.stateless_dd.RetrieveOrderCallbacks </interceptor-class> </interceptor-binding> </assembly-descriptor> </ejb-jar> |
Note |
---|
The default namespace of the above XML document is |
In the RetrieveOrderInfoBean
, the following code is used to look up the Datasource object and obtain a database connection.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>OrderWEB</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <description></description> <display-name>RetrieveOrder</display-name> <servlet-name>RetrieveOrder</servlet-name> <servlet-class> examples.web.servlet.RetrieveOrder </servlet-class> </servlet> <ejb-local-ref> <ejb-ref-name>ejb/RetrieveOrderInfo</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local> examples.session.stateless_dd.RetrieveOrderInfo </local> <ejb-link>RetrieveOrderInfoBean</ejb-link> </ejb-local-ref> <servlet-mapping> <servlet-name>RetrieveOrder</servlet-name> <url-pattern>/RetrieveOrder</url-pattern> </servlet-mapping> </web-app> |
Note |
---|
The default namespace of the above XML document is |
In the RetrieveOrder
servlet, the following code is used to look up the ejb to retrieve the order details.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?> <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/j2ee/application_5.xsd" version="5"> <description>EAR Example</description> <display-name>Order Sample</display-name> <module> <web> <web-uri>OrderWEB.war</web-uri> <context-root>/OrderDemo</context-root> </web> </module> <module> <ejb>OrderEJB.jar</ejb> </module> </application> /application> |
Note |
---|
The default namespace of the above XML document is |
The deployment plan of the Order.ear
is as follows.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2" application-name="Order"> <sys:environment> <sys:moduleId> <sys:groupId>Order</sys:groupId> <sys:artifactId>OrderEAR</sys:artifactId> <sys:version>5.0</sys:version> <sys:type>car</sys:type> </sys:moduleId> </sys:environment> <module> <web>OrderWEB.war</web> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" > <sys:environment> <sys:moduleId> <sys:groupId>Order</sys:groupId> <sys:artifactId>OrderWEB</sys:artifactId> <sys:version>2.5</sys:version> <sys:type>war</sys:type> </sys:moduleId> </sys:environment> <context-root>/OrderDemo</context-root> </web-app> </module> <module> <ejb>OrderEJB.jar</ejb> <openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"> <sys:environment> <sys:moduleId> <sys:groupId>Order</sys:groupId> <sys:artifactId>OrderEJB</sys:artifactId> <sys:version>3.0</sys:version> <sys:type>jar</sys:type> </sys:moduleId> <sys:dependencies> <sys:dependency> <sys:groupId>console.dbpool</sys:groupId> <sys:artifactId>OrderDS</sys:artifactId> <sys:version>1.0</sys:version> <sys:type>rar</sys:type> </sys:dependency> </sys:dependencies> </sys:environment> <enterprise-beans> <session> <ejb-name>RetrieveOrderInfoBean</ejb-name> <naming:resource-ref> <naming:ref-name>jdbc/DB2DataSource</naming:ref-name> <naming:resource-link>OrderDS</naming:resource-link> </naming:resource-ref> </session> </enterprise-beans> </openejb-jar> </module> </application> |
Note |
---|
The default namespace of the above XML document is |
Observe how the JEE 5 resource names and ejb names in ejb-jar.xml
and web.xml
are mapped to actual resources deployed in the server through geronimo-application.xml
.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?> <application-client xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application-client_5.xsd" version="5"> <ejb-ref> <ejb-ref-name>ejb/Converter</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <remote>examples.appclient.Converter</remote> </ejb-ref> </application-client> |
Note |
---|
The default namespace of the above XML document is |
The application client declares the ejb name ejb/Converter
through <ejb-ref>>
.. </ejb-ref>
elements.
...
Note |
---|
The default namespace of the above XML document is |
...