Hitachi

uCosminexus Application Server Expansion Guide


2.3.9 Implementing a batch application (when accessing EJB)

You can access EJBs of a J2EE application from a batch application. When creating a batch application that accesses EJBs, you can perform lookup of EJBs to be accessed, with the following name and then use EJBs.

When accessing EJB, you prepare the batch application with the following procedure:

  1. Preparing EJB to be accessed from the batch application

    Set up a J2EE application that includes EJB to be accessed from the batch application to the start state.

  2. Implementing the batch application

    In the batch application, you implement the code for using EJB.

  3. Executing the batch application

    You execute the batch application created in step 2.

The following subsections describe the procedure:

Organization of this subsection

(1) Preparing EJB

You prepare a J2EE application, including EJB to be accessed, from a batch application. Also you prepare a J2EE server for executing the J2EE application. For details on how to set up the J2EE servers, see 4.1 System setup for improving machine performance by allocating Web Server to a different host in the uCosminexus Application Server System Setup and Operation Guide.

Start the J2EE application on the J2EE server that is set up. Use the cjgetstubsjar command, and acquire the RMI-IIOP stub and interface of the started J2EE application.

If you perform lookup on an optional name, when accessing EJB from a batch application, you specify an optional name of EJB in advance by using the user-specified namespace functionality. For details on setting the optional names of EJBs, see 2.6 Assigning optional name to Enterprise Bean or J2EE server (user-specified name space functionality) in the uCosminexus Application Server Common Container Functionality Guide.

(2) Implementing batch application

You implement the code for acquiring EJB that is set up in (1) Preparing EJB, in a batch application. The following example shows coding:

String EjbName = EJB-lookup-name;
InitialContext ic = new InitialContext();
Object objref = ic.lookup(EjbName);
Home-interface-class-name home =
   (Home-interface-class-name) PortableRemoteObject.narrow(objref,
                             Home-interface-class-name.class;
EJB-object-class-name ejbobj = home.create();

Prepare home interface and EJB object file in advance. You must include home interface and EJB object in class path when compiling and executing batch applications.

(3) Executing the batch application

When executing a batch application, you specify the stub acquired in (1) Preparing EJB and the interface file used in (2) Implementing batch application with full path, in class path.

You specify URL of Naming Service used to search EJB, as a value of java.naming.provider.url in usrconf.properties (user property file for batch application).

However, when concurrently using the resource connection functionality and the EJB access functionality, use the Naming Service switching functionality and specify Naming Service which performs lookup of EJB. In this case, do not specify java.naming.provider.url in usrconf.properties (user property file for batch application). For details on the Naming Service switching functionality, see 2.10 Switching CORBA Naming Service in the uCosminexus Application Server Common Container Functionality Guide.