com.ibm.connector2.ims.db
Class IMSJdbcManagedConnectionFactory

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

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

In a managed-server environment, IMSJdbcManagedConnectionFactory is the object that is configured at deployment time with the information necessary to create a specific connection. It is used to create an IMSJdbcDataSource 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 IMSJdbcDataSource into the JNDI namespace:

   IMSJdbcManagedConnectionFactory mcf = new IMSJdbcConnectionFactory();
   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, IMSJdbcDataSource, Serialized Form

Constructor Summary
IMSJdbcManagedConnectionFactory()
          IMSJdbcManagedConnectionFactory 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 IMSJdbcDataSource 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 IMSJdbcManagedConnectionFactory 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.io.PrintWriter getLogWriter()
          Returns the PrintWriter provided by the server runtime.
 boolean getRRSTransactional()
          When WAS/zOS creates the ManagedConnectionFactory, it will do a getMethod for this method and then invoke the method.
 java.lang.String getThreadIdentitySupport()
          Supports the use of thread identity during getConnection processing.
 boolean getThreadSecurity()
          When WAS/zOS creates the ManagedConnectionFactory, it will do a getMethod for this method and then invoke the method.
 java.lang.Integer getTraceLevel()
          Gets the value of the trace level property.
 java.lang.String getTransactionResourceRegistration()
          When WAS/zOS 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 IMSJdbcManagedConnectionFactory 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 setLogWriter(java.io.PrintWriter logWriter)
          Used by the server runtime to provide a PrintWriter for resource adapter tracing.
 void setTraceLevel(java.lang.Integer newTraceLevel)
          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)
          The IMS JDBC resource adapter only supports dynamic resource registration.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IMSJdbcManagedConnectionFactory

public IMSJdbcManagedConnectionFactory()
IMSJdbcManagedConnectionFactory 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 IMSJdbcDataSource 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 IMSJdbcDataSource
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. It 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

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)
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

getThreadSecurity

public boolean getThreadSecurity()
When WAS/zOS 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 true, WebSphere will place the thread security context onto the current thread before ManagedConnectionFactory.createManagedConnection() and ManagedConnection.getConnection() processing. Note: Only used with WebSphere Application Server for z/OS and OS/390.
Returns:
Returns true to indicate that this resource adapter requires WebSphere to push the thread security context (ACEE) onto the current thread.

getRRSTransactional

public boolean getRRSTransactional()
When WAS/zOS 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 true, the resource adapter must support RRS Transactions. Otherwise, the adapter will be treated as not RRS Transactional. Note: Only used with WebSphere Application Server for z/OS and OS/390.
Returns:
Returns true to indicate that this resource adapter supports RRS transactions.

getTransactionResourceRegistration

public java.lang.String getTransactionResourceRegistration()
When WAS/zOS 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. Note: Only used with WebSphere Application Server for z/OS and OS/390.
Returns:
Returns "dynamic" to indicate that this resource adapter supports dynamic resource registration in WebSphere.

setTransactionResourceRegistration

public void setTransactionResourceRegistration(java.lang.String registration)
The IMS JDBC resource adapter only supports dynamic resource registration. This method is here so that a warning message does not appear in the log of the J2EE server. The paramater is ignored. Note: Only used with WebSphere Application Server for z/OS and OS/390.

equals

public boolean equals(java.lang.Object anObject)
Determines if the input object matches set of configuration properties that make this IMSJdbcManagedConnectionFactory 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 - IMSJdbcManagedConnectionFactory object to test.
Returns:
True if equal; false otherwise.

hashCode

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

getThreadIdentitySupport

public java.lang.String getThreadIdentitySupport()
Supports the use of thread identity during getConnection processing. Always returns "REQUIRED".
Returns:
String


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