How to Define the SDO Types with an Enterprise JavaBeans Bean
An Enterprise JavaBeans bean must define the SDO types. The example that follows provides details.
Caution:
Where to call define
can be nontrivial. You must force the types to be defined before remote method invocation (RMI) marshalling must occur and in the right helper context. The EclipseLink SDO implementation indexes the helper instance with the application name or class loader.
When you invoke the Enterprise JavaBeans method, an application name is available to the EclipseLink SDO runtime. The EclipseLink SDO looks up the context using the application name as the key. Ensure that the types are defined when the application name is visible. When an Enterprise JavaBeans static block is initialized, the application name is not created. Therefore, putting the define
in the static block does not work if you are using the default application name-based context. One way to get the application name initialized is to allocate more than two instance beans using the weblogic-ejb-jar.xml
file.
InputStreamReader reader = new InputStreamReader(url.openStream());
StreamSource source = new StreamSource(reader);
List<SDOType> list = ((SDOXSDHelper) XSDHelper.INSTANCE).define(source, null);
The weblogic-ejb-jar.xml
file is the descriptor file that must be added in the deployment jar. The weblogic-ejb-jar.xml
file is automatically created when you create a session bean. This file must be modified by adding the entries shown in the following example:
<?xml version = '1.0' encoding = 'windows-1252'?> <weblogic-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd" xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar"> <weblogic-enterprise-bean> <ejb-name>HelloEJB</ejb-name> <stateless-session-descriptor> <pool> <initial-beans-in-free-pool>2</initial-beans-in-free-pool> </pool> </stateless-session-descriptor> </weblogic-enterprise-bean> </weblogic-ejb-jar>
Figure 38-2 provides a code example of a session bean with SDO logic defined.
Figure 38-2 Session Bean with Defined SDO Logic

Description of "Figure 38-2 Session Bean with Defined SDO Logic"