org.exolab.jms.messagemgr
Class DestinationManager

java.lang.Object
  |
  +--org.exolab.jms.messagemgr.DestinationManager
All Implemented Interfaces:
GarbageCollectable, MessageManagerEventListener

public class DestinationManager
extends java.lang.Object
implements MessageManagerEventListener, GarbageCollectable

The destination manager is responsible for creating and managing the lifecycle of DestinationCache objects. The destination manager is also responsible for managing messages, that are received by the message manager, which do not have any registered DestinationCache

Version:
$Revision: 1.36 $ $Date: 2003/08/16 06:37:43 $
Author:
Jim Alateras

Method Summary
 void collectGarbage(boolean aggressive)
          Perform any garbage collection on this resource.
 boolean createAdministeredDestination(JmsDestination dest)
          Create an administered destination using the specified destination.
 void createDestination(JmsDestination destination)
          Create a non-administered destination and cache it.
 DestinationCache createDestinationCache(java.sql.Connection connection, JmsDestination dest)
          Create a destination of the specified type.
 DestinationCache createDestinationCache(JmsDestination dest)
          Create a destination of the specified type.
static DestinationManager createInstance()
          Create the singleton instance of the destination manager
 void deleteAdministeredDestination(JmsDestination dest)
          Remove the corresponding administered destination from persistent store, from transient memory and from the jndi context.
 boolean destinationExists(JmsDestination destination)
          Check if the specified destination exists.
 JmsDestination destinationFromString(java.lang.String name)
          Return the JmsDestination corresponding to the specified destination name
 java.util.Iterator destinationNames()
          Return a list of destination names currently supported by the destination manager.
 java.util.Iterator destinations()
          Return a list of DestinationCache objects that are currently active and in memory.
 void destroy()
          Destroy this manager.
 void destroyDestinationCache(DestinationCache cache)
          Delete the specfied destination
 void destroyDestinationCache(JmsDestination dest)
          Delete the specfied destination
 void destroyDestinationCache(java.lang.String name)
          Deprecated. use destroyDestination(JmsDestination) instead
 DestinationCache getDestinationCache(JmsDestination dest)
          Return the destination cache associated with the dest object
 DestinationCache getDestinationCache(MessageImpl message)
          Return the DestinationCache for this message.
 DestinationCache getDestinationCache(java.lang.String dest)
          Return the destination object associated with destination
 boolean hasDestinationCache(JmsDestination dest)
          Check if the specified destination exists.
protected  void init()
          Initialises the destination manager.
static DestinationManager instance()
          Return the singleton destination manager
 boolean isAdministeredDestination(java.lang.String name)
          Test whether the specified destination is an administered destination.
 boolean isMessageForAdministeredDestination(MessageImpl msg)
          Test whether the specified message is for an administered destination.
 boolean messageAdded(JmsDestination destination, MessageImpl message)
          This method is called when the MessageMgr adds a message for this destination to the cache
 void messageRemoved(JmsDestination destination, MessageImpl message)
          This method is called when the MessageMgr removes a message from the cache.
 boolean persistentMessageAdded(java.sql.Connection connection, JmsDestination destination, MessageImpl message)
          This event is called when the MessageMgr adds a persistent message to the cache.
 void persistentMessageRemoved(java.sql.Connection connection, JmsDestination destination, MessageImpl message)
          This event is called when the MessageMgr removes a persistent message from the cache.
 void registerConfiguredAdministeredDestinations()
          This method will create the administered destinations specified in the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createInstance

public static DestinationManager createInstance()
                                         throws org.exolab.core.service.ServiceException
Create the singleton instance of the destination manager
Returns:
the singleton instance
Throws:
org.exolab.core.service.ServiceException - if the service cannot be initialised

instance

public static DestinationManager instance()
Return the singleton destination manager
Returns:
the singleton instance, or null if it hasn't been initialised

createDestinationCache

public DestinationCache createDestinationCache(JmsDestination dest)
Create a destination of the specified type. If the destination already exists then simply return it. If it doesn't exist then create it.
Parameters:
dest - - the destination to create
Returns:
DestinationCache - the created destination cache

createDestinationCache

public DestinationCache createDestinationCache(java.sql.Connection connection,
                                               JmsDestination dest)
Create a destination of the specified type. If the destination already exists then simply return it. If it doesn't exist then create it. If a connection is supplied then create the cache using the connection context, otherwise create it without a context.
Parameters:
connection - - the connection to use.
dest - - the destination to create
Returns:
DestinationCache - the created destination cache

destroyDestinationCache

public void destroyDestinationCache(DestinationCache cache)
Delete the specfied destination
Parameters:
cahe - - the destination to destroy

destroyDestinationCache

public void destroyDestinationCache(java.lang.String name)
Deprecated. use destroyDestination(JmsDestination) instead

Delete the specfied destination
Parameters:
name - - destination name

destroyDestinationCache

public void destroyDestinationCache(JmsDestination dest)
Delete the specfied destination
Parameters:
dest - - the destination to destroy

destinationFromString

public JmsDestination destinationFromString(java.lang.String name)
Return the JmsDestination corresponding to the specified destination name
Parameters:
name - - destination name
Returns:
JmsDestination - the corresponding object or null

getDestinationCache

public DestinationCache getDestinationCache(JmsDestination dest)
Return the destination cache associated with the dest object
Parameters:
dest - - the destination
Returns:
DestinationCache - associated destination object or null

getDestinationCache

public DestinationCache getDestinationCache(java.lang.String dest)
Return the destination object associated with destination
Parameters:
dest - - the name of the destination
Returns:
DestinationCache - associated destination object or null

getDestinationCache

public DestinationCache getDestinationCache(MessageImpl message)
Return the DestinationCache for this message.
Parameters:
message - - the message to query
Returns:
DestinationCache - the corresponding cahce or null

hasDestinationCache

public boolean hasDestinationCache(JmsDestination dest)
Check if the specified destination exists.
Parameters:
dest - - destination to check
Returns:
boolean - true if it exists

createDestination

public void createDestination(JmsDestination destination)
Create a non-administered destination and cache it. It does not check to see whether or not it is an administered destination this must be done by the caller
Parameters:
destination - - the destination to create

createAdministeredDestination

public boolean createAdministeredDestination(JmsDestination dest)
                                      throws javax.jms.JMSException
Create an administered destination using the specified destination. It will create the destination in the database and register it with the jndi context.
Parameters:
dest - - the destination
Returns:
boolean - true if successful

deleteAdministeredDestination

public void deleteAdministeredDestination(JmsDestination dest)
                                   throws javax.jms.JMSException
Remove the corresponding administered destination from persistent store, from transient memory and from the jndi context. This will also remove all durable consumers for this topic.
Parameters:
dest - - the destination to remove
Returns:
boolean - true if successful

destinationNames

public java.util.Iterator destinationNames()
Return a list of destination names currently supported by the destination manager. This includes all types of destinations.
Returns:
Iterator - iterator for JmsDestination objects

destinations

public java.util.Iterator destinations()
Return a list of DestinationCache objects that are currently active and in memory. This will return a list of all destination types (temporary. transient, administered}.
Returns:
Iterator - set of DestinationCache objects

registerConfiguredAdministeredDestinations

public void registerConfiguredAdministeredDestinations()
This method will create the administered destinations specified in the configuration. A topic may also have zero or more preconfigured durable sunbscribers. An equivalent entity for queues does not exist.

messageAdded

public boolean messageAdded(JmsDestination destination,
                            MessageImpl message)
Description copied from interface: MessageManagerEventListener
This method is called when the MessageMgr adds a message for this destination to the cache
Specified by:
messageAdded in interface MessageManagerEventListener
Following copied from interface: org.exolab.jms.messagemgr.MessageManagerEventListener
Parameters:
destination - the message's destination
message - the message added to cache
Returns:
true if this message was accepted

messageRemoved

public void messageRemoved(JmsDestination destination,
                           MessageImpl message)
Description copied from interface: MessageManagerEventListener
This method is called when the MessageMgr removes a message from the cache.
Specified by:
messageRemoved in interface MessageManagerEventListener
Following copied from interface: org.exolab.jms.messagemgr.MessageManagerEventListener
Parameters:
destination - the message's destination
message - message removed from cache

persistentMessageAdded

public boolean persistentMessageAdded(java.sql.Connection connection,
                                      JmsDestination destination,
                                      MessageImpl message)
                               throws PersistenceException
Description copied from interface: MessageManagerEventListener
This event is called when the MessageMgr adds a persistent message to the cache.
Specified by:
persistentMessageAdded in interface MessageManagerEventListener
Following copied from interface: org.exolab.jms.messagemgr.MessageManagerEventListener
Parameters:
connection - the database connection
destination - the message's destination
message - message added to cache
Returns:
trueThrows:
PersistenceException - if there is a persistence related problem

persistentMessageRemoved

public void persistentMessageRemoved(java.sql.Connection connection,
                                     JmsDestination destination,
                                     MessageImpl message)
                              throws PersistenceException
Description copied from interface: MessageManagerEventListener
This event is called when the MessageMgr removes a persistent message from the cache.
Specified by:
persistentMessageRemoved in interface MessageManagerEventListener
Following copied from interface: org.exolab.jms.messagemgr.MessageManagerEventListener
Parameters:
connection - the database connection
message - message to remove from cache
destination - the message's destination
Throws:
PersistenceException - - if there is a persistence related problem

collectGarbage

public void collectGarbage(boolean aggressive)
Description copied from interface: GarbageCollectable
Perform any garbage collection on this resource. This will have the effect of releasing system resources. If the 'aggressive' flag is set to true then the garbage collection should do more to release memory related resources since it is called when the application memory is low.
Specified by:
collectGarbage in interface GarbageCollectable
Following copied from interface: org.exolab.jms.gc.GarbageCollectable
Parameters:
aggressive - - true for aggressive garbage collection

destroy

public void destroy()
Destroy this manager. This is brutal and final

isAdministeredDestination

public boolean isAdministeredDestination(java.lang.String name)
Test whether the specified destination is an administered destination. It assumes that the destination exsits.
Parameters:
name - - the name of the destination
Returns:
boolean - true if it is and false otherwise

isMessageForAdministeredDestination

public boolean isMessageForAdministeredDestination(MessageImpl msg)
Test whether the specified message is for an administered destination. This would be the case if the destination is administered or if there is an administered wildcard destination that is satisfied by the message destination
Parameters:
message - - the message to check
Returns:
boolean

destinationExists

public boolean destinationExists(JmsDestination destination)
Check if the specified destination exists.
Parameters:
destination - - the destination to check
Returns:
boolean - true if it exists and false otherwise

init

protected void init()
             throws org.exolab.core.service.ServiceException
Initialises the destination manager.
Throws:
org.exolab.core.service.ServiceException - if the service cannot be initialised


Copyright © 1999-2004 The OpenJMS Group. All Rights Reserved.