Java Custom Function inside TIBCO BusinessWorks 5.x

In one of the last posts I talked about how to introduce JMS Selector inside our TIBCO BW application and to do that in our example, which do a little comprobation of the JMSTimestamp value we have to create a Java Custom Function to make it work, but what is the scope and the goal of using Java Custom Function? Ok, we are going to answer this question for you.

Why I need to use a Java Custom Function?

If you leave in an ideal world when you can survive with the basic function catalog the TIBCO BusinessWorks 5.x versions have been provided to you, you are a very happy and lucky person but that is not the world when we all live some of the times. So, in different times you have the need to increase the functionality the product is given to you. And it is in some of this situations when you have to take a look of Java Custom Function to reach your goal.

Posibilities to increase the functionality the product gives you

Java Custom Function is a posiblity to increase the functionality you have when you are inside a BW process but it is not the one or the most usted. You have different ways to reach that goal as you can see here.

The most used technique to use that it is to introduce a Java Code BW Activity when you introduce the Java source code you want to a method from a JAR you already have and that’s it!

In fact, the behaviour and the steps to get it working using one option and another are similar. So, what’s the difference? How I know if I have to use a Java Code activity or a Java Custom Function? Ok, the main different is the scope.

Java Code vs Java Custom Function

As I already said you could add an BW activity to introduce the source code I want to increase the posibilities of the product OOTB. And that’s the important fact we have to add an activity but when we use a Java Custom Function we are not adding any activity because the Java Custom Function have a different scope.

Java Custom Function gives you the posiblity to increase the function catalog you can use inside a BusinessWorks Mapping situation. and that’s the reason because I used that option in the other post because a want a new mapper function I didn’t have.

Creating and Deploying a Java Custom Function

First of all If you want to introduce a Java Custom Function inside your project you need the Java source code you want to introduce. So you need a class file or a JAR file (we are going to go with the class file option to be quicker) with the logic you want to use. But you have to keep in mind these conditions about your Java code:

  • The logic must be encapsulated inside an static method
  • You have to use primitives types as arguments.

Ok, so when we have the compiled class according to this limitation you could introduce inside your BW project and to do that you need the following steps:

  • Create a “Java Custom Function” project actifact where you are going to specify the .class file full-path location and the prefix that are going to be used in the Mapper catalog.

JavaCustomFunction_1

  • Click the the “Load Button” to apply the changes.

JavaCustomFunction_2

Now you should get the new catalog function available to use in any mapping instance.

JavaCustomFunction_3

To check a real scenario, you should take a look to the JMS Selector project we disccused time ago. Please, folow the link: Source code

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s