Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 2 Tutorial : Advice Development in Eclipse

Advice Development in Eclipse
Setting up Eclipse for TIBCO ActiveMatrix BusinessWorks ActiveAspects Plug-in Development
To setup Eclipse for the TIBCO ActiveMatrix BusinessWorks ActiveAspects Plug-in development do the following:
1.
2.
Click Add External JARs to add all the required JARs contained in the installation to the build path and click Finish.
poa-samplesImpl.jar and poa-bwaa-samplesImpl-src.jar
3.
To attach the source to the samplesImpl.jar, right-click on the JAR in the Referenced Libraries in the Eclipse Project Explorer and select properties. In the Java Source Attachment, select External File and browse to samplesImpl-src.jar.
This will attach the source code to the JAVA classes.
Figure 1 Jars and Class Folders on the Build Path
4.
To attach the source to the samplesImpl.jar, right-click on the JAR in the Referenced Libraries in the Eclipse Project Explorer and select properties. In the JAVA Source Attachment, select External File and browse to samplesImpl-src.jar.
This will attach the source code to the JAVA classes.
Creating a Synchronous Advice Implementation
To create a synchronous advice implementation, you have to extend the SyncAdvice class.
1.
2.
Package - com.bwaa.tutorial
Name - JMSDocumentLogger
3.
Extend the SyncAdvice (for Sync Advice Implementations) class with the required generics.
4.
Annotate the class with @AdviceImpl.
Figure 2 Creating a Synchronous Advice Implementation
Exporting the Advice Implementation JAR file using Eclipse
To export the advice implementation JAR file, do the following:
1.
Right-click on the project (in this case com.bwaa.tutorial) and select Java > JAR File.
Make sure that Export generated classfiles and resources check box is selected.
2.
Click Browse in the JAR file field and select the export destination. For example, C:\tibco_bwaa\bw\plugins\bwaa\lib\bwaaTutorialAdviceImpl.jar.
The export destination must be in the classpath of BWAA. The recommended export location is $TIBCO_HOME\bw\plugins\bwaa\lib.
3.
Click Finish.
To run the scenario, you must copy the aspect.jar (in this case, JMSLoggerAspect.jar) file in the bw\plugins\bwaa\aspects folder.
Creating a New Aspect File
Create a new aspect file similar to the following XML snippet.
It may change as per your requirement.
<?xml version = "1.0" encoding = "UTF-8"?>
<aspect order="1" targetNamespace = "http://example.org/Eight" xmlns = "http://schemas.tibco.com/bw/poa" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://schemas.tibco.com/bw/poa BWAspect.xsd">
<pointcut name = "JMSActivities">
<query queryLanguage = "http://schemas.tibco.com/bw/poa/pointCutSelectionLanguage">activity (name = "JMS*")</query>
</pointcut>
<advice name = "JMSLoggerAdvice" pointcut = "JMSActivities">
<documentation>Document Logger for JMS activities</documentation>
<activity where = "After">
<implementation.java className = "com.bwaa.tutorial.JMSDocumentLogger"/>
</activity>
</advice>
</aspect>
Now validate this XML against the bwaspect.xsd file.
Creating an Aspect JAR
Create an aspect JAR with the following structure:
Figure 3 Aspect JAR Structure
To run the scenario, you must copy the aspect.jar (in this case, JMSLoggerAspect.jar) file in the bw\plugins\bwaa\aspects folder.
Using TIBCO Designer with TIBCO ActiveMatrix BusinessWorks ActiveAspects Plug-in
The following steps provide the detailed information about using TIBCO Designer with this example.
1.
Open $TIBCO-HOME\Designer\5.7\bin\designer.tra and append the aspect lib folder to the property tibco.env.CUSTOM_CP_EXT. The default aspect lib folder is $TIBCO-HOME\bw\plugins\bwaa\lib.
2.
Create a properties file, for example, C:\test\props.cfg, and add the following properties to it:
(Replace the value of the aspectPath property with the appropriate value based on your environment)
3.
4.
Go to the Tester tab, click the Start button to start debugging your project and then click the Advanced button to launch the advanced configuration. In the Test Engine User Args field, introduce the following:
-p C:\test\props.cfg
(Replace the path with the appropriate one based on where you saved the properties file that was created at step #2)
5.
6.
At this point, the engine should also execute the aspects that are available in aspectPath. Ensure that all advice implementations as well as their dependent JARs are available in the classpath.
Expected Final Output
The final output should be as follows:
 
----------[ADVICE EXECUTING: Document Logger]----------
The document received by the advice is :
<?xml version="1.0" encoding="UTF-8"?>
<jms1:aEmptyOutputClass xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
<jms1:MessageID>ID:EMS-SERVER-HGAWANDE.E684E896BACAD:12</jms1:MessageID>
</jms1:aEmptyOutputClass>
----------[ADVICE EXECUTION DONE: Document Logger]----------
----------[ADVICE EXECUTING: Document Logger]----------
The document received by the advice is :
<?xml version="1.0" encoding="UTF-8"?>
<jms1:ActivityOutput xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
<JMSHeaders>
<jms1:JMSDestination>sample</jms1:JMSDestination>
<jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
<jms1:JMSMessageID>ID:EMS-SERVER-HGAWANDE.E684E896BACAD:12</jms1:JMSMessageID>
<jms1:JMSTimestamp>1317806706130</jms1:JMSTimestamp>
<jms1:JMSExpiration>0</jms1:JMSExpiration>
<jms1:JMSRedelivered>false</jms1:JMSRedelivered>
<jms1:JMSPriority>4</jms1:JMSPriority>
</JMSHeaders>
<JMSProperties/>
<Body>HelloWorld</Body>
</jms1:ActivityOutput>
----------[ADVICE EXECUTION DONE: Document Logger]----------

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved