org.robokind.impl.messaging.utils
Class ConnectionManager

java.lang.Object
  extended by org.robokind.impl.messaging.utils.ConnectionManager

public class ConnectionManager
extends Object

Utility methods for creating JMS Connections and Destinations and managing them within the OSGi Service Registry. AMQP/Qpid is used for creating the connections and destinations.

Author:
Matthew Stevenson

Field Summary
static String PROP_CONNECTION_ID
          Property name for a Connection's unique id within the OSGi Service Registry.
static String PROP_DESTINATION_ID
          Property name for a Destination's unique id within the OSGi Service Registry.
 
Constructor Summary
ConnectionManager()
           
 
Method Summary
static String createAMQPConnectionURL(String username, String password, String clientName, String virtualHost, String tcpAddress)
          Formats an AMQP connection URL from the given details.
static javax.jms.Connection createConnection(String amqpURL)
          Creates an JMS Connection from the given connection URL
static javax.jms.Connection createConnection(String username, String password, String clientName, String virtualHost, String tcpAddress)
          Create a JMS Connection from the given details.
static javax.jms.Destination createDestination(String destinationStr)
          Creates a JMS Destination from the given destination String
static javax.jms.Destination createQueue(String destinationStr)
           
static javax.jms.Destination createTopic(String destinationStr)
           
static org.osgi.framework.ServiceRegistration registerConnection(org.osgi.framework.BundleContext context, String connectionId, javax.jms.Connection connection, Properties props)
          Registers a JMS Connection to OSGi Service Registry, using a unique id.
static org.osgi.framework.ServiceRegistration registerDestination(org.osgi.framework.BundleContext context, String destinationId, javax.jms.Destination destination, Properties props)
          Registers a JMS Connection to OSGi Service Registry, using a unique id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_CONNECTION_ID

public static final String PROP_CONNECTION_ID
Property name for a Connection's unique id within the OSGi Service Registry.

See Also:
Constant Field Values

PROP_DESTINATION_ID

public static final String PROP_DESTINATION_ID
Property name for a Destination's unique id within the OSGi Service Registry.

See Also:
Constant Field Values
Constructor Detail

ConnectionManager

public ConnectionManager()
Method Detail

createAMQPConnectionURL

public static String createAMQPConnectionURL(String username,
                                             String password,
                                             String clientName,
                                             String virtualHost,
                                             String tcpAddress)
Formats an AMQP connection URL from the given details.

Parameters:
username - broker username
password - broker password
clientName - connection client name
virtualHost - connection virtual host
tcpAddress - broker tcp address
Returns:
AMQP connection URL

createConnection

public static javax.jms.Connection createConnection(String username,
                                                    String password,
                                                    String clientName,
                                                    String virtualHost,
                                                    String tcpAddress)
Create a JMS Connection from the given details.

Parameters:
username - broker username
password - broker password
clientName - connection client name
virtualHost - connection virtual host
tcpAddress - broker tcp address
Returns:
JMS Connection

createConnection

public static javax.jms.Connection createConnection(String amqpURL)
Creates an JMS Connection from the given connection URL

Parameters:
amqpURL - AMQP connection URL for the broker
Returns:
JMS Connection created with the given URL

createDestination

public static javax.jms.Destination createDestination(String destinationStr)
Creates a JMS Destination from the given destination String

Parameters:
destinationStr - destination String defining a JMS Destination
Returns:
JMS Destination

createQueue

public static javax.jms.Destination createQueue(String destinationStr)

createTopic

public static javax.jms.Destination createTopic(String destinationStr)

registerConnection

public static org.osgi.framework.ServiceRegistration registerConnection(org.osgi.framework.BundleContext context,
                                                                        String connectionId,
                                                                        javax.jms.Connection connection,
                                                                        Properties props)
Registers a JMS Connection to OSGi Service Registry, using a unique id.

Parameters:
context - BundleContext for OSGi
connectionId - unique id for registering the connection
connection - the JMS Connection to register
props - optional OSGi registration properties
Returns:
ServiceRegistration for the connection, null if the id is already in use or some other registration error occurred

registerDestination

public static org.osgi.framework.ServiceRegistration registerDestination(org.osgi.framework.BundleContext context,
                                                                         String destinationId,
                                                                         javax.jms.Destination destination,
                                                                         Properties props)
Registers a JMS Connection to OSGi Service Registry, using a unique id.

Parameters:
context - BundleContext for OSGi
destinationId - unique id for registering the destination
destination - the JMS Destination to register
props - optional OSGi registration properties
Returns:
ServiceRegistration for the destination, null if the id is already in use or some other registration error occurred


Copyright © 2011-2013. All Rights Reserved.