public class ManagedConnectionImpl extends Object implements ManagedConnection, LocalTransaction, ExceptionListener
ManagedConnectionImpl
instance wraps a physical connection
to an underlying JORAM server, and provides "handles" for handling this
physical connection.Modifier and Type | Field and Description |
---|---|
private XAConnection |
cnx
Physical connection to the JORAM server.
|
(package private) ConnectionRequestInfo |
cxRequest
only used for reconnection
|
private Vector |
handles
Vector of connection handles.
|
private int |
hashCode
hashCode
|
(package private) String |
hostName
Underlying JORAM server host name.
|
private Vector |
listeners
Vector of condition event listeners.
|
private Object |
lock
Use for reconnection synchronization
|
private Object |
lockForExc |
static org.objectweb.util.monolog.api.Logger |
logger |
(package private) ManagedConnectionFactoryImpl |
mcf
Ref to the managed connection factory (use to reconnect)
|
private ManagedConnectionMetaDataImpl |
metaData
Connection meta data.
|
(package private) String |
mode
Messaging mode (PTP or PubSub or Unified).
|
private PrintWriter |
out
Out stream for error logging and tracing.
|
private JoramResourceAdapter |
ra
Central adapter authority.
|
(package private) int |
serverPort
Underlying JORAM server port number.
|
private Session |
session
Unique session for the use of managed components, involved in local or
distributed transactions.
|
private boolean |
startedLocalTx
true if a local transaction has been started. |
(package private) Subject |
subject
only used for reconnection
|
private long |
timeWaitReconnect
The waiting time in ms for reconnection.
|
(package private) String |
userName
User identification.
|
private boolean |
valid
true if the connection is valid. |
Constructor and Description |
---|
ManagedConnectionImpl(JoramResourceAdapter ra,
ManagedConnectionFactoryImpl mcf,
XAConnection cnx,
String hostName,
int serverPort,
String userName)
Creates a
ManagedConnectionImpl instance wrapping a
physical connection to the underlying JORAM server. |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionEventListener(ConnectionEventListener listener)
Adds a connection event listener.
|
void |
associateConnection(Object connection)
Dissociates a given connection handle and associates it to this
managed connection.
|
void |
begin()
Notifies that the local transaction is beginning.
|
void |
cleanup()
Remove the created handles and prepares the physical connection
to be put back into a connection pool.
|
(package private) void |
closeHandle(OutboundConnection handle)
Notifies of the closing of one of the connection handles.
|
void |
commit()
Commits the local transaction.
|
void |
destroy()
Destroys the physical connection to the underlying JORAM server.
|
boolean |
equals(Object o)
Compares
ManagedConnectionImpl instances according to their
server and user identification parameters. |
Object |
getConnection(Subject subject,
ConnectionRequestInfo cxRequestInfo)
Returns a new
OutboundConnection instance for handling the
physical connection. |
LocalTransaction |
getLocalTransaction()
Returns this managed connection instance as a
LocalTransaction instance for managing local transactions. |
PrintWriter |
getLogWriter()
Gets the log writer for this
ManagedConnectionImpl
instance. |
ManagedConnectionMetaData |
getMetaData()
Returns the metadata information for the underlying JORAM server.
|
(package private) Session |
getSession() |
XAResource |
getXAResource()
Provides a
XAResource instance for managing distributed transactions. |
int |
hashCode()
Returns a code based on the JORAM server and user identification
parameters.
|
(package private) boolean |
isReconnected() |
(package private) boolean |
isValid()
Returns
false if the wrapped physical connection has been
lost or destroyed, true if it is still valid. |
(package private) boolean |
matches(String hostName,
int serverPort,
String userName,
String mode)
Returns
true if this managed connection matches given
parameters. |
void |
onException(JMSException exc)
Notifies that the wrapped physical connection has been lost.
|
(package private) void |
reconnect() |
void |
removeConnectionEventListener(ConnectionEventListener listener)
Removes a connection event listener.
|
void |
rollback()
Rollsback the local transaction.
|
void |
setLogWriter(PrintWriter out)
Sets the log writer for this
ManagedConnectionImpl
instance. |
(package private) void |
setSession(Session session) |
public static org.objectweb.util.monolog.api.Logger logger
private JoramResourceAdapter ra
ManagedConnectionFactoryImpl mcf
private XAConnection cnx
private Vector handles
private Vector listeners
private boolean startedLocalTx
true
if a local transaction has been started.private ManagedConnectionMetaDataImpl metaData
private PrintWriter out
private boolean valid
true
if the connection is valid.private int hashCode
String hostName
int serverPort
String mode
String userName
private Session session
Subject subject
ConnectionRequestInfo cxRequest
private Object lock
private long timeWaitReconnect
private Object lockForExc
ManagedConnectionImpl(JoramResourceAdapter ra, ManagedConnectionFactoryImpl mcf, XAConnection cnx, String hostName, int serverPort, String userName)
ManagedConnectionImpl
instance wrapping a
physical connection to the underlying JORAM server.ra
- Central adapter authority.mcf
- The Managed Connection Factorycnx
- Physical connection to the JORAM server.hostName
- JORAM server host name.serverPort
- JORAM server port number.userName
- User identification.final Session getSession()
final void setSession(Session session)
public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
OutboundConnection
instance for handling the
physical connection.getConnection
in interface ManagedConnection
CommException
- If the wrapped physical connection is lost.ResourceException
public void associateConnection(Object connection) throws ResourceException
associateConnection
in interface ManagedConnection
CommException
- If the wrapped physical connection is lost.ResourceException
- If the provided handle is invalid.public void addConnectionEventListener(ConnectionEventListener listener)
addConnectionEventListener
in interface ManagedConnection
public void removeConnectionEventListener(ConnectionEventListener listener)
removeConnectionEventListener
in interface ManagedConnection
public XAResource getXAResource() throws ResourceException
XAResource
instance for managing distributed transactions.getXAResource
in interface ManagedConnection
CommException
- If the physical connection is lost.IllegalStateException
- If the managed connection is involved in a local transaction.ResourceAdapterInternalException
- If the XA resource can't be retrieved.ResourceException
public LocalTransaction getLocalTransaction() throws ResourceException
LocalTransaction
instance for managing local transactions.getLocalTransaction
in interface ManagedConnection
CommException
- If the physical connection is lost.IllegalStateException
- If the managed connection is
involved in a distributed
transaction.LocalTransactionException
- If the LocalTransaction resource
can't be created.ResourceException
public ManagedConnectionMetaData getMetaData() throws ResourceException
getMetaData
in interface ManagedConnection
ResourceException
- Never thrown.public void setLogWriter(PrintWriter out) throws ResourceException
ManagedConnectionImpl
instance.setLogWriter
in interface ManagedConnection
ResourceException
- Never thrown.public PrintWriter getLogWriter() throws ResourceException
ManagedConnectionImpl
instance.getLogWriter
in interface ManagedConnection
ResourceException
- Never thrown.public void cleanup() throws ResourceException
cleanup
in interface ManagedConnection
ResourceException
- Never thrown.public void destroy() throws ResourceException
destroy
in interface ManagedConnection
ResourceException
- Never thrown.public int hashCode()
public boolean equals(Object o)
ManagedConnectionImpl
instances according to their
server and user identification parameters.public void onException(JMSException exc)
onException
in interface ExceptionListener
void reconnect()
boolean isReconnected()
public void begin() throws ResourceException
begin
in interface LocalTransaction
CommException
- If the wrapped physical connection
is lost.LocalTransactionException
- If a local transaction has already
begun.ResourceException
public void commit() throws ResourceException
commit
in interface LocalTransaction
CommException
- If the wrapped physical connection
is lost.LocalTransactionException
- If the local transaction has not
begun, or if the commit fails.ResourceException
public void rollback() throws ResourceException
rollback
in interface LocalTransaction
CommException
- If the wrapped physical connection
is lost.LocalTransactionException
- If the local transaction has not
begun, or if the rollback fails.ResourceException
boolean matches(String hostName, int serverPort, String userName, String mode)
true
if this managed connection matches given
parameters.boolean isValid()
false
if the wrapped physical connection has been
lost or destroyed, true
if it is still valid.void closeHandle(OutboundConnection handle)
Copyright © 2021 ScalAgent D.T.. All rights reserved.