|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 4 of 6
Context context = new InitialContext();
JavaWorld javaWorld = (JavaWorld)context.lookup("ejb/JavaWorld");
For WebLogic server, you must use:
Context context = new InitialContext();
JavaWorld javaWorld =
(JavaWorld)context.lookup("ejb/JavaWorld#datamodel.logic.JavaWorld");
In the last line of this code, the value of the mappedName attribute precedes the #, and the package plus the Java class name of the business interface follows the #. Note that the mappedName attribute is used to refer to resources configured in the entire application server, not just the application. OC4J doesn't
support this attribute.
In general, it's preferable to configure resources in an application server instead of doing all the coding yourself. A Java Message Service (JMS) service is one such resource. JMS is a messaging standard that lets EJB components create, send, receive, and read messages. To configure a JMS provider on a WebLogic server, you must follow a few steps:
Next, add the persistent store, JMS server, and the JMS modules to the config.xml file in the domain-home/config directory. Put the JMS resources into a separate file located in the domain-home/config/jms directory. This file contains the provided JNDI names. If you use OC4J, you must add the JMS resources to the jms.xml file located in the oc4j-home/config directory.
Java EE lets you retrieve configured resources by using resource injection. Suppose you have configured a connection factory and registered it using the JNDI name jms/JavaWorld. With OC4J, you can retrieve this resource by using:
@Resource(name = "jms/JavaWorld")
private ConnectionFactory javaWorld;
On a WebLogic server, resource injection is not supported by itself. If a certain enterprise bean wants to use configured
resources, you must add these resources to the weblogic-ejb-jar.xml file. This file, which defines the beans, can be used to override certain deployment settings. Of course you can still use
a JNDI lookup to retrieve the resource.
If an application is being deployed, you can also create a deployment plan that contains various module-override sections. This example deployment-plan section specifies a number of files in which you can define the overrides:
<weblogic-ejb-jar...>
<weblogic-enterprise-bean>
<ejb-name>JavaWorld</ejb-name>
<enable-call-by-reference>True</enable-call-by-reference>
<jndi-name>ejb/JavaWorld</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
Note that the resources to be used by the enterprise bean can be defined in the deployment plan.