|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.firebirdsql.jca.FBManagedConnection
public class FBManagedConnection
The class FBManagedConnection implements both the
ManagedConnection and XAResource interfaces.
| Field Summary | |
|---|---|
static java.lang.String |
WARNING_NO_CHARSET
|
| Fields inherited from interface javax.transaction.xa.XAResource |
|---|
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY |
| Method Summary | |
|---|---|
void |
addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Add an ConnectionEventListener listener. |
void |
associateConnection(java.lang.Object connection)
Used by the container to change the association of an application-level connection handle with a ManagedConneciton instance. |
void |
cleanup()
Application server calls this method to force any cleanup on the ManagedConnection instance. |
void |
close(AbstractConnection c)
Close this connection with regards to a wrapping AbstractConnection. |
void |
commit(javax.transaction.xa.Xid id,
boolean onePhase)
Commits a transaction. |
void |
destroy()
Destroys the physical connection to the underlying resource manager. |
void |
end(javax.transaction.xa.Xid id,
int flags)
Dissociates a resource from a global transaction. |
void |
errorOccured(GDSException ex)
Notify GDS container that error occured, if the ex
represents a "fatal" one |
protected javax.transaction.xa.Xid |
findSingleXid(javax.transaction.xa.Xid externalXid)
Obtain a single prepared transaction branch from a resource manager, based on a Xid |
void |
forget(javax.transaction.xa.Xid id)
Indicates that no further action will be taken on behalf of this transaction (after a heuristic failure). |
java.lang.Object |
getConnection(javax.security.auth.Subject subject,
javax.resource.spi.ConnectionRequestInfo cri)
Creates a new connection handle for the underlying physical connection represented by the ManagedConnection instance. |
FBConnectionRequestInfo |
getConnectionRequestInfo()
Get information about the current connection parameters. |
java.lang.String |
getDatabase()
|
org.firebirdsql.gds.impl.GDSHelper |
getGDSHelper()
Get instance of GDSHelper connected with this managed connection. |
javax.resource.spi.LocalTransaction |
getLocalTransaction()
Returns a javax.resource.spi.LocalTransaction instance. |
java.io.PrintWriter |
getLogWriter()
Gets the log writer for this ManagedConnection instance. |
javax.resource.spi.ManagedConnectionFactory |
getManagedConnectionFactory()
Get the managed connection factory that created this managed connection. |
javax.resource.spi.ManagedConnectionMetaData |
getMetaData()
Gets the metadata information for this connection's underlying EIS resource manager instance. |
java.lang.Object |
getSynchronizationObject()
Get synchronization object. |
int |
getTransactionIsolation()
Get the transaction isolation level of this connection. |
TransactionParameterBuffer |
getTransactionParameters()
|
TransactionParameterBuffer |
getTransactionParameters(int isolation)
|
int |
getTransactionTimeout()
Gets the transaction timeout. |
javax.transaction.xa.XAResource |
getXAResource()
Return an XA resource to the caller. |
boolean |
inDistributedTransaction()
|
void |
internalStart(javax.transaction.xa.Xid id,
int flags)
Perform the internal processing to start associate a JDBC connection with a global transaction. |
boolean |
inTransaction()
|
boolean |
isConnectionSharing()
Check if connection sharing is enabled. |
boolean |
isManagedEnvironment()
|
boolean |
isReadOnly()
Retrieve whether this connection is readonly. |
boolean |
isSameRM(javax.transaction.xa.XAResource res)
Retrieve whether this FBManagedConnection uses the same
ResourceManager as res. |
int |
prepare(javax.transaction.xa.Xid xid)
Prepares a transaction to commit. |
javax.transaction.xa.Xid[] |
recover(int flags)
Obtain a list of prepared transaction branches from a resource manager. |
void |
removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Remove a ConnectionEventListner from the listing of
listeners that will be notified for a ConnectionEvent. |
void |
rollback(javax.transaction.xa.Xid xid)
Rolls back the work, assuming it was done on behalf of the specified transaction. |
void |
setConnectionSharing(boolean connectionSharing)
Enable or disable connection sharing. |
void |
setLogWriter(java.io.PrintWriter out)
Sets the log writer for this ManagedConnection instance. |
void |
setManagedEnvironment(boolean managedEnvironment)
|
void |
setReadOnly(boolean readOnly)
Set whether this connection is to be readonly |
void |
setTransactionIsolation(int isolation)
Set the transaction level for this connection. |
void |
setTransactionParameters(int isolation,
TransactionParameterBuffer transactionParams)
|
void |
setTransactionParameters(TransactionParameterBuffer transactionParameters)
|
boolean |
setTransactionTimeout(int timeout)
Sets the transaction timeout. |
void |
start(javax.transaction.xa.Xid id,
int flags)
Associates a JDBC connection with a global transaction. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String WARNING_NO_CHARSET
| Method Detail |
|---|
public void errorOccured(GDSException ex)
ex
represents a "fatal" one
errorOccured in interface org.firebirdsql.gds.impl.GDSHelper.GDSHelperErrorListenerFatalGDSErrorHelper.isFatal(GDSException)
public org.firebirdsql.gds.impl.GDSHelper getGDSHelper()
throws GDSException
GDSHelper connected with this managed connection.
GDSHelper.
GDSException - If this connection has no GDSHelperpublic java.lang.String getDatabase()
public boolean isManagedEnvironment()
public boolean inTransaction()
public void setManagedEnvironment(boolean managedEnvironment)
throws javax.resource.ResourceException
javax.resource.ResourceExceptionpublic boolean isConnectionSharing()
AbstractConnection instances)
can access this managed connection in thread-safe manner (they synchronize
on this instance). This feature can be enabled only in JCA environment,
any other environment must not use connection sharing.
true if connection sharing is enabled.
public void setConnectionSharing(boolean connectionSharing)
throws javax.resource.ResourceException
isConnectionSharing()
method for details.
connectionSharing - true if connection sharing must be
enabled.
javax.resource.ResourceException - If connection sharing state cannot be changedpublic javax.resource.spi.LocalTransaction getLocalTransaction()
javax.resource.spi.LocalTransaction instance.
The LocalTransaction interface is used by the container to manage local
transactions for a RM instance.
getLocalTransaction in interface javax.resource.spi.ManagedConnectionjavax.resource.ResourceException - generic exception if operation fails
javax.resource.NotSupportedException - if the operation is not supported
javax.resource.spi.ResourceAdapterInternalException - resource adapter internal error condition
public javax.resource.spi.ManagedConnectionMetaData getMetaData()
throws javax.resource.ResourceException
getMetaData in interface javax.resource.spi.ManagedConnectionjavax.resource.ResourceException - generic exception if operation fails
javax.resource.NotSupportedException - if the operation is not supportedpublic void setLogWriter(java.io.PrintWriter out)
The log writer is a character output stream to which all logging and tracing messages for this ManagedConnection instance will be printed. Application Server manages the association of output stream with the ManagedConnection instance based on the connection pooling requirements.
When a ManagedConnection object is initially created, the default log
writer associated with this instance is obtained from the
ManagedConnectionFactory. An application server can set a
log writer specific to this ManagedConnection to log/trace this instance
using setLogWriter method.
setLogWriter in interface javax.resource.spi.ManagedConnectionout - Character Output stream to be associated
javax.resource.ResourceException - generic exception if operation fails
javax.resource.spi.ResourceAdapterInternalException - resource adapter related error conditionpublic java.io.PrintWriter getLogWriter()
The log writer is a character output stream to which all logging and
tracing messages for this ManagedConnection instance will be printed.
ConnectionManager manages the association of output stream
with the ManagedConnection instance based on the
connection pooling requirements.
The Log writer associated with a ManagedConnection
instance can be one set as default from the ManagedConnectionFactory
(that created this connection) or one set specifically for this instance
by the application server.
getLogWriter in interface javax.resource.spi.ManagedConnectionManagedConnection
javax.resource.ResourceException - generic exception if operation failspublic void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
ConnectionEventListener listener. The listener will
be notified when a ConnectionEvent occurs.
addConnectionEventListener in interface javax.resource.spi.ManagedConnectionlistener - The ConnectionEventListener to be addedpublic void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
ConnectionEventListner from the listing of
listeners that will be notified for a ConnectionEvent.
removeConnectionEventListener in interface javax.resource.spi.ManagedConnectionlistener - The ConnectionEventListener to be removed
public void associateConnection(java.lang.Object connection)
throws javax.resource.ResourceException
The resource adapter is required to implement the associateConnection method. The method implementation for a ManagedConnection should dissociate the connection handle (passed as a parameter) from its currently associated ManagedConnection and associate the new connection handle with itself.
associateConnection in interface javax.resource.spi.ManagedConnectionconnection - Application-level connection handle
javax.resource.ResourceException - Failed to associate the connection handle with this
ManagedConnection instance
javax.resource.spi.IllegalStateException - Illegal state for invoking this method
javax.resource.spi.ResourceAdapterInternalException - Resource adapter internal error condition
public void cleanup()
throws javax.resource.ResourceException
ManagedConnection instance.
The method ManagedConnection.cleanup()initiates a cleanup of the
any client-specific state as maintained by a ManagedConnection instance.
The cleanup should invalidate all connection handles that had been
created using this ManagedConnection instance. Any attempt
by an application component to use the connection handle after cleanup of
the underlying ManagedConnection should result in an
exception.
The cleanup of ManagedConnection is always driven by an application
server. An application server should not invoke
ManagedConnection.cleanup()when there is an uncompleted
transaction (associated with a ManagedConnection instance) in progress.
The invocation of ManagedConnection.cleanup()method on an already
cleaned-up connection should not throw an exception.
The cleanup of ManagedConnection instance resets its
client specific state and prepares the connection to be put back in to a
connection pool. The cleanup method should not cause resource adapter to
close the physical pipe and reclaim system resources associated with the
physical connection.
cleanup in interface javax.resource.spi.ManagedConnectionjavax.resource.ResourceException - generic exception if operation fails
javax.resource.spi.ResourceAdapterInternalException - resource adapter internal error condition
javax.resource.spi.IllegalStateException - Illegal state for calling connection cleanup. Example - if a
local transaction is in progress that doesn't allow
connection cleanup
public java.lang.Object getConnection(javax.security.auth.Subject subject,
javax.resource.spi.ConnectionRequestInfo cri)
throws javax.resource.ResourceException
ManagedConnection instance. This
connection handle is used by the application code to refer to the
underlying physical connection. A connection handle is tied to its
ManagedConnection instance in a resource adapter
implementation specific way.
The ManagedConnection uses the Subject and additional
ConnectionRequestInfo (which is specific to resource
adapter and opaque to application server) to set the state of the
physical connection.
getConnection in interface javax.resource.spi.ManagedConnectionsubject - security context as JAAS subjectcri - ConnectionRequestInfo instance
Object instance representing the
connection handle. For CCI, the connection handle created by a
ManagedConnection instance is of the type
javax.resource.cci.Connection.
javax.resource.ResourceException - generic exception if operation fails
javax.resource.spi.ResourceAdapterInternalException - resource adapter internal error condition
javax.resource.spi.SecurityException - security related error condition
javax.resource.spi.CommException - failed communication with EIS instance
javax.resource.spi.EISSystemException - internal error condition in EIS instance - used if EIS
instance is involved in setting state of
ManagedConnection
public void destroy()
throws javax.resource.ResourceException
ManagedConnection.destroy()to destroy a physical
connection. A resource adapter should destroy all allocated system
resources for this ManagedConnection instance when the
method destroy is called.
destroy in interface javax.resource.spi.ManagedConnectionjavax.resource.ResourceException - generic exception if operation failed
javax.resource.spi.IllegalStateException - illegal state for destroying connectionpublic javax.transaction.xa.XAResource getXAResource()
In both javax.sql.XAConnection and
javax.resource.spi.MangagedConnection.
getXAResource in interface javax.resource.spi.ManagedConnection
public void commit(javax.transaction.xa.Xid id,
boolean onePhase)
throws javax.transaction.xa.XAException
commit in interface javax.transaction.xa.XAResourcejavax.transaction.xa.XAException - Occurs when the state was not correct (end never called), the
transaction ID is wrong, the connection was set to
Auto-Commit, or the commit on the underlying connection
fails. The error code differs depending on the exact
situation.
public void end(javax.transaction.xa.Xid id,
int flags)
throws javax.transaction.xa.XAException
end in interface javax.transaction.xa.XAResourcejavax.transaction.xa.XAException - Occurs when the state was not correct (end called twice), or
the transaction ID is wrong.
public void forget(javax.transaction.xa.Xid id)
throws javax.transaction.xa.XAException
forget in interface javax.transaction.xa.XAResourcejavax.transaction.xa.XAException - Occurs when the state was not correct (end never called), or
the transaction ID is wrong.
public int getTransactionTimeout()
throws javax.transaction.xa.XAException
getTransactionTimeout in interface javax.transaction.xa.XAResourcejavax.transaction.xa.XAException
public boolean isSameRM(javax.transaction.xa.XAResource res)
throws javax.transaction.xa.XAException
FBManagedConnection uses the same
ResourceManager as res. This method relies on
res being a Firebird implementation of
XAResource.
isSameRM in interface javax.transaction.xa.XAResourceres - The other XAResource to compare to
true if res uses the same
ResourceManager, false otherwise
javax.transaction.xa.XAException
public int prepare(javax.transaction.xa.Xid xid)
throws javax.transaction.xa.XAException
prepare in interface javax.transaction.xa.XAResourcejavax.transaction.xa.XAException - Occurs when the state was not correct (end never called), the
transaction ID is wrong, or the connection was set to
Auto-Commit.
public javax.transaction.xa.Xid[] recover(int flags)
throws javax.transaction.xa.XAException
recover in interface javax.transaction.xa.XAResourceflags - One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be
used when no other flags are set in flags.
javax.transaction.xa.XAException - An error has occurred. Possible values are XAER_RMERR,
XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.
protected javax.transaction.xa.Xid findSingleXid(javax.transaction.xa.Xid externalXid)
throws javax.transaction.xa.XAException
externalXid - The Xid to find
javax.transaction.xa.XAException - An error has occurred. Possible values are XAER_RMERR,
XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.public final java.lang.Object getSynchronizationObject()
Synchronizable
getSynchronizationObject in interface Synchronizablenull.
public void rollback(javax.transaction.xa.Xid xid)
throws javax.transaction.xa.XAException
rollback in interface javax.transaction.xa.XAResourcejavax.transaction.xa.XAException - Occurs when the state was not correct (end never called), the
transaction ID is wrong, the connection was set to
Auto-Commit, or the rollback on the underlying connection
fails. The error code differs depending on the exact
situation.
public boolean setTransactionTimeout(int timeout)
throws javax.transaction.xa.XAException
setTransactionTimeout in interface javax.transaction.xa.XAResourcetimeout - The timeout to be set in seconds
javax.transaction.xa.XAExceptionpublic boolean inDistributedTransaction()
public void start(javax.transaction.xa.Xid id,
int flags)
throws javax.transaction.xa.XAException
start in interface javax.transaction.xa.XAResourceid - A global transaction identifier to be associated with the
resourceflags - One of TMNOFLAGS, TMJOIN, or TMRESUME
javax.transaction.xa.XAException - Occurs when the state was not correct (start called twice),
the transaction ID is wrong, or the instance has already been
closed.
public void internalStart(javax.transaction.xa.Xid id,
int flags)
throws javax.transaction.xa.XAException,
GDSException
id - A global transaction identifier to be associated with the
resourceflags - One of TMNOFLAGS, TMJOIN, or TMRESUME
javax.transaction.xa.XAException - If the transaction is already started, or this connection cannot participate in the distributed transaction
GDSExceptionstart(Xid, int)public void close(AbstractConnection c)
AbstractConnection.
c - The AbstractConnection that is being closedpublic FBConnectionRequestInfo getConnectionRequestInfo()
FBConnectionRequestInfo.public TransactionParameterBuffer getTransactionParameters()
public void setTransactionParameters(TransactionParameterBuffer transactionParameters)
public TransactionParameterBuffer getTransactionParameters(int isolation)
public void setTransactionParameters(int isolation,
TransactionParameterBuffer transactionParams)
public int getTransactionIsolation()
throws javax.resource.ResourceException
java.sql.Connection (i.e.
TRANSACTION_READ_COMMITTED,
TRANSACTION_READ_UNCOMMITTED,
TRANSACTION_REPEATABLE_READ,
TRANSACTION_SERIALIZABLE.
Connection.
javax.resource.ResourceException - If the transaction level cannot be retrievedConnection,
setTransactionIsolation(int)
public void setTransactionIsolation(int isolation)
throws javax.resource.ResourceException
java.sql.Connection (i.e.
TRANSACTION_READ_COMMITTED,
TRANSACTION_READ_UNCOMMITTED,
TRANSACTION_REPEATABLE_READ,
TRANSACTION_SERIALIZABLE.
isolation - Value representing a transaction isolation level defined in
Connection.
javax.resource.ResourceException - If the transaction level cannot be retrievedConnection,
getTransactionIsolation()public javax.resource.spi.ManagedConnectionFactory getManagedConnectionFactory()
ManagedConnectionFactory.public void setReadOnly(boolean readOnly)
readOnly - If true, the connection will be set read-only,
otherwise it will be writablepublic boolean isReadOnly()
true if this connection is readonly,
false otherwise
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||