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


Chapter 9 TIBCO Adapters and TIBCO Hawk : Creating User-Defined TIBCO Hawk Methods

Creating User-Defined TIBCO Hawk Methods
This section explains how to create TIBCO Hawk microagents for C++ adapters and Java adapters.
Creating TIBCO Hawk Methods in C++
To create a method for a C++ adapter:
1.
Use the TIBCO Designer software to specify information about the method name and method input and output parameters in the adapter instance description object. Select the adapter, then click Edit Adapter XML to define this information. The following association attributes describe TIBCO Hawk methods.
For an example, see TIBCO Designer Palette Reference, available through Help > Designer Help from TIBCO Designer.
2.
In the custom adapters, create a subclass of MHawkMethod and define the appropriate methods, and the destructor. Note that all methods must have been defined in TIBCO Designer for that adapter instance.
The following class is from the testHawk example:
   class Hawk_GetDebugValues : public MHawkMethod
   {
   public:
    Hawk_GetDebugValues( MHawkMicroAgent& refHawkMicroAgent )
     : MHawkMethod( "getDebugValues", refHawkMicroAgent ),
    {}
3.
Implement the MHawkMethod::processMethodInvocation() method in the subclass. For the subclass above, the method is implemented as follows:
   void processMethodInvocation(const MTree& inMTree,
MTree& outMTree) throw(MException)
{
// Ignore the mtree passed.
int level = m_pTestHawkDebug->getDebugLevel();
Mboolean bStatus = m_pTestHawkDebug->getDebugOnStatus();
MString sMessage = m_pTestHawkDebug->getDebugMessage();
outMTree.append("Level", level);
outMTree.append("On", bStatus?1:0);
outMTree.append("Message", sMessage.c_str());
return;
}
4.
   Hawk_GetDebugValues * pHawkMethod =
                  new Hawk_GetDebugValues(someHawkMicroAgent);
   if ( pHawkMethod != NULL ) {
        pHawkSession->addMethod( pHawkMethod );
Creating TIBCO Hawk Methods in Java
Creating user-defined TIBCO Hawk methods with the Java SDK differs slightly from the process used for the C++ SDK.
To create a method:
1.
Use the TIBCO Designer software to specify information about the method name and method input and output parameters in the adapter instance description object. Select the adapter, then click Edit Adapter XML to define this information. The following association attributes describe TIBCO Hawk methods.
For an example, see TIBCO Designer Palette Reference, available through Help > Designer Help from TIBCO Designer.
2.
In the Java adapter application, create an object and the method you want to have invoked from TIBCO Hawk. The method must match a method defined in the adapter instance description object as follows:
3.
Get the MHawkMicroagent instance from the MApp MHawkRegistry and call MHawkMicroagent.setMonitoredObject(), providing the object that contains the method you defined as the argument.
Through introspection, the SDK finds methods at runtime that match those defined in the adapter instance description object and make them available from TIBCO Hawk.
For instructions on how to choose the input and output parameters, see the class description for MHawkMethod in TIBCO Adapter SDK Java API.

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