javax.resource.cci
Interface ConnectionFactory

All Superinterfaces:
Referenceable, javax.naming.Referenceable, java.io.Serializable

public interface ConnectionFactory
extends java.io.Serializable, Referenceable

ConnectionFactory provides an interface for getting connection to an EIS instance. An implementation of ConnectionFactory interface is provided by a resource adapter.

Application code looks up a ConnectionFactory instance from JNDI namespace and uses it to get EIS connections.

An implementation class for ConnectionFactory is required to implement java.io.Serializable and javax.resource.Referenceableinterfaces to support JNDI registration.

See Also:
Connection, Referenceable

Method Summary
 Connection getConnection()
          Gets a connection to an EIS instance.
 Connection getConnection(ConnectionSpec properties)
          Gets a connection to an EIS instance.
 java.io.PrintWriter getLogWriter()
          Gets the log writer for the ConnectionFactory instance.
 ResourceAdapterMetaData getMetaData()
          Gets metadata for the Resource Adapter.
 RecordFactory getRecordFactory()
          Gets a RecordFactory instance.
 int getTimeout()
          Gets the maximum time in milliseconds that this connection factory can wait while attempting to connect to an EIS.
 void setLogWriter(java.io.PrintWriter out)
          Sets the log writer for the ConnectionFactory instance.
 void setTimeout(int milliseconds)
          Sets the maximum time in milliseconds that this connection factory will wait while attempting to connect to an EIS.
 
Methods inherited from interface javax.resource.Referenceable
setReference
 
Methods inherited from interface javax.naming.Referenceable
getReference
 

Method Detail

getConnection

public Connection getConnection()
                         throws ResourceException
Gets a connection to an EIS instance. This getConnection variant should be used when a component wants the container to manager EIS sign-on. This case is termed container-managed sign-on. The component does not pass any security information.
Returns:
Connection instance
Throws:
ResourceException - Failed to get a connection to the EIS instance

getConnection

public Connection getConnection(ConnectionSpec properties)
                         throws ResourceException
Gets a connection to an EIS instance. A component should use the getConnection variant with javax.resource.cci.ConnectionSpec parameter, if it needs to pass any resource adapter specific security information and connection parameters. In the component- managed sign-on case, an application component passes security information (example: username, password) through the ConnectionSpec instance.

It is important to note that the properties passed through the getConnection method should be client-specific (example: username, password, language) and not related to the configuration of a target EIS instance (example: port number, server name). The ManagedConnectionFactory instance is configured with complete set of properties required for the creation of a connection to an EIS instance.

Parameters:
properties - connection parameters and security information specified as ConnectionSpec instance
Returns:
Connection instance
Throws:
ResourceException - Failed to get a connection to the EIS instance
See Also:
ConnectionSpec

getRecordFactory

public RecordFactory getRecordFactory()
                               throws ResourceException
Gets a RecordFactory instance. The RecordFactory is used for the creation of generic Record instances.
Returns:
RecordFactory RecordFactory instance
Throws:
ResourceException -  

getMetaData

public ResourceAdapterMetaData getMetaData()
                                    throws ResourceException
Gets metadata for the Resource Adapter. Note that the metadata information is about the ResourceAdapter and not the EIS instance. An invocation of this method does not require that an active connection to an EIS instance should have been established.
Throws:
ResourceException - Failed to get information about the resource adapter.

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws ResourceException
Sets the log writer for the ConnectionFactory instance.

The log writer is a character output stream to which all logging and tracing messages for the Connectionfactory instance will be printed.

When a ConnectionFactory object is created the log writer is initially null, in other words, logging is disabled. Once a log writer is associated with a ConnectionFactory, logging and tracing for ConnectionFactory instance is enabled.

A Connection instance resulting from a ConnectionFactory inherits the log writer set on the ConnectionFactory.

Parameters:
out - Log writer associated with the ConnectionFactory
Throws:
ResourceException - Failed to set log writer for the ConnectionFactory

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws ResourceException
Gets the log writer for the ConnectionFactory instance.

The log writer is a character output stream to which all logging and tracing messages for this connection factory instance will be printed. When a ConnectionFactory object is created the log writer is initially null meaning that logging is disabled.

Returns:
log writer associated with the ConnectionFactory
Throws:
ResourceException - Failed to get the log writer for the ConnectionFactory

setTimeout

public void setTimeout(int milliseconds)
                throws ResourceException
Sets the maximum time in milliseconds that this connection factory will wait while attempting to connect to an EIS.

A value of zero specifies that the timeout is the default system timeout if there is one; otherwise it specifies that there is no timeout. When a ConnectionFactory object is created the timeout is initially zero.

Parameters:
milliseconds - connection establishment timeout in milliseconds
Throws:
ResourceException - Failed to set timeout for the ConnectionFactory

getTimeout

public int getTimeout()
               throws ResourceException
Gets the maximum time in milliseconds that this connection factory can wait while attempting to connect to an EIS. A value of zero mean that the timeout is the default system timeout if there is one; otherwise it means that there is no timeout. When a ConnectionFactory object is created the timeout is initially zero.
Returns:
connection establishment timeout in milliseconds
Throws:
ResourceException - Failed to get timeout for the ConnectionFactory