com.safmq
Class MQBuilder

java.lang.Object
  extended by com.safmq.MQBuilder

public class MQBuilder
extends java.lang.Object

A static builder class which builds connections to SAFMQ servers and message queues.

In the case that a connection to a queue server is sought, use the method MQBuilder.buildConnection(String url, String user, String password). This method will evaluate the URL and create a new connection to the queue server.

In the case that a connection to a message queue is sought, the use the method MQBuilder.buildMessageQueue(String url, String user, String password). This method will evaluate the URL and create a new connection tot he queue server and wrap that connection with a MessageQueue instance.


Field Summary
static int DEF_PORT
          The number of the default port for SAFMQ servers.
static int DEF_SSL_PORT
           
static java.lang.String SAFMQ_PROTO
           
static java.lang.String SAFMQ_SSL_PROTO
           
 
Constructor Summary
MQBuilder()
           
 
Method Summary
static MQConnection buildConnection(java.net.URI uri, java.lang.String user, java.lang.String password)
          Constructs a MQConnection connection object connected to a SAFMQ server.
static MQConnection buildConnection(java.net.URI uri, java.lang.String user, java.lang.String password, javax.net.ssl.SSLContext ctx)
          Constructs a MQConnection connection object connected to a SAFMQ server.
static MessageQueue buildMessageQueue(java.net.URI uri, java.lang.String user, java.lang.String password)
          Constructs a new MQConnection connection object and then a MessageQueue to wrap it.
static MessageQueue buildMessageQueue(java.net.URI uri, java.lang.String user, java.lang.String password, javax.net.ssl.SSLContext ctx)
          Constructs a new MQConnection connection object and then a MessageQueue to wrap it.
static void setSSLContext(javax.net.ssl.SSLContext ctx)
          Sets the SSLContext object for use in SSL communications.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_PORT

public static final int DEF_PORT
The number of the default port for SAFMQ servers.

See Also:
Constant Field Values

DEF_SSL_PORT

public static final int DEF_SSL_PORT
See Also:
Constant Field Values

SAFMQ_PROTO

public static final java.lang.String SAFMQ_PROTO
See Also:
Constant Field Values

SAFMQ_SSL_PROTO

public static final java.lang.String SAFMQ_SSL_PROTO
See Also:
Constant Field Values
Constructor Detail

MQBuilder

public MQBuilder()
Method Detail

buildConnection

public static MQConnection buildConnection(java.net.URI uri,
                                           java.lang.String user,
                                           java.lang.String password)
                                    throws MQException,
                                           java.io.IOException
Constructs a MQConnection connection object connected to a SAFMQ server.

Parameters:
uri - The URI of the message queue object in the format: protocol://user:password@server-name:port/ where the ":port" , "user", and "password" portion of the url is optional. Valid selections for "protocol" are "safmq" for a clear text connection and "safmqs" for a SSL encrypted connection.
user - [optional] The name of the user which is connecting to the server, used if not specified in the uri
password - [optional] The password of the user which is connecting to the server, used if not specified in the uri
Returns:
A valid MQConnection connection object connected to a SAFMQ server.
Throws:
MQException - In the case that the server refuses the supplied login credintials, or in the case that the URL could not be correctly parsed. See MQConnection.MQConnection(String,int,String,String) for details on connection errors.
java.io.IOException - In the case that there is a network error attempting to connect to the server via the TCP/IP network.
See Also:
MQConnection.MQConnection(Socket,String,String)

buildConnection

public static MQConnection buildConnection(java.net.URI uri,
                                           java.lang.String user,
                                           java.lang.String password,
                                           javax.net.ssl.SSLContext ctx)
                                    throws MQException,
                                           java.io.IOException
Constructs a MQConnection connection object connected to a SAFMQ server.

Parameters:
uri - The URI of the message queue object in the format: protocol://user:password@server-name:port/ where the ":port" , "user", and "password" portion of the url is optional. Valid selections for "protocol" are "safmq" for a clear text connection and "safmqs" for a SSL encrypted connection.
user - [optional] The name of the user which is connecting to the server, used if not specified in the uri
password - [optional] The password of the user which is connecting to the server, used if not specified in the uri
ctx - [optional] A SSLContext to use when connecting via SSL. This will override the contex set by calling MQCOnnection.setSSLContext(SSLContext).
Returns:
A valid MQConnection connection object connected to a SAFMQ server.
Throws:
MQException - In the case that the server refuses the supplied login credintials, or in the case that the URL could not be correctly parsed. See MQConnection.MQConnection(String,int,String,String) for details on connection errors.
java.io.IOException - In the case that there is a network error attempting to connect to the server via the TCP/IP network.
See Also:
MQConnection.MQConnection(Socket,String,String)

buildMessageQueue

public static MessageQueue buildMessageQueue(java.net.URI uri,
                                             java.lang.String user,
                                             java.lang.String password)
                                      throws MQException,
                                             java.io.IOException
Constructs a new MQConnection connection object and then a MessageQueue to wrap it.

Parameters:
uri - The URI of the message queue object in the format: protocol://user:password@server-name:port/queue where the ":port" , "user", and "password" portion of the url is optional. Valid selections for "protocol" are "safmq" for a clear text connection and "safmqs" for a SSL encrypted connection.
user - [optional] The name of the user which is connecting to the server, used if not specified in the uri
password - [optional] The password of the user which is connecting to the server, used if not specified in the uri
Returns:
A valid MessageQueue connected to a message queue on a SAFMQ server.
Throws:
MQException - In the case that the server refuses the supplied login credintials, or in the case that the URL could not be correctly parsed. See errors from MQConnection(String,String,String) and MQConnection.OpenQueue(String,QueueHandle).
java.io.IOException - In the case that there is a network error attempting to connect to the server via the TCP/IP network.
See Also:
MQConnection.MQConnection(Socket,String,String), MQConnection.OpenQueue(String,QueueHandle)

buildMessageQueue

public static MessageQueue buildMessageQueue(java.net.URI uri,
                                             java.lang.String user,
                                             java.lang.String password,
                                             javax.net.ssl.SSLContext ctx)
                                      throws MQException,
                                             java.io.IOException
Constructs a new MQConnection connection object and then a MessageQueue to wrap it.

Parameters:
uri - The URI of the message queue object in the format: protocol://user:password@server-name:port/queue where the ":port" , "user", and "password" portion of the url is optional. Valid selections for "protocol" are "safmq" for a clear text connection and "safmqs" for a SSL encrypted connection.
user - [optional] The name of the user which is connecting to the server, used if not specified in the uri
password - [optional] The password of the user which is connecting to the server, used if not specified in the uri
ctx - [optional] A SSLContext to use when connecting via SSL. This will override the contex set by calling MQCOnnection.setSSLContext(SSLContext).
Returns:
A valid MessageQueue connected to a message queue on a SAFMQ server.
Throws:
MQException - In the case that the server refuses the supplied login credintials, or in the case that the URL could not be correctly parsed. See errors from MQConnection(String,String,String) and MQConnection.OpenQueue(String,QueueHandle).
java.io.IOException - In the case that there is a network error attempting to connect to the server via the TCP/IP network.
See Also:
MQConnection.MQConnection(Socket,String,String), MQConnection.OpenQueue(String,QueueHandle)

setSSLContext

public static void setSSLContext(javax.net.ssl.SSLContext ctx)
Sets the SSLContext object for use in SSL communications. Using an SSL context allows the client program to determine certificate verification routines, and provide a client certificate to the server.

Parameters:
ctx - The SSLContext to use. Specifying null will cause the use of the default SSLContext.

Copyright Matthew J. Battey, 2004-2010;
Powered By: Get SAFMQ: Store and Forward Message Queue at SourceForge.net. Fast, secure and Free Open Source software downloads