org.apache.jetspeed.services.messaging.jms
Class AbstractJMSMessagingService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.jetspeed.services.messaging.jms.AbstractJMSMessagingService
All Implemented Interfaces:
org.apache.turbine.services.Initable, MessagingService, org.apache.turbine.services.Service
Direct Known Subclasses:
MessagingServiceImpl

public abstract class AbstractJMSMessagingService
extends org.apache.turbine.services.TurbineBaseService
implements MessagingService

This class provides basic functionality for accessing the JMS server. This implementation conforms to the JMS 1.1 specification. New implementations of a JMS Messaging Service should extend this class and implement the createConnection method. Also, any default variables that need to be set should be added to a default constructor.

Version:
$Id: AbstractJMSMessagingService.java,v 1.3 2004/08/28 19:01:53 jford Exp $
Author:
Jeremy Ford

Field Summary
protected  int ackMode
           
protected static java.lang.String AUTO_ACKNOWLEDGE
           
protected static java.lang.String CLIENT_ACKNOWLEDGE
           
protected static java.lang.String CONFIG_ACK_MODE
           
protected static java.lang.String CONFIG_CONNECTION_FACTORY
           
protected static java.lang.String CONFIG_DELIVERY_MODE
           
protected static java.lang.String CONFIG_DURABLE
           
protected static java.lang.String CONFIG_HOST
           
protected static java.lang.String CONFIG_NAME
           
protected static java.lang.String CONFIG_NOLOCAL
           
protected static java.lang.String CONFIG_PORT
           
protected static java.lang.String CONFIG_PRIORITY
           
protected static java.lang.String CONFIG_SCHEME
           
protected static java.lang.String CONFIG_TIME_TO_LIVE
           
protected static java.lang.String CONFIG_TOPIC
           
protected static java.lang.String CONFIG_TRANSACTED
           
protected static java.lang.String CONFIG_URL
           
protected  javax.jms.Connection connection
           
protected  java.lang.String connectionFactory
           
protected  java.util.Hashtable consumers
           
protected  int DEFAULT_ACK_MODE
           
protected  java.lang.String DEFAULT_CONNECTION_FACTORY
           
protected  int DEFAULT_DELIVERY_MODE
           
protected  boolean DEFAULT_DURABLE
           
protected  java.lang.String DEFAULT_HOST
           
protected  java.lang.String DEFAULT_NAME
           
protected  boolean DEFAULT_NOLOCAL
           
protected  java.lang.String DEFAULT_PORT
           
protected  int DEFAULT_PRIORITY
           
protected  java.lang.String DEFAULT_SCHEME
           
protected  int DEFAULT_TIME_TO_LIVE
           
protected  boolean DEFAULT_TOPIC
           
protected  boolean DEFAULT_TRANSACTED
           
protected  java.lang.String DEFAULT_URL
           
protected  int deliveryMode
           
protected  java.util.Hashtable destinations
           
protected static java.lang.String DUPS_OK_ACKNOWLEDGE
           
protected  boolean durable
           
protected  java.lang.String host
           
protected  java.lang.String initialContextFactory
           
protected  java.lang.String name
           
protected  boolean nolocal
           
protected static java.lang.String NON_PERSISTENT
           
protected static java.lang.String PERSISTENT
           
protected  java.lang.String port
           
protected  int priority
           
protected  java.util.Hashtable producers
           
protected  java.lang.String scheme
           
protected  javax.jms.Session session
           
protected  int timeToLive
           
protected  boolean transacted
           
protected  java.lang.String url
           
protected  boolean use_topic
           
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.jetspeed.services.messaging.MessagingService
BYTE_MESSAGE, GROUP_UPDATE_SUBJECT, MAP_MESSAGE, MESSAGE, OBJECT_MESSAGE, PSML_UPDATE_SUBJECT, REGISTRY_UPDATE_SUBJECT, ROLE_UPDATE_SUBJECT, SECURITY_CACHE_UPDATE_SUBJECT, SECURITY_UPDATE_SUBJECT, SERVICE_NAME, STREAM_MESSAGE, TEXT_MESSAGE, USER_UPDATE_SUBJECT
 
Fields inherited from interface org.apache.turbine.services.Service
SERVICE_NAME
 
Constructor Summary
AbstractJMSMessagingService()
           
 
Method Summary
 void addMessageListener(javax.jms.MessageListener listener, java.lang.String id, java.lang.String destination)
          This method creates a new consumer if one with the given id has not been created.
protected abstract  void createConnection()
          Create the connection the the JMS Server
 javax.jms.MessageConsumer createConsumer(java.lang.String destination)
          This method creates a new MessageConsumer.
 javax.jms.Message createMessage(int messageType)
          Create a message based on the give type
protected  void createSession()
          Create the JMS Session
protected  javax.naming.Context getContext()
          Genereate a JNDI context using the context factory and the provider url
protected  javax.jms.Destination getDestination(java.lang.String destination)
           
protected  javax.jms.MessageProducer getProducer(java.lang.String destination)
          Return the producer based on the given destination.
protected  java.lang.String getProviderURL()
          Return the url if it was configured, othewise, generate the url from the scheme, host, port, and name properties
 void init(javax.servlet.ServletConfig conf)
          This is the early initialization method called by the Turbine Service framework
protected  void initJMSConfiguration()
          Initialize the JMS Configuration
protected  java.lang.String printAckMode()
          Helper method to print the acknowledgement mode
protected  java.lang.String printDeliveryMode()
          Helper method to print the delivery mode
 void removeMessageListener(java.lang.String id)
          Remove a message listener that was added to the service previously via the addMessageListener method.
 void sendMessage(javax.jms.Message message, java.lang.String destination)
          Send a message to the chose destination
 void shutdown()
          This is the shutdown method called by the Turbine Service framework
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, init
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, setInitableBroker
 

Field Detail

CONFIG_SCHEME

protected static final java.lang.String CONFIG_SCHEME
See Also:
Constant Field Values

CONFIG_HOST

protected static final java.lang.String CONFIG_HOST
See Also:
Constant Field Values

CONFIG_PORT

protected static final java.lang.String CONFIG_PORT
See Also:
Constant Field Values

CONFIG_NAME

protected static final java.lang.String CONFIG_NAME
See Also:
Constant Field Values

CONFIG_URL

protected static final java.lang.String CONFIG_URL
See Also:
Constant Field Values

CONFIG_CONNECTION_FACTORY

protected static final java.lang.String CONFIG_CONNECTION_FACTORY
See Also:
Constant Field Values

CONFIG_TRANSACTED

protected static final java.lang.String CONFIG_TRANSACTED
See Also:
Constant Field Values

CONFIG_ACK_MODE

protected static final java.lang.String CONFIG_ACK_MODE
See Also:
Constant Field Values

CONFIG_TOPIC

protected static final java.lang.String CONFIG_TOPIC
See Also:
Constant Field Values

CONFIG_DURABLE

protected static final java.lang.String CONFIG_DURABLE
See Also:
Constant Field Values

CONFIG_NOLOCAL

protected static final java.lang.String CONFIG_NOLOCAL
See Also:
Constant Field Values

CONFIG_DELIVERY_MODE

protected static final java.lang.String CONFIG_DELIVERY_MODE
See Also:
Constant Field Values

CONFIG_PRIORITY

protected static final java.lang.String CONFIG_PRIORITY
See Also:
Constant Field Values

CONFIG_TIME_TO_LIVE

protected static final java.lang.String CONFIG_TIME_TO_LIVE
See Also:
Constant Field Values

DEFAULT_SCHEME

protected java.lang.String DEFAULT_SCHEME

DEFAULT_HOST

protected java.lang.String DEFAULT_HOST

DEFAULT_PORT

protected java.lang.String DEFAULT_PORT

DEFAULT_NAME

protected java.lang.String DEFAULT_NAME

DEFAULT_URL

protected java.lang.String DEFAULT_URL

DEFAULT_CONNECTION_FACTORY

protected java.lang.String DEFAULT_CONNECTION_FACTORY

DEFAULT_TRANSACTED

protected boolean DEFAULT_TRANSACTED

DEFAULT_ACK_MODE

protected int DEFAULT_ACK_MODE

DEFAULT_TOPIC

protected boolean DEFAULT_TOPIC

DEFAULT_DURABLE

protected boolean DEFAULT_DURABLE

DEFAULT_NOLOCAL

protected boolean DEFAULT_NOLOCAL

DEFAULT_DELIVERY_MODE

protected int DEFAULT_DELIVERY_MODE

DEFAULT_PRIORITY

protected int DEFAULT_PRIORITY

DEFAULT_TIME_TO_LIVE

protected int DEFAULT_TIME_TO_LIVE

AUTO_ACKNOWLEDGE

protected static final java.lang.String AUTO_ACKNOWLEDGE
See Also:
Constant Field Values

CLIENT_ACKNOWLEDGE

protected static final java.lang.String CLIENT_ACKNOWLEDGE
See Also:
Constant Field Values

DUPS_OK_ACKNOWLEDGE

protected static final java.lang.String DUPS_OK_ACKNOWLEDGE
See Also:
Constant Field Values

PERSISTENT

protected static final java.lang.String PERSISTENT
See Also:
Constant Field Values

NON_PERSISTENT

protected static final java.lang.String NON_PERSISTENT
See Also:
Constant Field Values

scheme

protected java.lang.String scheme

host

protected java.lang.String host

port

protected java.lang.String port

name

protected java.lang.String name

url

protected java.lang.String url

connectionFactory

protected java.lang.String connectionFactory

initialContextFactory

protected java.lang.String initialContextFactory

deliveryMode

protected int deliveryMode

priority

protected int priority

timeToLive

protected int timeToLive

transacted

protected boolean transacted

ackMode

protected int ackMode

use_topic

protected boolean use_topic

durable

protected boolean durable

nolocal

protected boolean nolocal

destinations

protected java.util.Hashtable destinations

consumers

protected java.util.Hashtable consumers

producers

protected java.util.Hashtable producers

connection

protected javax.jms.Connection connection

session

protected javax.jms.Session session
Constructor Detail

AbstractJMSMessagingService

public AbstractJMSMessagingService()
Method Detail

init

public void init(javax.servlet.ServletConfig conf)
          throws org.apache.turbine.services.InitializationException
This is the early initialization method called by the Turbine Service framework

Throws:
org.apache.turbine.services.InitializationException

initJMSConfiguration

protected void initJMSConfiguration()
Initialize the JMS Configuration


printAckMode

protected java.lang.String printAckMode()
Helper method to print the acknowledgement mode

Returns:

printDeliveryMode

protected java.lang.String printDeliveryMode()
Helper method to print the delivery mode

Returns:

getProviderURL

protected java.lang.String getProviderURL()
Return the url if it was configured, othewise, generate the url from the scheme, host, port, and name properties

Returns:

getContext

protected javax.naming.Context getContext()
                                   throws javax.naming.NamingException
Genereate a JNDI context using the context factory and the provider url

Returns:
Throws:
javax.naming.NamingException

createSession

protected void createSession()
                      throws javax.jms.JMSException
Create the JMS Session

Throws:
javax.jms.JMSException

createConnection

protected abstract void createConnection()
                                  throws javax.jms.JMSException
Create the connection the the JMS Server

Throws:
javax.jms.JMSException

createMessage

public javax.jms.Message createMessage(int messageType)
Description copied from interface: MessagingService
Create a message based on the give type

Specified by:
createMessage in interface MessagingService
Parameters:
messageType -
Returns:
See Also:
MessagingService.createMessage(int)

shutdown

public void shutdown()
This is the shutdown method called by the Turbine Service framework

Specified by:
shutdown in interface org.apache.turbine.services.Initable

addMessageListener

public void addMessageListener(javax.jms.MessageListener listener,
                               java.lang.String id,
                               java.lang.String destination)
Description copied from interface: MessagingService
This method creates a new consumer if one with the given id has not been created. The consumer will be closed during the services shutdown.

Specified by:
addMessageListener in interface MessagingService
Parameters:
listener -
id -
destination -
See Also:
org.apache.jetspeed.services.messaging.MessagingService#addMessageListener(java.lang.Object)

createConsumer

public javax.jms.MessageConsumer createConsumer(java.lang.String destination)
Description copied from interface: MessagingService
This method creates a new MessageConsumer. It's lifecycle should be managed by the caller.

Specified by:
createConsumer in interface MessagingService
Parameters:
destination -
See Also:
MessagingService.createConsumer(java.lang.String)

removeMessageListener

public void removeMessageListener(java.lang.String id)
Description copied from interface: MessagingService
Remove a message listener that was added to the service previously via the addMessageListener method.

Specified by:
removeMessageListener in interface MessagingService
Parameters:
id -
See Also:
MessagingService.removeMessageListener(java.lang.String)

sendMessage

public void sendMessage(javax.jms.Message message,
                        java.lang.String destination)
Description copied from interface: MessagingService
Send a message to the chose destination

Specified by:
sendMessage in interface MessagingService
Parameters:
message -
destination -
See Also:
org.apache.jetspeed.services.messaging.MessagingService#sendMessage(java.lang.Object)

getDestination

protected javax.jms.Destination getDestination(java.lang.String destination)

getProducer

protected javax.jms.MessageProducer getProducer(java.lang.String destination)
Return the producer based on the given destination. This implemenation will cache the producers that are created for use later.

Parameters:
destination -
Returns:


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.