com.ibm.ims.rds
Class ClientManagedConnectionFactory

java.lang.Object
  |
  +--com.ibm.ims.rds.ClientManagedConnectionFactory
All Implemented Interfaces:
javax.resource.spi.ManagedConnectionFactory, java.io.Serializable

public class ClientManagedConnectionFactory
extends java.lang.Object
implements javax.resource.spi.ManagedConnectionFactory, java.io.Serializable

In a managed-server environment, ClientManagedConnectionFactory is the object that is configured at deployment time with the information necessary to create a specific connection. It is used to create an ClientDataSource which is stored in the JNDI name space by a deployment tool, such as that for WebSphere Application Server. An application, such as an Enterprise Java Bean, can then use JNDI to find the object at runtime. For example, a DataSource deployed into the JNDI with the the name "ims/jdbc1" can be found and used to create a Connection using code like the following:

 
   // obtain the initial JNDI context
   Context initialContext = new InitialContext();

   // perform JNDI lookup to obtain connection factory
   javax.sql.DataSource dataSource =
        (javax.sql.DataSource)initialContext.lookup(“java:comp/env/ims/jdbc1”);
   javax.sql.Connection connection = dataSource.getConnection();
 

In an unmanged-server environment, the prior code can still be used to look up a DataSource for use in creating a Connection, however the application, or a related application, must have first deployed the DataSource into the name space. The following code snippet shows how to serialize an ClientDataSource into the JNDI namespace:

   ClientManagedConnectionFactory mcf = new ClientConnectionFactory();
   mcf.setDatabaseViewName("MyDatabaseView");
   mcf.setDRAName("IMS1");
   DataSource dataSource = (DataSource)mcf.createConnectionFactory();
   javax.naming.Context context = new javax.naming.InitialContext(env);
   context.bind("java:comp/env/ims/jdbc1", context);
 

See Also:
Connection, DataSource, ManagedConnectionFactory, ClientDataSource, Serialized Form

Constructor Summary
ClientManagedConnectionFactory()
          ClientManagedConnectionFactory default constructor method
 
Method Summary
 java.lang.Object createConnectionFactory()
          Creates an IMSJdbcDataSource with a default connection manager (IMSJdbcConnectionManager).
 java.lang.Object createConnectionFactory(javax.resource.spi.ConnectionManager connectionManager)
          Creates an ClientDataSource using the supplied ConnectionManager.
 javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo requestInfo)
          Creates a managed connection from the connection factory.
 boolean equals(java.lang.Object anObject)
          Determines if the input object matches set of configuration properties that make this ClientManagedConnectionFactory instance unique and specific to an instance;
 java.lang.String getDatabaseViewName()
          Returns the name of the DLIDatabaseView subclass.
 java.lang.String getDRAName()
          Returns the Database Resource Adapter (DRA) startup table identifier.
 java.lang.String getHostName()
          Returns the name (or IP address) of the host machine.
 java.io.PrintWriter getLogWriter()
          Returns the PrintWriter provided by the server runtime.
 java.lang.Integer getPortNumber()
          Returns the IIOP port number of the host machine's web server.
 java.lang.Integer getTraceLevel()
          Gets the value of the trace level property.
 java.lang.String getTransactionResourceRegistration()
          When WAS creates the ManagedConnectionFactory, it will do a getMethod for this method and then invoke the method.
 int hashCode()
          Returns the hash code of the configuration properties that make this ClientManagedConnectionFactory instance unique.
 javax.resource.spi.ManagedConnection matchManagedConnections(java.util.Set connectionPool, javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo requestInfo)
          This method is used by the server runtime to support connection pooling.
 void setDatabaseViewName(java.lang.String databaseViewName)
          Sets the name of the DLIDatabaseView subclass.
 void setDRAName(java.lang.String draName)
          Sets the name of the Database Resource Adapter (DRA) startup table identifier.
 void setHostName(java.lang.String hostName)
          Sets the name of the host machine.
 void setLogWriter(java.io.PrintWriter logWriter)
          Used by the server runtime to provide a PrintWriter for resource adapter tracing.
 void setPortNumber(java.lang.Integer portNumber)
          Sets the IIOP port number of the host machine's web server.
 void setTraceLevel(java.lang.Integer newTraceLevel)
          Turns on tracing and sets the value of the trace level property to one of the trace levels defined in XMLTrace (e.g XMLTrace.TRACE_EXCEPTIONS, XMLTrace.TRACE_METHOD1, etc).
 void setTransactionResourceRegistration(java.lang.String registration)
          Sets the transaction resource registration value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientManagedConnectionFactory

public ClientManagedConnectionFactory()
ClientManagedConnectionFactory default constructor method
Method Detail

createConnectionFactory

public java.lang.Object createConnectionFactory()
                                         throws javax.resource.ResourceException
Creates an IMSJdbcDataSource with a default connection manager (IMSJdbcConnectionManager). This supports use of the DataSource in an unmanaged server environment.
Specified by:
createConnectionFactory in interface javax.resource.spi.ManagedConnectionFactory
Returns:
java.lang.Object the IMSJdbcDataSource
Throws:
javax.resource.ResourceException - if the DataSource object cannot be created.
See Also:
DataSource

createConnectionFactory

public java.lang.Object createConnectionFactory(javax.resource.spi.ConnectionManager connectionManager)
                                         throws javax.resource.ResourceException
Creates an ClientDataSource using the supplied ConnectionManager. This supports use of the DataSource in a managed-server environment (e.g. WebSphere Application Server). This method is intended for use of the server runtime and should not normally be used in client code.
Specified by:
createConnectionFactory in interface javax.resource.spi.ManagedConnectionFactory
Parameters:
connectionManager - the server-provided ConnectionManager
Returns:
java.lang.Object the ClientDataSource
Throws:
javax.resource.ResourceException - if the DataSource object cannot be created.
See Also:
DataSource, ConnectionManager

createManagedConnection

public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,
                                                                    javax.resource.spi.ConnectionRequestInfo requestInfo)
                                                             throws javax.resource.ResourceException
Creates a managed connection from the connection factory.
Specified by:
createManagedConnection in interface javax.resource.spi.ManagedConnectionFactory
Parameters:
subject - The subject for which this connection should be obtained. The application server (connection manager) will pass a null subject if the res-ref was configured to be application managed. This resource adaptor is configured such that the ACEE should be placed on the TCB prior to this call, so if the subject is passed, then the ACEE is setup already, and there is nothing to do security wise.
reqInfo - This opaque object was passed from the connection factory to this object through the application server (connection manager).
Returns:
Returns a ManagedConnection from the appropriate connection factory.

matchManagedConnections

public javax.resource.spi.ManagedConnection matchManagedConnections(java.util.Set connectionPool,
                                                                    javax.security.auth.Subject subject,
                                                                    javax.resource.spi.ConnectionRequestInfo requestInfo)
                                                             throws javax.resource.ResourceException
This method is used by the server runtime to support connection pooling. Its use is not supported in client code.
Specified by:
matchManagedConnections in interface javax.resource.spi.ManagedConnectionFactory
Parameters:
connectionPool - the Set containing the available ManagedConnection objects.
subject -  
requestInfo -  
Returns:
a ManagedConnection object that matches the passed parameters or null if no match can be found.
Throws:
javax.resource.ResourceException - on an error matching the managed connection

setLogWriter

public void setLogWriter(java.io.PrintWriter logWriter)
                  throws javax.resource.ResourceException
Used by the server runtime to provide a PrintWriter for resource adapter tracing. Not available for client code.
Specified by:
setLogWriter in interface javax.resource.spi.ManagedConnectionFactory
Parameters:
logWriter - the PrintWriter to use for tracing.
Throws:
javax.resource.ResourceException -  
See Also:
PrintWriter

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws javax.resource.ResourceException
Returns the PrintWriter provided by the server runtime.
Specified by:
getLogWriter in interface javax.resource.spi.ManagedConnectionFactory
Returns:
the PrintWriter provided by the server runtime or null if one has not been provided.
Throws:
javax.resource.ResourceException - none currently

getDatabaseViewName

public java.lang.String getDatabaseViewName()
Returns the name of the DLIDatabaseView subclass.
Returns:
the name of the DLIDatabaseView subclass.
See Also:
DLIDatabaseView

setDatabaseViewName

public void setDatabaseViewName(java.lang.String databaseViewName)
Sets the name of the DLIDatabaseView subclass.
Parameters:
databaseViewName - the name of the DLIDatabaseView subclass.
See Also:
DLIDatabaseView

getHostName

public java.lang.String getHostName()
Returns the name (or IP address) of the host machine.
Returns:
the name of the host machine

setHostName

public void setHostName(java.lang.String hostName)
Sets the name of the host machine.
Parameters:
hostName - the name (or IP address) of the host machine.

getPortNumber

public java.lang.Integer getPortNumber()
Returns the IIOP port number of the host machine's web server.
Returns:
the port number of the host machine

setPortNumber

public void setPortNumber(java.lang.Integer portNumber)
Sets the IIOP port number of the host machine's web server.
Parameters:
portNumber - the port number of the host machine.

getDRAName

public java.lang.String getDRAName()
Returns the Database Resource Adapter (DRA) startup table identifier.
Returns:
The DRA startup table name.

setDRAName

public void setDRAName(java.lang.String draName)
Sets the name of the Database Resource Adapter (DRA) startup table identifier.
Parameters:
draName - the name of the DRA startup table.

getTraceLevel

public java.lang.Integer getTraceLevel()
Gets the value of the trace level property.
Returns:
One of the trace levels defined in XMLTrace (e.g XMLTrace.TRACE_EXCEPTIONS, XMLTrace.TRACE_METHOD1, etc) as an Integer object.
See Also:
XMLTrace

setTraceLevel

public void setTraceLevel(java.lang.Integer newTraceLevel)
Turns on tracing and sets the value of the trace level property to one of the trace levels defined in XMLTrace (e.g XMLTrace.TRACE_EXCEPTIONS, XMLTrace.TRACE_METHOD1, etc).
Parameters:
newTraceLevel - One of the trace levels defined in XMLTrace (e.g XMLTrace.TRACE_EXCEPTIONS, XMLTrace.TRACE_METHOD1, etc).
See Also:
XMLTrace

getTransactionResourceRegistration

public java.lang.String getTransactionResourceRegistration()
When WAS creates the ManagedConnectionFactory, it will do a getMethod for this method and then invoke the method. If the method is found and the returned value is "dynamic", the resource adapter will be considered to support Dynamic Transaction registration. An adapter that supports dynamic registration must post an INTERACTION_PENDING ConnectionEvent to the WebSphere EventListener when the adapter enlists in the transaction.
Returns:
Returns "dynamic" to indicate that this resource adapter supports dynamic resource registration in WebSphere.

setTransactionResourceRegistration

public void setTransactionResourceRegistration(java.lang.String registration)
Sets the transaction resource registration value. This method is used internally by WebSphere (or any J2EE server)

equals

public boolean equals(java.lang.Object anObject)
Determines if the input object matches set of configuration properties that make this ClientManagedConnectionFactory instance unique and specific to an instance;
Specified by:
equals in interface javax.resource.spi.ManagedConnectionFactory
Overrides:
equals in class java.lang.Object
Parameters:
anObject - ClientManagedConnectionFactory object to test.
Returns:
True if equal; false otherwise.

hashCode

public int hashCode()
Returns the hash code of the configuration properties that make this ClientManagedConnectionFactory instance unique.
Specified by:
hashCode in interface javax.resource.spi.ManagedConnectionFactory
Overrides:
hashCode in class java.lang.Object
Returns:
Hashcode of ClientManagedConnectionFactory instance.


(C) International Business Machines Corporation 2004. All rights reserved.