Class ManagedConnectionFactoryImpl
- java.lang.Object
-
- org.objectweb.joram.client.connector.ManagedConnectionFactoryConfig
-
- org.objectweb.joram.client.connector.ManagedConnectionFactoryImpl
-
- All Implemented Interfaces:
Serializable,ManagedConnectionFactory,ResourceAdapterAssociation,ValidatingManagedConnectionFactory
- Direct Known Subclasses:
ManagedQueueConnectionFactoryImpl,ManagedTopicConnectionFactoryImpl
public class ManagedConnectionFactoryImpl extends ManagedConnectionFactoryConfig implements ManagedConnectionFactory, ResourceAdapterAssociation, ValidatingManagedConnectionFactory, Serializable
AManagedConnectionFactoryImplinstance manages outbound connectivity to a given JORAM server.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static booleanDEBUGprivate static Loggerloggerprotected PrintWriteroutOut stream for error logging and tracing.(package private) JoramResourceAdapterraResource adapter central authority.private static longserialVersionUIDDefine serialVersionUID for interoperability.-
Fields inherited from class org.objectweb.joram.client.connector.ManagedConnectionFactoryConfig
MODE_PTP, MODE_PUBSUB, MODE_UNIFIED
-
-
Constructor Summary
Constructors Constructor Description ManagedConnectionFactoryImpl()Constructs aManagedConnectionFactoryImplinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcreateConnectionFactory()Method called in the non managed case for creating anOutboundConnectionFactoryinstance.ObjectcreateConnectionFactory(ConnectionManager cxManager)Method called by an application server (managed case) for creating anOutboundConnectionFactoryinstance.protected XAConnectionFactorycreateFactory(ConnectionRequestInfo cxRequest)ManagedConnectioncreateManagedConnection(Subject subject, ConnectionRequestInfo cxRequest)Creates a new physical connection to the underlying JORAM server, and returns aManagedConnectionImplinstance for a managed environment.protected XAConnectioncreateXAConnection(XAConnectionFactory factory, String userName, String password)booleanequals(Object o)Compares managed factories according to their configuration.Set<ManagedConnectionImpl>getInvalidConnections(Set connectionSet)From a set of managed connections, returns the set of invalid ones.PrintWritergetLogWriter()Gets the log writer of thisManagedConnectionFactoryImplinstance.StringgetName()ResourceAdaptergetResourceAdapter()Returns the resource adapter central authority instance.inthashCode()Returns a code depending on the managed factory configuration.ManagedConnectionmatchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequest)Finds a matching connection from the candidate set of connections and returns aManagedConnectionImplinstance.voidsetLogWriter(PrintWriter out)Sets the log writer for thisManagedConnectionFactoryImplinstance.voidsetResourceAdapter(ResourceAdapter ra)Sets the resource adapter central authority.-
Methods inherited from class org.objectweb.joram.client.connector.ManagedConnectionFactoryConfig
getAsyncSend, getCnxPendingTimer, getConnectingTimer, getHostName, getIdentityClass, getMode, getMultiThreadSync, getMultiThreadSyncDelay, getOutLocalAddress, getOutLocalPort, getPassword, getServerPort, getTxPendingTimer, getUserName, isAsyncSend, isCollocated, isMultiThreadSync, setAsyncSend, setCnxPendingTimer, setCollocated, setConnectingTimer, setHostName, setIdentityClass, setInInterceptors, setManagedConnectionFactoryConfig, setMode, setMultiThreadSync, setMultiThreadSyncDelay, setName, setOutInterceptors, setOutLocalAddress, setOutLocalPort, setParameters, setPassword, setServerPort, setTxPendingTimer, setUserName
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Define serialVersionUID for interoperability.- See Also:
- Constant Field Values
-
logger
private static final Logger logger
-
DEBUG
private static final boolean DEBUG
-
out
protected transient PrintWriter out
Out stream for error logging and tracing.
-
ra
transient JoramResourceAdapter ra
Resource adapter central authority.
-
-
Method Detail
-
createConnectionFactory
public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
Method called by an application server (managed case) for creating anOutboundConnectionFactoryinstance.- Specified by:
createConnectionFactoryin interfaceManagedConnectionFactory- Parameters:
cxManager- Application server's connections pooling manager.- Throws:
ResourceException- Never thrown.
-
createConnectionFactory
public Object createConnectionFactory() throws ResourceException
Method called in the non managed case for creating anOutboundConnectionFactoryinstance.- Specified by:
createConnectionFactoryin interfaceManagedConnectionFactory- Throws:
ResourceException- Never thrown.
-
createFactory
protected XAConnectionFactory createFactory(ConnectionRequestInfo cxRequest) throws ResourceException
- Throws:
ResourceException
-
createXAConnection
protected XAConnection createXAConnection(XAConnectionFactory factory, String userName, String password) throws ResourceException
- Throws:
ResourceException
-
createManagedConnection
public final ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequest) throws ResourceException
Creates a new physical connection to the underlying JORAM server, and returns aManagedConnectionImplinstance for a managed environment.- Specified by:
createManagedConnectionin interfaceManagedConnectionFactory- Parameters:
subject- Security data, not taken into account.cxRequest- User identification data, may benull.- Throws:
CommException- If the JORAM server is not reachable.SecurityException- If the connecting is not allowed.IllegalStateException- If the central Joram adapter state is invalid.ResourceException- If the provided user info is invalid, or if connecting fails for any other reason.
-
matchManagedConnections
public final ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequest) throws ResourceException
Finds a matching connection from the candidate set of connections and returns aManagedConnectionImplinstance.- Specified by:
matchManagedConnectionsin interfaceManagedConnectionFactory- Parameters:
connectionSet- Set of connections to test.subject- Security data, not taken into account.cxRequest- User identification data, may benull.- Throws:
ResourceException- If the provided connection request info is invalid.
-
setLogWriter
public void setLogWriter(PrintWriter out) throws ResourceException
Sets the log writer for thisManagedConnectionFactoryImplinstance.- Specified by:
setLogWriterin interfaceManagedConnectionFactory- Throws:
ResourceException
-
getLogWriter
public PrintWriter getLogWriter() throws ResourceException
Gets the log writer of thisManagedConnectionFactoryImplinstance.- Specified by:
getLogWriterin interfaceManagedConnectionFactory- Throws:
ResourceException
-
getName
public String getName()
- Overrides:
getNamein classManagedConnectionFactoryConfig- Returns:
- the name
-
hashCode
public int hashCode()
Returns a code depending on the managed factory configuration.- Specified by:
hashCodein interfaceManagedConnectionFactory- Overrides:
hashCodein classObject
-
equals
public boolean equals(Object o)
Compares managed factories according to their configuration.- Specified by:
equalsin interfaceManagedConnectionFactory- Overrides:
equalsin classObject
-
getResourceAdapter
public ResourceAdapter getResourceAdapter()
Returns the resource adapter central authority instance.- Specified by:
getResourceAdapterin interfaceResourceAdapterAssociation
-
setResourceAdapter
public void setResourceAdapter(ResourceAdapter ra) throws ResourceException
Sets the resource adapter central authority.- Specified by:
setResourceAdapterin interfaceResourceAdapterAssociation- Throws:
ResourceException- If the adapter could not be set.
-
getInvalidConnections
public Set<ManagedConnectionImpl> getInvalidConnections(Set connectionSet) throws ResourceException
From a set of managed connections, returns the set of invalid ones.- Specified by:
getInvalidConnectionsin interfaceValidatingManagedConnectionFactory- Throws:
ResourceException
-
-