org.codehaus.activemq
Class ActiveMQConnectionFactory

java.lang.Object
  extended byorg.codehaus.activemq.jndi.JNDIBaseStorable
      extended byorg.codehaus.activemq.ActiveMQConnectionFactory
All Implemented Interfaces:
ConnectionFactory, JNDIStorableInterface, QueueConnectionFactory, javax.naming.Referenceable, Service, StatsCapable, TopicConnectionFactory
Direct Known Subclasses:
ActiveMQXAConnectionFactory

public class ActiveMQConnectionFactory
extends JNDIBaseStorable
implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, Service, StatsCapable

A ConnectionFactory is an an Administed object, and is used for creating Connections.

This class also implements QueueConnectionFactory and TopicConnectionFactory and is an Administered object. You can use this connection to create both QueueConnections and TopicConnections.

Version:
$Revision: 1.29 $
See Also:
ConnectionFactory

Field Summary
protected  java.lang.String brokerURL
           
protected  java.lang.String clientID
           
protected static BrokerContainer container
           
protected  java.lang.String password
           
protected  java.lang.String userName
           
 
Constructor Summary
ActiveMQConnectionFactory()
          Default Constructor for ActiveMQConnectionFactory
ActiveMQConnectionFactory(java.lang.String brokerURL)
           
ActiveMQConnectionFactory(java.lang.String userName, java.lang.String password, java.lang.String brokerURL)
           
 
Method Summary
protected  void buildFromProperties(java.util.Properties props)
          Set the properties that will represent the instance in JNDI
protected  BrokerConnector createBrokerConnector(java.lang.String url)
           
 Connection createConnection()
          Create a JMS Connection
 Connection createConnection(java.lang.String userName, java.lang.String password)
           
protected  java.lang.String createMulticastClientID()
          Creates the clientID for the multicast client (used to dispatch local messages over a multicast bus)
 QueueConnection createQueueConnection()
          Create a JMS QueueConnection
 QueueConnection createQueueConnection(java.lang.String userName, java.lang.String password)
           
 TopicConnection createTopicConnection()
          Create a JMS TopicConnection
 TopicConnection createTopicConnection(java.lang.String userName, java.lang.String password)
           
protected  TransportChannel createTransportChannel(java.lang.String theURLString)
          Factory method to create a TransportChannel from a URL
protected  java.net.URI createURI(java.lang.String uri)
           
protected  java.net.URI createURI(java.lang.String protocol, java.net.URI uri)
           
protected  TransportChannel ensureMulticastChannelIsAvailable(java.net.URI remoteLocation, TransportChannel channel, BrokerConnector brokerConnector, boolean created)
           
protected  TransportChannel ensureServerIsAvailable(java.net.URI remoteLocation, TransportChannel channel, BrokerConnector brokerConnector, boolean created)
           
protected  boolean getBoolean(java.util.Properties props, java.lang.String key)
          Helper method to return the property value as a boolean flag
 BrokerContainerFactory getBrokerContainerFactory()
           
 java.lang.String getBrokerURL()
           
 java.lang.String getClientID()
           
protected  BrokerContainer getContainer(java.lang.String brokerName)
           
 JMSStatsImpl getFactoryStats()
           
 java.lang.String getPassword()
           
 Stats getStats()
           
 java.lang.String getUserName()
           
 WireFormat getWireFormat()
           
 boolean isUseEmbeddedBroker()
          Is an embedded broker used by this connection factory
(package private)  void onConnectionClose(ActiveMQConnection connection)
          Called when a connection is closed so that we can shut down any embedded brokers cleanly
(package private)  void onConnectionCreate(ActiveMQConnection connection)
           
protected  void populateProperties(java.util.Properties props)
          Initialize the instance from properties stored in JNDI
static void registerBroker(java.lang.String theURLString, BrokerConnector brokerConnector)
           
 void setBrokerContainerFactory(BrokerContainerFactory brokerContainerFactory)
           
 void setBrokerURL(java.lang.String brokerURL)
           
 void setClientID(java.lang.String clientID)
           
 void setPassword(java.lang.String password)
           
 void setUseEmbeddedBroker(boolean useEmbeddedBroker)
          Allows embedded brokers to be associated with a connection factory
 void setUserName(java.lang.String userName)
           
 void setWireFormat(WireFormat wireFormat)
          Allows a custom wire format to be used; otherwise the default Java wire format is used which is designed for minimum size and maximum speed on the Java platform
 void start()
          Called to start the service
 void stop()
          A hook to allow any embedded JMS Broker's to be closed down
static void unregisterBroker(java.lang.String theURLString)
           
 
Methods inherited from class org.codehaus.activemq.jndi.JNDIBaseStorable
getProperties, getReference, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

container

protected static BrokerContainer container

userName

protected java.lang.String userName

password

protected java.lang.String password

brokerURL

protected java.lang.String brokerURL

clientID

protected java.lang.String clientID
Constructor Detail

ActiveMQConnectionFactory

public ActiveMQConnectionFactory()
Default Constructor for ActiveMQConnectionFactory


ActiveMQConnectionFactory

public ActiveMQConnectionFactory(java.lang.String brokerURL)

ActiveMQConnectionFactory

public ActiveMQConnectionFactory(java.lang.String userName,
                                 java.lang.String password,
                                 java.lang.String brokerURL)
Method Detail

getStats

public Stats getStats()
Specified by:
getStats in interface StatsCapable
Returns:
the Stats for this object

getFactoryStats

public JMSStatsImpl getFactoryStats()

getBrokerURL

public java.lang.String getBrokerURL()
Returns:
Returns the brokerURL.

setBrokerURL

public void setBrokerURL(java.lang.String brokerURL)
Parameters:
brokerURL - The brokerURL to set.

getClientID

public java.lang.String getClientID()
Returns:
Returns the clientID.

setClientID

public void setClientID(java.lang.String clientID)
Parameters:
clientID - The clientID to set.

getPassword

public java.lang.String getPassword()
Returns:
Returns the password.

setPassword

public void setPassword(java.lang.String password)
Parameters:
password - The password to set.

getUserName

public java.lang.String getUserName()
Returns:
Returns the userName.

setUserName

public void setUserName(java.lang.String userName)
Parameters:
userName - The userName to set.

isUseEmbeddedBroker

public boolean isUseEmbeddedBroker()
Is an embedded broker used by this connection factory

Returns:
true if an embedded broker will be used by this connection factory

setUseEmbeddedBroker

public void setUseEmbeddedBroker(boolean useEmbeddedBroker)
Allows embedded brokers to be associated with a connection factory

Parameters:
useEmbeddedBroker -

getWireFormat

public WireFormat getWireFormat()

setWireFormat

public void setWireFormat(WireFormat wireFormat)
Allows a custom wire format to be used; otherwise the default Java wire format is used which is designed for minimum size and maximum speed on the Java platform

Parameters:
wireFormat -

getBrokerContainerFactory

public BrokerContainerFactory getBrokerContainerFactory()

setBrokerContainerFactory

public void setBrokerContainerFactory(BrokerContainerFactory brokerContainerFactory)

buildFromProperties

protected void buildFromProperties(java.util.Properties props)
Set the properties that will represent the instance in JNDI

Specified by:
buildFromProperties in class JNDIBaseStorable
Parameters:
props -

populateProperties

protected void populateProperties(java.util.Properties props)
Initialize the instance from properties stored in JNDI

Specified by:
populateProperties in class JNDIBaseStorable
Parameters:
props -

getBoolean

protected boolean getBoolean(java.util.Properties props,
                             java.lang.String key)
Helper method to return the property value as a boolean flag


createConnection

public Connection createConnection()
                            throws JMSException
Create a JMS Connection

Specified by:
createConnection in interface ConnectionFactory
Returns:
the JMS Connection
Throws:
JMSException - if an error occurs creating the Connection

createConnection

public Connection createConnection(java.lang.String userName,
                                   java.lang.String password)
                            throws JMSException
Specified by:
createConnection in interface ConnectionFactory
Parameters:
userName -
password -
Returns:
the Connection
Throws:
JMSException - if an error occurs creating the Connection

createQueueConnection

public QueueConnection createQueueConnection()
                                      throws JMSException
Create a JMS QueueConnection

Specified by:
createQueueConnection in interface QueueConnectionFactory
Returns:
the JMS QueueConnection
Throws:
JMSException - if an error occurs creating the Connection

createQueueConnection

public QueueConnection createQueueConnection(java.lang.String userName,
                                             java.lang.String password)
                                      throws JMSException
Specified by:
createQueueConnection in interface QueueConnectionFactory
Parameters:
userName -
password -
Returns:
the QueueConnection
Throws:
JMSException - if an error occurs creating the Connection

createTopicConnection

public TopicConnection createTopicConnection()
                                      throws JMSException
Create a JMS TopicConnection

Specified by:
createTopicConnection in interface TopicConnectionFactory
Returns:
the JMS TopicConnection
Throws:
JMSException - if an error occurs creating the Connection

createTopicConnection

public TopicConnection createTopicConnection(java.lang.String userName,
                                             java.lang.String password)
                                      throws JMSException
Specified by:
createTopicConnection in interface TopicConnectionFactory
Parameters:
userName -
password -
Returns:
the TopicConnection
Throws:
JMSException - if an error occurs creating the Connection

start

public void start()
           throws JMSException
Description copied from interface: Service
Called to start the service

Specified by:
start in interface Service
Throws:
JMSException

stop

public void stop()
          throws JMSException
A hook to allow any embedded JMS Broker's to be closed down

Specified by:
stop in interface Service
Throws:
JMSException

createTransportChannel

protected TransportChannel createTransportChannel(java.lang.String theURLString)
                                           throws JMSException
Factory method to create a TransportChannel from a URL

Throws:
JMSException

registerBroker

public static void registerBroker(java.lang.String theURLString,
                                  BrokerConnector brokerConnector)

unregisterBroker

public static void unregisterBroker(java.lang.String theURLString)

getContainer

protected BrokerContainer getContainer(java.lang.String brokerName)
                                throws JMSException
Throws:
JMSException

createBrokerConnector

protected BrokerConnector createBrokerConnector(java.lang.String url)
                                         throws JMSException
Throws:
JMSException

ensureServerIsAvailable

protected TransportChannel ensureServerIsAvailable(java.net.URI remoteLocation,
                                                   TransportChannel channel,
                                                   BrokerConnector brokerConnector,
                                                   boolean created)
                                            throws JMSException
Throws:
JMSException

ensureMulticastChannelIsAvailable

protected TransportChannel ensureMulticastChannelIsAvailable(java.net.URI remoteLocation,
                                                             TransportChannel channel,
                                                             BrokerConnector brokerConnector,
                                                             boolean created)
                                                      throws JMSException
Throws:
JMSException

createMulticastClientID

protected java.lang.String createMulticastClientID()
Creates the clientID for the multicast client (used to dispatch local messages over a multicast bus)


createURI

protected java.net.URI createURI(java.lang.String protocol,
                                 java.net.URI uri)
                          throws JMSException
Throws:
JMSException

createURI

protected java.net.URI createURI(java.lang.String uri)
                          throws JMSException
Throws:
JMSException

onConnectionClose

void onConnectionClose(ActiveMQConnection connection)
                 throws JMSException
Called when a connection is closed so that we can shut down any embedded brokers cleanly

Parameters:
connection -
Throws:
JMSException

onConnectionCreate

void onConnectionCreate(ActiveMQConnection connection)


Copyright © 2004 Protique, Ltd.. All Rights Reserved.