Adapter Development Kit 6.5 | webMethods Adapter Development Kit Documentation | webMethods Adapter Development Kit Installation and User’s Documentation | Listener Notifications | Listener Notification Implementation | Implementing the supports and runNotification Methods
 
Implementing the supports and runNotification Methods
This example implementation of the supports method parses the contents of the data object (originally returned from the listener's waitForData method) into the object variable _parsedValues. Any error in the parsing process indicates that the data object was not a session log entry, and the supports method returns a false value.
private Object[] _parsedValues = new Object[_sigFieldNames.length];
public boolean supports(Object data) throws ResourceException
{
boolean result = false;
try
{ //2003-08-09 13:05:20 EDT
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd H:mm:ss zzz");
String sData = (String)data;
this._parsedValues[0] = sdf.parse(sData.substring(0,48));
StringTokenizer st = new StringTokenizer(sData.substring(49)," ",false);
this._parsedValues[1] = st.nextToken();
this._parsedValues[2] = st.nextToken();
this._parsedValues[3] = st.nextToken();
this._parsedValues[4] = st.nextToken();
st.nextToken(); // skip the session ID
this._parsedValues[5] = st.nextToken();
this._parsedValues[6] = new Integer(st.nextToken());
this._parsedValues[7] = st.nextToken();
this._parsedValues[8] = st.nextToken();
this._parsedValues[9] = new Integer(st.nextToken());
this._parsedValues[10] = new Long(st.nextToken());
result = true;
}
catch(Throwable t){}
return result;
}
The runNotification implementation assumes that the supports method was successful in parsing the data object, so it does not need the NotificationEvent argument. It merely populates a WmRecord object by inserting the parsed names, using the same key names array that populate the resource domain.
public NotificationResults runNotification(NotificationEvent event)
throws ResourceException
{
NotificationResults result = null;
WmRecord notice = WmRecordFactory.getFactory().createWmRecord("notUsed");
for(int i = 0; i< _sigFieldNames.length;i++)
{
if (_uses[i])
{
notice.put(_sigFieldNames[i],_parsedValues[i]);
}
}
this.doNotify(notice);
result = new AsyncNotificationResults(this.nodeName(),true,null);
return result;
}
Note:
The doNotify method has two forms. When calling the WmAsynchronousNotification.doNotify(WmRecord rec, String msgId) form of this method, the length (the number of characters) of the value in msgId should not exceed a particular limit. To determine this limit, call the WmAsynchronousNotification.adapterMaxMessageIdLen() method. There is a fixed number of characters available in Integration Server to hold a notification ID. Of these, the WmART package reserves a certain number to hold a unique ID that it inserts prior to dispatching a notification. The remaining characters are available to you when calling WmAsynchronousNotification.doNotify(WmRecord rec, String msgId). For more information, see the Javadoc for WmAsynchronousNotifcation.doNotify.