TIBCO ActiveMatrix BusinessWorks ActiveAspects Plug-in extends TIBCO ActiveMatrix BusinessWorks by adding an Aspect Oriented Programming capability. This allows you to enhance your BW processes at deploy time while keeping the original BW process intact.
The plug-in works by providing the developer a JAVA API that can be used to develop and build a custom java application, packaged in a jar file. This jar file can alter the execution of any TIBCO ActiveMatrix BusinessWorks application. Naturally, if used correctly.
Before you can start, you should at least understand what process aspect oriented programming is. The following screenshot, from the TIBCO Documentation, provides a very good explanation.
A Process-Oriented Aspect (POA) alters the execution of a process by injecting Advices, which are user defined code, at specific points of the process called Join Points. The selection of the Join Points is made based on the expressions called Point Cuts.
An Aspect is the collection of Point Cuts and Advices. Aspects implement features that cut across different layers of a BW application (that is, across different BW processes). One of the key characteristics of the POA style programming is that these features can be developed, packaged and deployed independent of TIBCO ActiveMatrix BusinessWorks applications.
Let’s take an example to see how it works. The following business process subscribes on an event, does some transformation and writes it to disk.
You can now use the plug-in to change dynamically the destination file location. In real life, you could execute an external business rule to determine dynamically the file location.
Creating the advice implementation.
After creation of a java project in eclipse (or any other IDE you prefer), you need to add the jar files that are located in the directory $TIBCO_HOMEbwpluginslibpalettes (bwaa-palette.jar, bwconfig-api.jar, bwconfig-impl.jar, gxml.jar, gxmlBridges.jar, gxmlProcessors.jar, poa-api.jar, poa-bwaa.jar, poa-core.jar). You can also add the poa-bwaa-samplesImpl.jar from the examples since it contains a useful GxmlUtil class (also used in all the examples given by Tibco).
The first thing to decide is whether you need an asynchronous advice implementation or not. An asynchronous advice implementation does not execute its business logic on the engine job thread. During this time, the engine can execute other advice pipelines or activities if any of them exist in the same process instance on a parallel track. A synchronous advice implementation does not allow this and ‘blocks’ the execution in the job thread.
The above sample is based on the examples and Java API provided by Tibco.
Once you’ve written the java class, you’ll have to package it into a jar file. Best location to save this jar file would be $TIBCO_HOMEbwpluginsbwaalib because this location will be, by default, included on the classpath of a businessworks engine (bwengine). However if you want to run the aspect in your designer, you’ll need to adjust the tibco.env.CUSTOM_CP_EXT in the designer.tra. You can look in the bwengine.tra for the variable BW_AA_HOME to see how it should be set.
When the advice implementation is made, you’ll have to create an aspect xml file. The aspect file will define your point cuts and which advice implementation should be executed when the point cut is reached. The plug-in defines a query language used for writing point cut expression. The query language defines four basic primitives that can be used (and combined) to narrow down your point cut:
This aspect xml file should be packaged as a jar file (although it’s not a java implementation) and should be put in the location $TIBCO_HOMEbwpluginsbwaaaspects. This is the default location as configured in the bwengine.tra. For testing in the designer, you’ll need to use a custom property file and add the following to it:
The tibco designer project can be downloaded here.
The aspect implementation can be downloaded here.
The aspect configuration xml can be downloaded here.