Class ClusterConnectionFactory
- java.lang.Object
-
- org.objectweb.joram.client.jms.admin.AdministeredObject
-
- org.objectweb.joram.client.jms.admin.ClusterConnectionFactory
-
- All Implemented Interfaces:
Serializable,ConnectionFactory,Referenceable
public class ClusterConnectionFactory extends AdministeredObject implements ConnectionFactory
A base class for clustered connection factories.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Hashtable<String,ConnectionFactory>clusterprivate static org.objectweb.util.monolog.api.Loggerloggerprivate static longserialVersionUIDdefine serialVersionUID for interoperability-
Fields inherited from class org.objectweb.joram.client.jms.admin.AdministeredObject
rand
-
-
Constructor Summary
Constructors Constructor Description ClusterConnectionFactory()Constructs an empty clustered connection factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnectionFactory(String location, ConnectionFactory cf)Adds a connection factory to the cluster with the specifiedlocationkey.voidaddConnectionFactory(ConnectionFactory cf)Adds a connection factory to the cluster.ConnectioncreateConnection()Creates a connection with the default user identity.ConnectioncreateConnection(String name, String password)Creates a connection with the specified user identity.JMSContextcreateContext()JMSContextcreateContext(int sessionMode)JMSContextcreateContext(String userName, String password)JMSContextcreateContext(String userName, String password, int sessionMode)voidfromReference(Reference ref)Restores the administered object from a naming reference.Hashtable<String,ConnectionFactory>getCluster()protected ConnectionFactorygetConnectionFactory()Chooses a connection factory from the cluster definition.voidtoReference(Reference ref)Sets the naming reference of an administered object.StringtoString()Returns a String image of the object.-
Methods inherited from class org.objectweb.joram.client.jms.admin.AdministeredObject
getReference
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
logger
private static final org.objectweb.util.monolog.api.Logger logger
-
cluster
protected Hashtable<String,ConnectionFactory> cluster
-
-
Method Detail
-
addConnectionFactory
public void addConnectionFactory(ConnectionFactory cf)
Adds a connection factory to the cluster. The object will be added with a key equals to the location property. By default, the location value is set to the hostname of corresponding server. Be careful, the object should be rebind after modification.- Parameters:
cf- the ConnectionFactory
-
addConnectionFactory
public void addConnectionFactory(String location, ConnectionFactory cf)
Adds a connection factory to the cluster with the specifiedlocationkey. Be careful, the object should be rebind after modification.- Parameters:
location- the location keycf- the ConnectionFactory
-
getConnectionFactory
protected ConnectionFactory getConnectionFactory()
Chooses a connection factory from the cluster definition.
-
createConnection
public final Connection createConnection() throws JMSException
Creates a connection with the default user identity. It chooses aConnectionFactorydepending of the location property, then creates the relatedConnection. API method, see javax.jms.ConnectionFactory.- Specified by:
createConnectionin interfaceConnectionFactory- Throws:
JMSSecurityException- If the default identification is incorrect.IllegalStateException- If the server is not listening.JMSException
-
createConnection
public final Connection createConnection(String name, String password) throws JMSException
Creates a connection with the specified user identity. It chooses aConnectionFactorydepending of the location property, then creates the relatedConnection. API method, see javax.jms.ConnectionFactory.- Specified by:
createConnectionin interfaceConnectionFactory- Parameters:
name- the caller's user namepassword- the caller's password- Throws:
JMSSecurityException- If the user identification is incorrect.IllegalStateException- If the server is not listening.JMSException
-
toString
public String toString()
Returns a String image of the object.
-
getCluster
public Hashtable<String,ConnectionFactory> getCluster()
- Returns:
- the cluster hashtable.
-
toReference
public void toReference(Reference ref) throws NamingException
Sets the naming reference of an administered object.- Specified by:
toReferencein classAdministeredObject- Throws:
NamingException
-
fromReference
public void fromReference(Reference ref) throws NamingException
Restores the administered object from a naming reference.- Specified by:
fromReferencein classAdministeredObject- Throws:
NamingException
-
createContext
public JMSContext createContext()
- Specified by:
createContextin interfaceConnectionFactory
-
createContext
public JMSContext createContext(String userName, String password)
- Specified by:
createContextin interfaceConnectionFactory
-
createContext
public JMSContext createContext(String userName, String password, int sessionMode)
- Specified by:
createContextin interfaceConnectionFactory
-
createContext
public JMSContext createContext(int sessionMode)
- Specified by:
createContextin interfaceConnectionFactory
-
-