Use
these instructions to associate Java™ code
with your JavaCompute node.
Before you start
To complete
this task, you must have already created a JavaCompute node in your message flow.
To associate Java code with a JavaCompute node, use one of
the following methods:
- Use the New Java Compute Node Class wizard
to create template code. This is a preferred method.
- Right-click the node and click Open Java.
- Navigate the New Java Compute Node Class wizard
until you reach the Java Compute Node Class Template page.
On the Java Compute Node Class Template page,
choose one of the following options:
- For a filter node template code, select Filtering message
class.
- To change an incoming message, select Modifying message
class.
- To create a new message, select Creating message class.
- To process messages using the JAXB template, select Process
via JAXB class. If you want to use the Generate
JAXB Java object classes wizard to create your JAXB Java object classes, or to update
the template code to reference your existing JAXB Java object classes, click Next.
For more information, see Creating JAXB Java object classes by using a wizard.
- Click Finish.
You have created template code for your JavaCompute node.
- Associate a JavaCompute node
with an existing Java class
that the wizard has previously generated; this is the safest way in
which you can share the same Java code
between multiple nodes. To associate a JavaCompute nodes with an existing Java class, perform the following
steps:
- Right-click the JavaCompute node and click Properties.
- Enter the name of the Java class
in the Java Class field.
- Click OK.
You have associated your JavaCompute node with an existing Java class.
- Create a Java project
from scratch. Before you add one or more classes to the
project, you must perform the following steps:
- Open the .project file in the text
editor, and ensure that the following builders and natures are set:
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.ibm.etools.mft.java.builder.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.ibm.etools.mft.jcn.jcnbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.ibm.etools.mft.bar.barbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.ibm.etools.mft.bar.barnature</nature>
<nature>com.ibm.etools.mft.jcn.jcnnature</nature>
</natures>
- Add the following plug-ins to the build path of the Java project:
- Open the properties of the Java project.
- Select Java Build Path and open the Libraries tab.
- Click Add Variable.
- Select the variable JCN_HOME and click OK.
- Double-click the variable you added to open the Edit
Variable Entry dialog.
- Click Extension and select javacompute.jar.
- Repeat the previous four steps to add the variable JCN_HOME/jplugin2.jar.
- Create the appropriate Java class
and ensure that it extends from com.ibm.broker.javacompute.MbJavaComputeNode.
You have created your Java project.
You
can now perform the following tasks: