org.apache.wsif.util.jms
Class WSIFJMSDestination

java.lang.Object
  extended by org.apache.wsif.util.jms.WSIFJMSDestination
Direct Known Subclasses:
JMS2HTTPBridgeDestination

public class WSIFJMSDestination
extends java.lang.Object

A WSIFJMSDestination is a pair of queues, one that read from and the other that is written to. This class provides various methods for different flavours of reading and writing messages to those queues. This class hides the JMS interface.

Author:
Mark Whitlock

Constructor Summary
WSIFJMSDestination(WSIFJMSFinder finder)
          Public constructor.
WSIFJMSDestination(WSIFJMSFinder finder, long timeout)
          Public constructor.
WSIFJMSDestination(WSIFJMSFinder finder, java.lang.String altDestName, long timeout)
          Public constructor.
 
Method Summary
 void close()
          Close all objects.
 javax.jms.Message createMessage(int msgType)
           
static javax.jms.Message createMessage(javax.jms.Session session, int msgType)
           
 java.lang.String deep()
           
 void finalize()
          close the destination at finalize.
static JMSAddress getJMSAddressFromURL(java.lang.String url)
          Create a JMSAddress extensability element from a URL string The URL string would normally be from the WSDL soap:address location attribute.
 java.util.HashMap getProperties()
          Gets all the JMS properties from the previous message that was received.
 java.lang.Object getProperty(java.lang.String name)
          Gets a JMS property from the previous message that was received.
 java.lang.String receive()
          Blocking receive for the wsif.syncrequest.timeout
 javax.jms.Message receive(java.lang.String id)
          Blocking receive waits for a message for the wsif.syncrequest.timeout
 javax.jms.Message receive(java.lang.String id, long timeout)
          Blocking receive waits for a message for the specified timeout
 java.lang.String receiveString(java.lang.String id)
          Blocking receive for the wsif.syncrequest.timeout
 java.lang.String receiveString(java.lang.String id, long timeout)
          Blocking receive waits for the specified timeout
 java.lang.String send(javax.jms.Message msg, java.lang.String id, boolean setReplyTo)
          Sends a message to the write queue.
 java.lang.String send(java.io.Serializable data)
          Send a message to the write queue
 java.lang.String send(java.io.Serializable data, java.lang.String id)
          Send a message to the write queue
 java.lang.String send(java.lang.String data)
          Send a message to the write queue
 java.lang.String send(java.lang.String data, java.lang.String id)
          Send a message to the write queue
 void setAsyncMode(boolean b)
          Sets if this destination is to be used for asynchronous requests.
 void setLastMessage(javax.jms.Message msg)
          The last message is the most recent message that was received by this WSIFJMSDestination.
 void setProperties(java.util.HashMap propMap)
          Sets a HashMap of JMS property value pairs.
 void setProperty(java.lang.String name, java.lang.Object value)
          Sets a JMS property to a value.
 void setReplyToQueue()
          Set the replyTo queue to a temporary queue.
 void setReplyToQueue(java.lang.String replyTo)
          Set the replyTo queue.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSIFJMSDestination

public WSIFJMSDestination(WSIFJMSFinder finder)
                   throws WSIFException
Public constructor.

Parameters:
finder - used to find JMS objects.
Throws:
WSIFException

WSIFJMSDestination

public WSIFJMSDestination(WSIFJMSFinder finder,
                          long timeout)
                   throws WSIFException
Public constructor.

Parameters:
finder - used to find JMS objects.
timeout - is the maximum time to wait on a synchronous receive
Throws:
WSIFException

WSIFJMSDestination

public WSIFJMSDestination(WSIFJMSFinder finder,
                          java.lang.String altDestName,
                          long timeout)
                   throws WSIFException
Public constructor.

Parameters:
finder - used to find JMS objects.
altdestName - is an alterative JMS provider destination name
timeout - is the maximum time to wait on a synchronous receive
Throws:
WSIFException
Method Detail

close

public void close()
           throws WSIFException
Close all objects.

Throws:
WSIFException

finalize

public void finalize()
              throws WSIFException
close the destination at finalize.

Overrides:
finalize in class java.lang.Object
Throws:
WSIFException

send

public java.lang.String send(java.lang.String data)
                      throws WSIFException
Send a message to the write queue

Parameters:
data - is the message
Returns:
the id of the message that was sent.
Throws:
WSIFException

send

public java.lang.String send(java.lang.String data,
                             java.lang.String id)
                      throws WSIFException
Send a message to the write queue

Parameters:
data - is the message
id - is the correlation id to set on the message
Returns:
the id of the message that was sent.
Throws:
WSIFException

send

public java.lang.String send(java.io.Serializable data)
                      throws WSIFException
Send a message to the write queue

Parameters:
data - is the message
Returns:
the id of the message that was sent.
Throws:
WSIFException

send

public java.lang.String send(java.io.Serializable data,
                             java.lang.String id)
                      throws WSIFException
Send a message to the write queue

Parameters:
data - is the message
id - is the correlation id to set on the message
Returns:
the id of the message that was sent.
Throws:
WSIFException

send

public java.lang.String send(javax.jms.Message msg,
                             java.lang.String id,
                             boolean setReplyTo)
                      throws WSIFException
Sends a message to the write queue.

Parameters:
message -
id - Correlation id
setReplyTo - If true JMSReplyTo is always set. If false JMSReplyTo is only set if the ReplyTo was explicitly set as a property.
Throws:
WSIFException

receive

public java.lang.String receive()
                         throws WSIFException
Blocking receive for the wsif.syncrequest.timeout

Returns:
the received message
Throws:
WSIFException

receiveString

public java.lang.String receiveString(java.lang.String id)
                               throws WSIFException
Blocking receive for the wsif.syncrequest.timeout

Returns:
the received message
Throws:
WSIFException

receiveString

public java.lang.String receiveString(java.lang.String id,
                                      long timeout)
                               throws WSIFException
Blocking receive waits for the specified timeout

Returns:
the received message
Throws:
WSIFException

receive

public javax.jms.Message receive(java.lang.String id)
                          throws WSIFException
Blocking receive waits for a message for the wsif.syncrequest.timeout

Parameters:
id - is the correlation id that the received message must have
Returns:
the received message
Throws:
WSIFException

receive

public javax.jms.Message receive(java.lang.String id,
                                 long timeout)
                          throws WSIFException
Blocking receive waits for a message for the specified timeout

Parameters:
id - is the correlation id that the received message must have
timeout - how long in milliseconds to wait
Returns:
the received message
Throws:
WSIFException

setReplyToQueue

public void setReplyToQueue()
                     throws WSIFException
Set the replyTo queue to a temporary queue.

Throws:
WSIFException

setReplyToQueue

public void setReplyToQueue(java.lang.String replyTo)
                     throws WSIFException
Set the replyTo queue.

Parameters:
replyTo - queue name.
Throws:
WSIFException

setAsyncMode

public void setAsyncMode(boolean b)
                  throws WSIFException
Sets if this destination is to be used for asynchronous requests. If this destination is to be used for asynchronous requests then a WSIFJMSAsyncListener will be created to listen for the async responses.

Parameters:
b - true if this destination is to be used for asynchronous requests, otherwise false.
Throws:
WSIFException

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws WSIFException
Sets a JMS property to a value. This property value will be only be used for the next message that is sent, then the property will be reset.

Throws:
WSIFException

setProperties

public void setProperties(java.util.HashMap propMap)
Sets a HashMap of JMS property value pairs. The property values will be only be used for the next message that is sent, then all the properties will be reset.


getProperty

public java.lang.Object getProperty(java.lang.String name)
                             throws WSIFException
Gets a JMS property from the previous message that was received.

Throws:
WSIFException

getProperties

public java.util.HashMap getProperties()
                                throws WSIFException
Gets all the JMS properties from the previous message that was received.

Throws:
WSIFException

createMessage

public static javax.jms.Message createMessage(javax.jms.Session session,
                                              int msgType)
                                       throws WSIFException
Throws:
WSIFException

createMessage

public javax.jms.Message createMessage(int msgType)
                                throws WSIFException
Throws:
WSIFException

setLastMessage

public void setLastMessage(javax.jms.Message msg)
The last message is the most recent message that was received by this WSIFJMSDestination. The getProperty(s) methods return the properties that are on the lastMessage. The works fine for sync, but for async user code will have received the message. So the provider must inform the WSIFJMSDestination about the lastMessage explicitly so it can inquire correctly about any jms properties on it.


deep

public java.lang.String deep()

getJMSAddressFromURL

public static JMSAddress getJMSAddressFromURL(java.lang.String url)
                                       throws WSIFException
Create a JMSAddress extensability element from a URL string The URL string would normally be from the WSDL soap:address location attribute. The format of the URL is: jms:/[queue|topic]?=|=|... Valid properties are: destination The JNDI name of the destination queue or topic. connectionFactory The JNDI name of the connection factory. targetService The name of the deployed service to which the request will be dispatched. JNDI-related Properties (optional) initialContextFactory The name of the initial context factory to use (this is mapped to the java.naming.factory.initial property) jndiProviderURL The JNDI provider URL (this is mapped to the java.naming.provider.url property) JMS-related Properties (optional) deliveryMode An indication as to whether the request message should be persistent or not. The valid values are DeliveryMode.NON_PERSISTENT (default) and DeliveryMode.PERSISTENT. timeToLive The lifetime (in milliseconds) of the request message. A value of 0 indicates an infinite lifetime. priority The JMS priority associated with the request message Valid values are 0 to 9. The default value is 4 userid The userid to be used to gain access to the connection factory. password The password to be used to gain access to the connection factory.

Parameters:
url - the URL string
Returns:
JMSAddress the new JMSAddress created from the URL
Throws:
WSIFException


Copyright ? 2002, 2006 Apache XML Project. All Rights Reserved.