Adapter Development Kit 9.12 | webMethods Adapter Development Kit Documentation | webMethods Adapter Development Kit Installation and User’s Documentation | Runtime Activities | Runtime Connection Allocation for Adapter Services | Implementing Partitioned Connection Pools | Updating the Connection Factory
 
Updating the Connection Factory
The adapter's WmManagedConnectionFactory implementation must be able to produce valid WmConnectionRequestInfo objects and it must be able to use those objects to create connections with the required characteristics to support the partitioned connection pool feature.
1. Implement the getConnectionRequestInfo method.
In the example, getConnectionRequestInfo uses information from the ConnectionSpec object to produce a valid ConnectionRequestInfo object. The MegaBank user name is used as a key to lookup a set of user ID and credentials appropriate for the backend being accessed by this connection.
Note:
Details of how this lookup is implemented are adapter specific and outside the scope of this document.
/**
* Produce a ConnectionRequestInfo object based on the provided ConnectionSpec
* object. If an mbUserName is provided, lookup the name to use on the backend
* for this connection pool.
*/
public ConnectionRequestInfo getConnectionRequestInfo(ConnectionSpec spec)
{
MbConnectionRequestInfo partitionDef = null;
if(spec != null && spec instanceof MbConnectionSpec)
{
synchronized(this)
{
try
{
String mbUserName = ((MbConnectionSpec)spec).getMbUserName();
lookupUser(mbUserName);
partitionDef = new MbConnectionRequestInfo(mbUserName,
this.backendUserID, this.credentials);
}
catch(IllegalArgumentException ex)
{
// no partition info available for this user. Swallow the
// exception and return null
}
}
}
return partitionDef
}
2. Update the createManagedConnectionObject method.
The ConnectionRequestInfo object returned from getConnectionRequestInfo method is passed to the createManagedConnectionObject method when the connection pool needs a new connection belonging to a particular partition. In the example, this information is used to override default logon information that is otherwise established based on the metadata parameter settings.
Note:
The createManagedConnectionObject method implementations must be able to establish default-partition connections when null is passed in the cxRequestInfo argument.
/**
* Create a connection using userId and credentials from the provided
* connectionRequestInfo object, if provided. If connectionRequestInfo is
* not provided use the default userId and credentials information established
* at node startup from metadata parameters.
*/
public WmManagedConnection createManagedConnectionObject(Subject subject,
ConnectionRequestInfo cxRequestInfo) throws ResourceException
{
String connUser;
Credentials connCredentials;
if (cxRequestInfo != null && cxRequestInfo instanceof
MbConnectionRequestInfo)
{
connUser = ((MbConnectionRequestInfo)cxRequestInfo).getUserId();
connCredentials =
((MbConnectionRequestInfo)cxRequestInfo).getCredentials();
}
else
{
connUser = this.defaultUserId;
connCredentials = this.defaultCredentials;
}
return new MbConnection(connUser, connCredentials);
}