BEA Logo BEA WebLogic Java Adapter for Mainframe Release 4.2

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   JAM Documentation   |   JAM Programming Guide   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Generating a Server Enterprise Java Bean-based Application

 

This type of application produces Java classes that comprise an EJB application, similar to a Client EJB application, but acting as a remote server from the viewpoint of the mainframe. The classes process service requests originating from the mainframe (remote) system, known as "inbound" requests, and transfer data records to and from the mainframe. From the viewpoint of the Java classes, they receive EJB method requests. From the viewpoint of the mainframe application, it invokes remote DPL or IMS programs.

 


Action List

Before you build a Server Enterprise Java Bean-based application, see the following action list and refer to the appropriate information sources.

 

Your action...

Refer to...

1

Complete all prerequisite tasks.

Prerequisites

2

Review the general steps for building a Java application

Generating a Java Application with the eGen COBOL Code Generator

3

Review an example of a script for generating a server EJB application

Components of an eGen COBOL Server EJB Script

4

Review script processing and sample script commands

Processing the Script

5

Review the generated files

Working with Generated Files

6

Customize the application

Customizing a Server Enterprise Java Bean-Based Application

7

Proceed to the next set of instructions.

What Do I Do Next?


 

 


Prerequisites

Before you start programming your Server Enterprise Java Bean-based application, you should complete the following tasks:

 

Your action...

Refer to...

1

Install your computer systems, Windows/UNIX and mainframe, to meet your requirements.

BEA WebLogic Java Adapter for Mainframe Installation Guide

2

Configure your computer systems, Windows/UNIX and mainframe, to meet your requirements.

BEA WebLogic Java Adapter for Mainframe Configuration and Administration Guide


 

 


Components of an eGen COBOL Server EJB Script

The following listing shows the contents of a complete script for defining a server EJB application.

Listing 4-1 Sample Server EJB Script

1  #--------------------------------------------------------
2 # empserver.egen
3 # JAM script for an employee record.
4 #
5 # $Id: empserver.egen, v 1.1 2000/01/21 23:20:40
6 #-------------------------------------------------------------
7
8 # DataViews (typed data records)
9
10 view sample.EmployeeRecord (Comment 1)
11 from emprec.cpy
12
13 # Clients and servers (Comment 2)
14
15 server ejb sample.SampleServer my.sampleServer (Comment 3)
16 {
17 method newEmployee (EmployeeRecord)(Comment 4)
18 returns EmployeeRecord
19 }
20
21 # End

Table 4-1 refers to the numbered comments in Listing 4-1.

Table 4-1 Script Comments

Comment 1

Defines a DataView class, specifying its corresponding copybook source file and its package name.

Comment 2

Defines a server EJB class.

Comment 3

my.sampleServer is the home interface identifier for this bean. This value must be included in an entry in the local Services section of the jcrmgw.cfg file for the Java gateway.

Comment 4

Defines a server class method and its parameter.

 


Processing the Script

Issue the following command to process the script.

Listing 4-2 Sample Script Process Command

egencobol empserver.egen
emprec.cpy, Lines: 21, Errors: 0, Warnings: 0
Generating sample.EmployeeRecord...
Generating group emp-name
Generating group emp-addr
Generating SampleServer...

 


Working with Generated Files

The empserver.egen script command generates the following files.

Table 4-2 Sample Script Generated Files

File

Content

SampleServer.java

Source for the EJB remote interface.

SampleServerBean.java

Source for the EJB implementation.

SampleServerHome.java

Source for the EJB home interface.

EmployeeRecord.java

Source for the DataView object.

SampleServer-jar.xml

Sample deployment descriptor

wl-SampleServer-jar.xml

Sample WebLogic deployment information

SampleServer.java Source File

The following listing shows the content of the generated SampleServer.java source file.

Listing 4-3 Sample SampleServer.java Contents

// SampleServer.java
//
// EJB Remote Interface generated by eGenCobol on 24-Jan-2000.
package sample;
// Imports
import javax.ejb.EJBObject;
...
/** Remote Interface for SampleServer EJB. */
public interface SampleServer
extends gwObject
{
//dispatch
byte[] dispatch(byte[] commarea, Object future)
throws RemoteException, UnexpectedException;
}
// End SampleServer.java

SampleServerBean.java Source File

The following listing shows the contents of the generated SampleServerBean.java source file.

Listing 4-4 Sample SampleServerBean.java Contents

// SampleServerBean.java
//
EJB generated by eGenCobol on 24-Jan-2000.
package Sample;
// Imports
import com.bea.jam.egen.EgenServerBean;
...
/** EJB implementation. */
public class SampleServerBean
extends EgenServerBean
{
// dispatch
public byte[] dispatch (byte[] commarea, Object future)
throws IOException
{
...
}
	/**
* Do the actual work for a newEmployee operation.
* NOTE: This routine should be overridden to do actual work
*/
EmployeeRecord newEmployee (EmployeeRecord commarea)
{
return new EmployeeRecord();
}
}
//End SampleServerBean.java

SampleServerHome.java Source File

The following listing shows the contents of the generated SampleServerHome.java source file.

Listing 4-5 Sample SampleServerHome.java Contents

// SampleServerHome.java
//
// EJB Home interface generated by eGenCobol on 24-Jan-2000.
package Sample;
//Imports
import javax.ejb.EJBHome;
...
/** Home interface for SampleServer EJB. */
public interface SampleServerHome
extends EJBHome
{
//create
SampleServer create()
throws CreateException, RemoteException;
}
// End SampleServerHome.java

SampleServer-jar.xml Source File

The following listing shows the contents of the generated SampleServer-jar.xml deployment descriptor file.

Listing 4-6 Sample SampleServer-jar.xml Contents

<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN''http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>SampleServer</ejb-name>
<home>sample.SampleServerHome</home>
<remote>sample.SampleServer</remote>
<ejb-class>sample.SampleServerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>SampleServer</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

wl-SampleServer-jar.xml Source File

The following listing shows the contents of the generated wl-SampleServer-jar.xml source file. To use this file, copy it to weblogic-ejb-jar.xml

Listing 4-7 Sample wl-SampleServer-jar.xml Contents

<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN' 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>SampleServer</ejb-name>
<caching-descriptor>
<max-beans-in-free-pool>50</max-beans-in-free-pool>
</caching-descriptor>
<jndi-name>my.sampleBean</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>Script Comments

 


Customizing a Server Enterprise Java Bean-Based Application

The generated server enterprise Java bean-based applications are only intended for customizing, since they perform no real work without customization.

This section describes the way that generated server EJB code can be customized.

The following figure illustrates the relationships and inheritance hierarchy between the JAM classes comprising the application.

Figure 4-1 The JAM Server EJB Class Hierarchy


 

The generated Java code for a client EJB application is a class that inherits class EgenServerBean. The EgenServerBean class is provided in the JAM distribution jar file. This base class, illustrated in the following listing, provides the basic framework for an EJB. It provides the required methods for a Stateless Session EJB.

Listing 4-8 EgenServerBean.java Base Class

//==========================================================
// EgenServerBean.java
// The base class for generated server EJB's.
//
//===============================================================
package com.bea.jam.egen;
abstract public class EgenServerBean
implements SessionBean
{
// Implementation of ejbActivate(), ejbRemove(),
// ejbPassivate(),
// setSessionContext() and ejbCreate().
...
	// Variables
	protected transient SessionContext m_context;
protected transient Properties m_properties;
}
// End EgenServerBean.java

The generated class, illustrated in the following listing, adds the methods specific to this EJB.

Listing 4-9 Generated SampleServerBean.java Class

// SampleServerBean.java
//
// EJB generated by eGenCobol on 03-Feb-00.
//
package Sample;
//Imports
//
import java.io.IOException;
import java.util.Hashtable;
import com.bea.sna.jcrmgw.snaException;
import com.bea.base.io.MainframeWriter
import com.bea.base.io.MainframeReader;
import com.bea.jam.egen.EgenServerBean;
import com.bea.jam.egen.InboundDispatcher;
/**
* EJB implementation
*/
public class SampleServerBean extends EgenServerBean
{
// dispatch
//
public byte[] dispatch(byte[] commarea, Object future)
throws IOException
{
EmployeeRecord inputBuffer
= new EmployeeRecord (new
MainframeReader (commarea));
EmployeeRecord result = newEmployee (inputBuffer);;
return result.toByteArray (new MainframeWriter());
}
   /**
* Do the actual work for a newEmployee operation.
* NOTE: This routine should be overridden to do actual work
*/
EmployeeRecord newEmployee(EmployeeRecord commarea)
{
return new EmployeeRecord();
}
}
// END SampleServerBean.java

The following listing shows an example ExtSampleServerBean class that extends the generated SampleServerBean class, providing an implementation of the newEmployee() method. The example method prints a message indicating that a newEmployee request has been received.

Listing 4-10 Sample ExtSampleServerBean.java Contents

// ExtSampleServerBean.java
//
package sample;
/**
* EJB implementation
*/
public class ExtSampleServerBean extends SampleServerBean
{
public EmployeeRecord newEmployee (EmployeeRecord in)
{
System.out.println("New Employee: " +
+in.getEmpRecord()in.getEmpName().getEmpNameFirst()
+ " "
+ in.getEmpRecord().getEmpname().getEmpNameLast());
return in;
}
}
// END ExtSampleServerBean.java

Once it has been written, the ExtSampleServerBean class and the other EJB Java source files must be compiled and deployed in the same manner as other EJBs. Before deploying, the deployment descriptor must be modified; the ejb-class must be set to the name of your extended EJB implementation class.

 


Compiling and Deploying

Refer to the BEA WebLogic server documentation for more information. The sample file provided with WebLogic Server contains a build script for reference.

 


What Do I Do Next?

Refer to BEA Java Adapter for Mainframe Scenarios for detailed examples of some of the application models discussed in this guide.

 

back to top previous page next page