Steps to build Java External Action Blocks (EAB) in Gen
search cancel

Steps to build Java External Action Blocks (EAB) in Gen

book

Article ID: 27818

calendar_today

Updated On: 08-16-2023

Products

Gen Gen - Workstation Toolset

Issue/Introduction

This document gives an example based on the instructions in the Gen 8.6 doc. section: Gen™ 8.6 > Distributed Processing > Working With Enterprise JavaBeans > External Action Blocks in Java

Environment

Gen 8.6 Java applications

Resolution

Setting up the build directory for the EABs:

1. Create a directory under the sample.ief root directory giving it a name of choice e.g. javaeabs
 
2. Under the new directory create a directory with the short model name. For e.g. javaeabs\sample

(Optional Step) If a Java Package Name has been specified under the Model Generation Properties in the toolset, then instead of the short model name a directory structure should be created according to the Java Package Name. For example:

Based on the above package name the directory javaeabs\com\broadcom should be created.


Customizing the EAB java file

1. Copy and paste all the EAB related java files (e.g. MYEAB*.java) from the sample.ief\java\sample directory into the sample.ief\javaeabs\sample directory.

2. Customize the MYEAB.java file in the javaeabs\sample directory with your own java code under this section:
//    User-written code should be inserted here


Compiling the customized EAB java files

NoteIn order to compile successfully the java EAB files need to reference the Gen runtimes which would need to be in the system classpath or can be referenced in the javac command with a -classpath entry as in the example beloe. The Gen runtimes file which has default name genrt.jar can be easily created by doing an initial Assemble step for the application EAR file without already having the EAB classes included.

Open a Windows Command Windows and change to the javaeabs/sample directory. Enter the following java command to compile the java files:
javac -classpath C:\Users\USERID\Documents\CA\Gen 8.6\Models\sample.ief\java\deploy.j2ee\genrt.jar MYEAB*.java

Executing the above command will produce class files in the javaeabs\sample directory.


Creating the JAR file:

Place all the class files into a jar file which in turn will be included in the assembled application EAR file. From a Windows Command Prompt change directory to sample.ief\javaeabs and execute the following command:
jar -cvf myeabs.jar sample\*.class

That will create a new jar file myeabs.jar in the javaeabs directory containing all the class files from the javaeabs\sample directory.


Deploy the EABs in the EAR during the Assemble step

In the Build Tool EAR File Assemble dialog choose "Additional Files" which opens a File System/Folder options chooser dialog.
For client EABs the myeabs.jar file should go into the <WAR FILE>/WEB-INF/lib folder.
For server EABs the myeabs.jar file should go into the lib folder.
Select the appropriate Additional Files folder and then navigate to the directory holding the myeabs.jar file, select it and click Open.
Then complete the assemble & deployment process