|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.j2ca.base.WBIManagedConnection
This is the base class for representing managed physical connections to an EIS. It provides a number of generic features that enable the container to monitor its status and manage its life-cycle, including:
A subclass should:
getMetadata
checkValidity
at the start of any method
to validate the state of class
Constructor Summary | |
---|---|
WBIManagedConnection(WBIManagedConnectionFactory mcf,
javax.security.auth.Subject subject,
WBIConnectionRequestInfo connRequestInfo)
A subclass should establish a physical connection to the EIS using the credentials and connection properties of the ManagedConnectionFactory instance
provided. |
Method Summary | |
---|---|
void |
addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Registers a listener for events related to the managed connection. |
void |
associateConnection(java.lang.Object handle)
Registers a connection handle with this managed connection. |
protected void |
checkValidity()
Verifies that this connection is still valid. |
void |
cleanup()
Releases and cleanups the managed connection in preparation for re-use. |
abstract void |
destroy()
Closes this connection to the EIS and releases any associated resources. |
void |
dissociateConnections()
Releases any connection handles associated with this managed connection. |
protected void |
fireErrorOccurred(java.lang.Exception errorThatOccurred)
Notifies the container of any errors encountered when communicating with the EIS or reported by the EIS asynchronously. |
java.lang.Object |
getConnection(javax.security.auth.Subject subject,
javax.resource.spi.ConnectionRequestInfo cri)
Returns a new connection handle for this managed connection. |
protected WBIConnectionRequestInfo |
getConnectionRequestInfo()
Returns the current connection request parameters associated with this instance. |
protected int |
getHandleCount()
Returns the number of outstanding connection handles associated with this managed connection. |
javax.resource.spi.LocalTransaction |
getLocalTransaction()
Returns a LocalTransaction instance tied to the underlying
EIS. |
LogUtils |
getLogUtils()
|
java.io.PrintWriter |
getLogWriter()
|
WBIManagedConnectionFactory |
getManagedConnectionFactory()
Returns the managed connection factory associated with this instance. |
abstract javax.resource.spi.ManagedConnectionMetaData |
getMetaData()
Returns information about the EIS connection. |
protected javax.resource.spi.security.PasswordCredential |
getPasswordCredential()
Returns the current PasswordCredential for this managed connection. |
abstract java.lang.Object |
getWBIConnection(javax.resource.spi.security.PasswordCredential pc,
boolean reauthenticate)
A subclass should return a WBIConnection instance associated with the underlying EIS connection. |
javax.transaction.xa.XAResource |
getXAResource()
Returns a XAResource instance tied to the underlying EIS. |
boolean |
isConnectionInfoOverwriteable()
Returns true if the WBIConnectionRequestInfo
already associated with this connection can be overwritten by another
which satisfies the 'match' condition. |
protected boolean |
isEnlistedInTransaction()
Allows a connection to determine whether it is already involved in a transaction. |
protected boolean |
matchConnectionRequestInfo(WBIConnectionRequestInfo requestCRI)
Determines whether the existing ConnectionRequestInfo for this connection is compatable with the configuration parameters passed in requestCRI . |
void |
removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Deregisters a listener for connection events. |
protected void |
setLogUtils(LogUtils utils)
|
void |
setLogWriter(java.io.PrintWriter out)
setLogWriter method comment. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WBIManagedConnection(WBIManagedConnectionFactory mcf, javax.security.auth.Subject subject, WBIConnectionRequestInfo connRequestInfo) throws javax.resource.ResourceException
ManagedConnectionFactory
instance
provided.
Note: Any subclass that opts to defer creation of the physical connection to a
later point in processing should be prepared for the fact that any and all
methods of this class may be invoked before the initial invocation of
getWBIConnection
.
Method Detail |
public abstract javax.resource.spi.ManagedConnectionMetaData getMetaData() throws javax.resource.ResourceException
getMetaData
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
protected boolean matchConnectionRequestInfo(WBIConnectionRequestInfo requestCRI)
requestCRI
.
Background: the connector manager may invoke getConnection(Subject, ConnectionRequestInfo)
passing a ConnectionRequestInfo instance that does not match the ConnectionRequestInfo
already associated with connection. To determine whether the ConnectionRequestInfo is compatable with this connection, the default implementation of this method does a property-for-property
comparison between the two ConnectionRequestInfo instances. It returns true
if it is an exact match or false
otherwise.
If the 'match' criteria should be something different, the resource adapter developer may override this method with a suitable implementation. For example, it may not matter if property
'language' of the ConnectionRequestInfo is different since the same connection can be used for clients of different languages; in that case, a subclass would want to override this method to
compare all values in the ConnectionRequestInfo excluding language
Returns true
if the WBIConnectionRequestInfo passed is considered to be a "match" with the WBIConnectionRequestInfo already associated with this ManagedConnection, otherwise
false
.
public boolean isConnectionInfoOverwriteable()
true
if the WBIConnectionRequestInfo
already associated with this connection can be overwritten by another
which satisfies the 'match' condition. A subclass should override this
method and return true
if the EIS can support changing
some connection parameters without destroying the connection (for
example, language). By default, this method returns false
.
If a subclass overrides this method, it should consider also overriding
matchConnectionRequestInfo(com.ibm.j2ca.base.WBIConnectionRequestInfo)
public final java.lang.Object getConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri) throws javax.resource.ResourceException
getWBIConnection
rather than override this method.
getConnection
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
public abstract java.lang.Object getWBIConnection(javax.resource.spi.security.PasswordCredential pc, boolean reauthenticate) throws javax.resource.ResourceException
Only if a subclass supports reauthentication, as indicated both in the
adapter deployment descriptor and the flag ReauthSupported
in
the associated ManagedConnectionFactory
instance, should this
method evaluate the authentication parameters passed. If reauthentication is
supported, this method should reset or modify the existing physical
connection to the EIS and match the new credentials.
javax.resource.ResourceException
public void cleanup() throws javax.resource.ResourceException
cleanup
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
public abstract void destroy() throws javax.resource.ResourceException
destroy
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
public WBIManagedConnectionFactory getManagedConnectionFactory()
protected WBIConnectionRequestInfo getConnectionRequestInfo()
protected int getHandleCount() throws javax.resource.ResourceException
javax.resource.ResourceException
protected javax.resource.spi.security.PasswordCredential getPasswordCredential()
protected void checkValidity() throws javax.resource.spi.IllegalStateException
java.lang.IllegalStateException
- (intended for the client) if the connection was closed or
invalidated previously due to an error.
javax.resource.spi.IllegalStateException
protected void fireErrorOccurred(java.lang.Exception errorThatOccurred) throws javax.resource.ResourceException
A subclass should use this method to propagate errors to the container so that the connection is recycled.
javax.resource.ResourceException
public void associateConnection(java.lang.Object handle) throws javax.resource.ResourceException
associateConnection
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
dissociateConnections()
public void dissociateConnections() throws javax.resource.ResourceException
dissociateConnections
in interface javax.resource.spi.DissociatableManagedConnection
javax.resource.ResourceException
#associateConnections
public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
addConnectionEventListener
in interface javax.resource.spi.ManagedConnection
removeConnectionEventListener(javax.resource.spi.ConnectionEventListener)
public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
removeConnectionEventListener
in interface javax.resource.spi.ManagedConnection
addConnectionEventListener(javax.resource.spi.ConnectionEventListener)
public javax.transaction.xa.XAResource getXAResource() throws javax.resource.ResourceException
XAResource
instance tied to the underlying EIS.
A subclass should override this method if it support XA transactions. If
transactions are supported, either this method or
getLocalTransaction()
should be supported but not both; this
method is preferrable.
Note: a subclass should wrap any XAResource
in a
WBIXAResourceWrapper
before returning it to allow this
connection to track transaciton status.
getXAResource
in interface javax.resource.spi.ManagedConnection
javax.resource.NotSupportedException
- by default
javax.resource.ResourceException
isEnlistedInTransaction()
,
getLocalTransaction()
public javax.resource.spi.LocalTransaction getLocalTransaction() throws javax.resource.ResourceException
LocalTransaction
instance tied to the underlying
EIS. A subclass should override this method if it support local
transactions. If transactions are supported, either this method or
getXAResource()
should be supported but not both; method
getXAResource
is preferrable.
getLocalTransaction
in interface javax.resource.spi.ManagedConnection
javax.resource.NotSupportedException
- by default
javax.resource.ResourceException
isEnlistedInTransaction()
,
getXAResource()
protected boolean isEnlistedInTransaction() throws javax.resource.ResourceException
A subclass should check this at the start and end of each request to determine whether to start a transaction or commit it, respectively.
javax.resource.ResourceException
public void setLogWriter(java.io.PrintWriter out) throws javax.resource.ResourceException
setLogWriter
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
public java.io.PrintWriter getLogWriter() throws javax.resource.ResourceException
getLogWriter
in interface javax.resource.spi.ManagedConnection
javax.resource.ResourceException
public LogUtils getLogUtils()
protected void setLogUtils(LogUtils utils)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |