Overview
Have you ever been stumped by a complex business process logic that you couldn't solve with the IBM Sterling B2B Integrator out-of-box services or adapters alone? Take, for example, a simple Universally Unique ID generation, a complex MQRFH2 parser and so on. Unfortunately, you cannot complete this task with only out-of-box services or adapters. In a situation such as this, you can simplify your business process code and solve the problem faster with a Java extension.
As we come across more and more of this kind of scenarios in a day-to-day business process development, the necessity of java becomes more and more obvious. This article provides a glimpse of the various options that are available for a developer/architect to extend business processes with java.
Options
Developers have the following five options to extend business processes - if the out-of-box services or adapters doesn't solve the problem.
1.) Custom Service / Adapter
2.) Java Task Service
3.) User Exits in Map
4.) XSLT Service / Java
5.) CLA2 Adapter / Java
Now, which is the correct option to 
solve the problem?
1.) Custom Service / Adapter
MESA Developer Studio Software Development Kit (SDK) provides the tightest integration with Sterling B2B Integrator and enables you to create complex and complete services and adapters. These services use the same APIs as the services included with Sterling B2B Integrator, so all of the benefits and infrastructure of Sterling B2B Integrator are available. This flexibility and tight integration means that creating a service is more advanced and requires good knowledge of Java development, Sterling B2B Integrator APIs, and the APIs of any system that will be accessed by the service.
The MESA Developer Studio SDK helps you create and edit custom services and adapters using the Eclipse development environment. The MESA Developer Studio SDK is designed as an Eclipse plug-in and is installed locally on your computer. Use the SDK to create a service, build and export a service package within the Eclipse development environment, then install and test it with IBM Sterling B2B Integrator.
Pros:
- No known performance issues if the custom service / adapters is coded optimally.
- Runtime custom service / adapter is free from accidental code changes.
- No need of any additional skills apart from IBM Sterling B2B Integrator and Java.
- Can play-around with process data values.
Cons:
- Long development / deployment / testing cycle times.
- SBI application should be restarted for every code deployment / change.
- Need to code using an external editor like eclipse.
2.) Java Task Service
The Java Task service executes java code in Sterling B2B Integrator. It eliminates the need to create a custom service.
To execute the source code place import statements at the top followed by any set of standard java code you want to call. There are two classes automatically available to you, one called wfc (which is an instance of the workflow context of the current process), and one called log (which is an instance of the XLogger). There must be a return of a string included in the code fragment. This string will go to the log.
Pros:
- Easy to invoke java code
- Can code using any editor(service configuration parameters in GPM or any text editors).
- Short development / deployment / testing cycle times.
- No need to restart application for any kind of deployments.
- No need of any additional skills apart from IBM Sterling B2B Integrator and Java.
- Can play-around with process data values.
Cons:
- Compiles whenever it runs.
- Code is not free from accidental code changes as the deployed code is a .java source file rather than .class files.
- No automated scripts to deploy the code if the srcLocationMode is File. The java source(.java) should be placed on the file system.
3.) User Exits in Map
User exits perform functions that the translator does not perform during typical translation. For example, user exits can:
- Access a database table to perform cross-references or lookups.
- Perform complex pricing calculations that enable different prices to be calculated for multiple customers, where the seller is located, or where the product is sold.
User exits are extended rules that enable Java objects to be created and accessed. With user exits you can create custom Java classes or use third-party Java classes. User exits can create objects, access properties, or start methods.
Note: Extended rules cannot compare property or method results because property and method types are unknown prior to compilation. Also, extended rules cannot catch Java exceptions and Java methods called by extended rules cannot throw exceptions. To handle an exception, you must create a user exit containing a wrapper class that calls the real class and handles the exception.
Pros:
- Development can be done using the out-of-box Map Editor.
- Can access process data values.
Cons:
- The Map Editor does not inspect Java classes to verify the correctness of method and property names during map compilation.
- The java class needs a constructor with a string argument.
- Application restart might be required if the rules depends on the third party jar files.
- Long development / deployment / testing cycle times if the rules depends on the third party jar files.
- Requires additional mapping skills apart from Java.
4.) XSLT Service / Java
XSLT Service enables you to use XSLT style sheets in IBM Sterling B2B Integrator. In today's world - most XSLT processors written in Java also let you go the other way, integrating Java code with XSLT stylesheets.
For example, although you can do complicated string searching and replacing in XSLT, but it will be about a thousand times easier in Java, especially with a good regular expression library. Same as the case with mathematical functions like factorial and fibonacci. XSLT optimizers are not nearly as mature or as reliable as Java optimizers, and those that do exist mostly focus on optimizing XPath search and evaluation on node-sets rather than mathematical operations on numbers.
So, most of the logic can be easily written by using the power of java along with XSLT in IBM Sterling B2B Integrator though XSLT by itself doesn't provide all the required functionality.
Pros:
- Can play-around with process data easily.
- Very useful when there is a need to invoke simple static / instance methods.
Cons:
- Long development / deployment / testing cycle times if the rules depends on the external jar files.
- Requires additional XSLT skills apart from Java / IBM Sterling B2B Integrator.
- Application restart might be required if the logic depends on the third party jar files.
- Due to the nature of XSLT processing in IBM Sterling B2B Integrator there could be a possibility of performance issues.
5.) CLA2 Adapter / Java
The CLA2 / Command Line Adapter 2 is a second generation adapter that enables Sterling B2B Integrator to run a program from a command line in a business process.
The Command Line Adapter 2 operates in a remote implementation only. This does not necessarily mean that it has to run remotely. It runs in a separate JVM (Java Virtual Machine), which may be on the machine where Sterling B2B Integrator is installed or on a remote machine.
This option is considered to be a loosely coupled option - as the java code executed using CLA2 adapter can't access process data except document.
Pros:
- Java code runs in a separate JVM by providing better performance.
- Can develop and unit test using external editors like eclipse.
- Short development / deployment / unit testing cycle times.
- Runtime code is free from accidental code changes as the deployed code is a class file.
Cons:
- Java code can't retrieve values from the ProcessData / Instance Data area.
- Java code can't pass values to the ProcessData / Instance Data area.
- No automated tools to deploy the code.
Summary
More the options - more the headache but, here all the options carry equal weight-age depending on the type of the requirement. So, the developer / technical architect should take a decision considering the nature of the problem to be solved, and the overall performance impact.

References
1.) Custom Service / Adapter: http://pic.dhe.ibm.com/infocenter/sb2bi/v5r2/index.jsp?topic=%2Fcom.ibm.help.mesa_studio.doc%2FSI_MESACreateCustomServices.html
2.) Java Task Service: http://pic.dhe.ibm.com/infocenter/sb2bi/v5r2/index.jsp?topic=%2Fcom.ibm.help.svcs_adpts_a_l.doc%2FJava_Task_svc.html
3.) User Exits: http://pic.dhe.ibm.com/infocenter/sb2bi/v5r2/index.jsp?topic=%2Fcom.ibm.help.stds804_map_editor.doc%2Fr_STDS_ME_UserExits.html
4.) XSLT Service:
http://pic.dhe.ibm.com/infocenter/sb2bi/v5r2/topic/com.ibm.help.svcs_adpts_m_z.doc/XSLT_svc.html
http://xml.apache.org/xalan-j/extensions.html
5.) CLA2 Adapter:
http://pic.dhe.ibm.com/infocenter/sb2bi/v5r2/index.jsp?topic=%2Fcom.ibm.help.svcs_adpts_a_l.doc%2FCommand_Line_adapter_2.html
Disclaimer:
Please do not cite, circulate, or copy without permission of the author. The views expressed are solely my own and do not express the views or opinions of my employer. I shall not be accountable for and does not accept any liability or responsibility whatsoever for any inaccuracies, omissions, errors, misleading information, loss or damage howsoever arising (including without limitation, incidental, punitive, exemplary, special or consequential damages, loss of profit or damages resulting from lost data or business interruption), be it by negligence or otherwise, or expense resulting from:-
- Using the information and contents of this article whether with or without authorization;
- Relying on the information and contents of this article, whether downloaded or not;
- The performance, operation, functionality, non performance, unavailability, inaccessibility, or corruption of this article;
- Communicating with us or transmitting instructions to us over the internet via this website.