Adapter Development Kit 9.12 | webMethods Adapter Development Kit Documentation | webMethods Adapter Development Kit Installation and User’s Documentation | Usage Scenarios | How to register an adapter with the Integration Server? | Creating an Adapter Implementation Class
 
Creating an Adapter Implementation Class
1. Start the editor to create Java files.
2. Create directories corresponding to your Java package structure in the webMethods package you created using Designer. For example: Integration Server_directory \instances\<instance_name>\packages\MyAdapter\code\source folder.
3. Create the following classes and interfaces:
a. An interface that contains the constants for the adapter implementation.
In the example, the interface created is MyAdapterConstants:

package com.wm.MyAdapter;

public interface MyAdapterConstants {

static final int ADAPTER_MAJOR_CODE = 9001;
static final String ADAPTER_JCA_VERSION = "1.0";
static final String ADAPTER_NAME = "MyAdapter";
static final String ADAPTER_VERSION = "9.12";

//Using next statement will create cyclic class loading dependency issue
//therefore, the resource bundle class name is fully spelled out
//static final String ADAPTER_SOURCE_BUNDLE_NAME = MyAdapterResource.class.getName();
static final String ADAPTER_SOURCE_BUNDLE_NAME =
"com.wm.MyAdapter.MyAdapterResource";
}
b. A class by extending the base class com.wm.adk.WmAdapter.
In the example, the class created is MyAdapter:

package com.wm.MyAdapter;

import java.util.Locale;

import com.wm.adk.WmAdapter;
import com.wm.adk.error.AdapterException;
import com.wm.adk.info.AdapterTypeInfo;
import com.wm.adk.log.ARTLogger;

public class MyAdapter extends WmAdapter implements MyAdapterConstants{

public static MyAdapter _instance = null;
public static ARTLogger _logger = null;

public MyAdapter() throws AdapterException { super(); }

public void fillAdapterTypeInfo(AdapterTypeInfo arg0, Locale arg1) {}
public String getAdapterJCASpecVersion() { return ADAPTER_JCA_VERSION; }
public int getAdapterMajorCode() { return ADAPTER_MAJOR_CODE; }
public String getAdapterName() { return ADAPTER_NAME; }
public String getAdapterResourceBundleName() { return ADAPTER_SOURCE_BUNDLE_NAME; }
public String getAdapterVersion() { return ADAPTER_VERSION; }
public static ARTLogger getLogger() { return _logger; }

public void initialize() throws AdapterException {
// TODO Auto-generated method stub
_logger = new ARTLogger(getAdapterMajorCode(),
getAdapterName(),
getAdapterResourceBundleName());
_logger.logDebug(9999,"My Adapter Initialized");
}

public void cleanup() {
if (_logger != null)
_logger.close();
}

public static MyAdapter getInstance() {
// TODO Auto-generated method stub
if (_instance != null)
return _instance;
else {
synchronized (MyAdapter.class) {
if (_instance != null) {
return _instance;
}
try {
_instance = new MyAdapter();
return _instance;
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
}
}
}
c. Create a resource bundle class by extending the base class java.util.ListResourceBundle.
In the example, the class created is MyAdapterResource:
package com.wm.MyAdapter;

import java.util.ListResourceBundle;
import com.wm.adk.ADKGLOBAL;

public class MyAdapterResource extends ListResourceBundle implements MyAdapterConstants{

static final String IS_PKG_NAME = "/MyAdapter/";

static final Object[][] _contents = {
// adapter type display name.
{ADAPTER_NAME + ADKGLOBAL.RESOURCEBUNDLEKEY_DISPLAYNAME, "My Adapter"}
// adapter type descriptions.
,{ADAPTER_NAME + ADKGLOBAL.RESOURCEBUNDLEKEY_DESCRIPTION,
"Adapter for MyAdapter Server (a Sample System)"}
// adapter type vendor.
,{ADAPTER_NAME + ADKGLOBAL.RESOURCEBUNDLEKEY_VENDORNAME, "Software AG"}
//Copyright URL Page
,{ADAPTER_NAME + ADKGLOBAL.RESOURCEBUNDLEKEY_THIRDPARTYCOPYRIGHTURL,
IS_PKG_NAME + "copyright.html"}
//Copyright Encoding
,{ADAPTER_NAME + ADKGLOBAL.RESOURCEBUNDLEKEY_COPYRIGHTENCODING, "UTF-8"}
//About URL Page
,{ADAPTER_NAME + ADKGLOBAL.RESOURCEBUNDLEKEY_ABOUT, IS_PKG_NAME + "About.html"}
//Release Notes URL Page
,{ADAPTER_NAME + ADKGLOBAL.RESOURCEBUNDLEKEY_RELEASENOTEURL, IS_PKG_NAME + "ReleaseNotes.html"}
};

protected Object[][] getContents() {
// TODO Auto-generated method stub
return _contents;
}
}
d. Specify the adapter’s default resource bundle in your WmAdapter implementation class. You can return the name of your default resource bundle using the getAdapterResourceBundleName method in your WmAdapter implementation class.
Example of getAdapterResourceBundleName in MyAdapter class:

@Override
public String getAdapterResourceBundleName() {
// TODO Auto-generated method stub
return ADAPTER_SOURCE_BUNDLE_NAME;
}
Example of ADAPTER_SOURCE_BUNDLE_NAME constant in MyAdapterConstants interface:
//static final String ADAPTER_SOURCE_BUNDLE_NAME = MyAdapterResource.class.getName();
static final String ADAPTER_SOURCE_BUNDLE_NAME =
"com.wm.MyAdapter.MyAdapterResource";
e. Create the reference pages for copyright, and index page for the adapter in adapterPackageName/pub folder.
Note:
You must create your reference pages in the same adapterPackageName/pub folder in the webMethods package you created using Designer.
All the Java classes and html pages for adapter implementation are created.