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


Chapter 5 Advanced Features : Custom Function Callout

Custom Function Callout
TIBCO ActiveMatrix Adapter for Kenan/BP allows you to invoke custom functions.
Integrating the Custom Function with the Adapter
The adapter exposes some interfaces which can be extended to generate the required custom function. The name and the prototype of the custom function are decided beforehand by the adapter. The content of the function however is user specific.
When a request comes to the adapter, it validates whether it is a custom request. If it is a custom request, the name of the class which contains the custom function is extracted from the incoming request. The adapter then invokes the custom function which is part of the class specified in the incoming request.
Using Custom Function Callout
To use Custom Function Callout, follow these steps:
1.
Configure a custom request XSD (XML Schema Definition). This can customize this schema as required. However two essential prerequisites for the same are:
The root element for the XSD would be CustomRequest. In the request XSD provided with the Kenan API installation, the same element is Request. All the XSD sequences and the complex application types should be contained in a tag <xs:element name = "CustomRequest">.
There should be an XSD block containing an attribute CustomFunctionName. The xsd should contain a block like this:
<xs:element name = "CustomFunctionName">
<xs:complexType>
<xs:simpleContent>
<xs:extension base = "xs:string">
<xs:attribute name = "e-dtype" fixed = "string" type = "xs:string"/>
   </xs:extension>
  </xs:simpleContent>
  </xs:complexType>
  </xs:element>
2.
You can extend the interface provided by the adapter. TheTIBCO ActiveMatrix Adapter for Kenan/BP exposes two interfaces for executing custom function callout, which are KenanMessageHandler and KenanMessageHandlerFactory. There are two methods for consideration, both of which are exposed by the adapter:
processMessage() - This method incorporates custom function logic and is completely dependent on user requirements. This method is found in the KenanMessageHandler interface. The method accepts a DOM document and an XMLConnection object as input and returns a DOM document to the adapter.
getMessageHandler() - This method creates an object for handling the custom function callout operation. This method is found in the KenanMessageHandlerFactory interface. You have the flexibility to create a message handler either on every message or on every thread based on the incoming custom function handler name. This function returns a KenanMessageHandler class object. This method needs to be synchronized to make it thread safe.
3.
Compile the source code for the custom class. Once the source code for the custom function has been generated, it has to be compiled to generate the custom class. A sample compilation script is provided with the adapter installation in $TIBCO_HOME/adapter/adkenan/version_num/examples/KenanCustomCallout/CustomClasses.
The compiled class has to be placed in the classpath so that the adapter can find it while running. The location of the custom classes is already a part of the CUSTOM_CP_EXT path in the adapter properties file.
4.
Specify the name of the factory class in the adapter property file. The adkenan.KenanCustomCallOutFactoryName property should be uncommented and the Custom Factory class name should be provided. For example, set KenanCustomFactory to the adkenan.KenanCustomCallOutFactoryName property.
5.
Use an external application like TIBCO ActiveMatrix BusinessWorks to configure a custom request for the adapter after the related adapter configuration is done.
To do this, parse the custom request schema as explained in step 1. This is similar to the configuration of a single API request.
Once the custom request reaches the adapter, it forwards the request data to the custom class. The custom class returns a DOM document as the response to the request. On receiving the response, the adapter serializes it and sends it as a reply.
Refer to the Custom Callout Example in TIBCO ActiveMatrix Adapter for Kenan/BP Examples for more information.

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