org.activemq.message
Class ActiveMQDestination

java.lang.Object
  extended by org.activemq.jndi.JNDIBaseStorable
      extended by org.activemq.message.ActiveMQDestination
All Implemented Interfaces:
Serializable, Comparable, Destination, Referenceable, JNDIStorableInterface
Direct Known Subclasses:
ActiveMQQueue, ActiveMQTopic

public abstract class ActiveMQDestination
extends JNDIBaseStorable
implements Destination, Comparable, Serializable

A Destination object encapsulates a provider-specific address. The JMS API does not define a standard address syntax. Although a standard address syntax was considered, it was decided that the differences in address semantics between existing message-oriented middleware (MOM) products were too wide to bridge with a single syntax.

Since Destination is an administered object, it may contain provider-specific configuration information in addition to its address.

The JMS API also supports a client's use of provider-specific address names.

Destination objects support concurrent use.

A Destination object is a JMS administered object.

JMS administered objects are objects containing configuration information that are created by an administrator and later used by JMS clients. They make it practical to administer the JMS API in the enterprise.

Although the interfaces for administered objects do not explicitly depend on the Java Naming and Directory Interface (JNDI) API, the JMS API establishes the convention that JMS clients find administered objects by looking them up in a JNDI namespace.

An administrator can place an administered object anywhere in a namespace. The JMS API does not define a naming policy.

It is expected that JMS providers will provide the tools an administrator needs to create and configure administered objects in a JNDI namespace. JMS provider implementations of administered objects should implement the javax.naming.Referenceable and java.io.Serializable interfaces so that they can be stored in all JNDI naming contexts. In addition, it is recommended that these implementations follow the JavaBeansTM design patterns.

This strategy provides several benefits:

An administered object should not hold on to any remote resources. Its lookup should not use remote resources other than those used by the JNDI API itself.

Clients should think of administered objects as local Java objects. Looking them up should not have any hidden side effects or use surprising amounts of local resources.

See Also:
Serialized Form

Field Summary
static int ACTIVEMQ_QUEUE
          Queue Destination object
static int ACTIVEMQ_TEMPORARY_QUEUE
          Temporary Queue Destination object
static int ACTIVEMQ_TEMPORARY_TOPIC
          Temporary Topic Destination object
static int ACTIVEMQ_TOPIC
          Topic Destination object
static String ADVISORY_PREFIX
          prefix for Advisory message destinations
static String CONNECTION_ADVISORY_PREFIX
          prefix for connection advisory destinations
static String CONSUMER_ADVISORY_PREFIX
          Deprecated. Use #getDestinationForConsumerAdvisory() instead.
static String DEFAULT_ORDERED_TARGET
          The default target for ordered destinations
static String PRODUCER_ADVISORY_PREFIX
          Deprecated. Use #getDestinationForProducerAdvisory() instead.
static String TEMP_DESTINATION_ADVISORY_PREFIX
          Deprecated. Use #getDestinationForTempAdvisory() instead.
 
Constructor Summary
protected ActiveMQDestination()
          The Default Constructor
protected ActiveMQDestination(String name)
          Construct the ActiveMQDestination with a defined physical name;
 
Method Summary
protected  void buildFromProperties(Properties props)
          Set the properties that will represent the instance in JNDI
 int compareTo(ActiveMQDestination that)
          Lets sort by name first then lets sort topics greater than queues
 int compareTo(Object o)
           
static ActiveMQDestination createDestination(int type, String pyhsicalName)
          Create a Destination
protected abstract  Destination createDestination(String name)
          Factory method to create a child destination if this destination is a composite
protected abstract  JMSDestinationStats createDestinationStats()
          Factory method to create a statistics counter object
static String createTemporaryName(String clientId)
          Create a temporary name from the clientId
 void decrementConsumerCounter()
          descrement counter for number interested consumers
 void delete()
          Used to Deletes a temporary destination.
 boolean equals(Object obj)
          if the object passed in is equivalent, return true
 List getChildDestinations()
          Returns a list of child destinations if this destination represents a composite destination.
static String getClientId(ActiveMQDestination destination)
          From a temporary destination find the clientId of the Connection that created it
 ActiveMQDestination getDestinationBeingAdvised()
           
 DestinationFilter getDestinationFilter()
           
 String[] getDestinationPaths()
           
abstract  int getDestinationType()
           
 String getOrderedTarget()
           
 String getPhysicalName()
           
 ActiveMQSession getSessionCreatedBy()
           
 JMSDestinationStats getStats()
           
 ActiveMQTopic getTopicForConsumerAdvisory()
           
 ActiveMQTopic getTopicForProducerAdvisory()
           
 ActiveMQTopic getTopicForTempAdvisory()
           
 int hashCode()
           
 void incrementConsumerCounter()
          increment counter for number of interested consumers
static String inspect(Destination destination)
          A helper method to return a descriptive string for the topic or queue
 boolean isAdvisory()
           
 boolean isComposite()
          Returns true if this destination represents a collection of destinations; allowing a set of destinations to be published to or subscribed from in one JMS operation.
 boolean isConnectionAdvisory()
           
 boolean isConsumerAdvisory()
           
 boolean isDeleted()
           
 boolean isExclusive()
           
 boolean isOrdered()
           
 boolean isProducerAdvisory()
           
 boolean isQueue()
          Returns true if a Queue Destination
 boolean isTempDestinationAdvisory()
           
 boolean isTemporary()
          Returns true if a temporary Destination
 boolean isTopic()
          Returns true if a Topic Destination
 boolean isWildcard()
           
 boolean matches(ActiveMQDestination destination)
           
protected  void populateProperties(Properties props)
          Initialize the instance from properties stored in JNDI
static ActiveMQDestination readFromStream(DataInput dataIn)
          Read an ActiveMQDestination from a Stream
 void setAdvisory(boolean advisory)
           
 void setChildDestinations(ActiveMQDestination[] children)
           
 void setDeleted(boolean value)
          det the deleted flag to the new value
 void setExclusive(boolean exclusive)
           
 void setOrdered(boolean ordered)
           
 void setOrderedTarget(String orderedTarget)
           
 void setPhysicalName(String name)
           
 void setSessionCreatedBy(ActiveMQSession orginatingSession)
           
 void setStats(JMSDestinationStats stats)
           
 String toString()
           
static ActiveMQDestination transformDestination(Destination destination)
           
static void writeToStream(ActiveMQDestination destination, DataOutput dataOut)
          Write an ActiveMQDestination to a Stream
 
Methods inherited from class org.activemq.jndi.JNDIBaseStorable
getProperties, getReference, setProperties
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ACTIVEMQ_TOPIC

public static final int ACTIVEMQ_TOPIC
Topic Destination object

See Also:
Constant Field Values

ACTIVEMQ_TEMPORARY_TOPIC

public static final int ACTIVEMQ_TEMPORARY_TOPIC
Temporary Topic Destination object

See Also:
Constant Field Values

ACTIVEMQ_QUEUE

public static final int ACTIVEMQ_QUEUE
Queue Destination object

See Also:
Constant Field Values

ACTIVEMQ_TEMPORARY_QUEUE

public static final int ACTIVEMQ_TEMPORARY_QUEUE
Temporary Queue Destination object

See Also:
Constant Field Values

ADVISORY_PREFIX

public static final String ADVISORY_PREFIX
prefix for Advisory message destinations

See Also:
Constant Field Values

CONNECTION_ADVISORY_PREFIX

public static final String CONNECTION_ADVISORY_PREFIX
prefix for connection advisory destinations

See Also:
Constant Field Values

CONSUMER_ADVISORY_PREFIX

public static final String CONSUMER_ADVISORY_PREFIX
Deprecated. Use #getDestinationForConsumerAdvisory() instead.
prefix for consumer advisory destinations

See Also:
Constant Field Values

PRODUCER_ADVISORY_PREFIX

public static final String PRODUCER_ADVISORY_PREFIX
Deprecated. Use #getDestinationForProducerAdvisory() instead.
prefix for producer advisory destinations

See Also:
Constant Field Values

TEMP_DESTINATION_ADVISORY_PREFIX

public static final String TEMP_DESTINATION_ADVISORY_PREFIX
Deprecated. Use #getDestinationForTempAdvisory() instead.
prefix for connection advisory destinations

See Also:
Constant Field Values

DEFAULT_ORDERED_TARGET

public static final String DEFAULT_ORDERED_TARGET
The default target for ordered destinations

See Also:
Constant Field Values
Constructor Detail

ActiveMQDestination

protected ActiveMQDestination()
The Default Constructor


ActiveMQDestination

protected ActiveMQDestination(String name)
Construct the ActiveMQDestination with a defined physical name;

Parameters:
name -
Method Detail

getSessionCreatedBy

public ActiveMQSession getSessionCreatedBy()
Returns:
Returns the orginatingSession.

setSessionCreatedBy

public void setSessionCreatedBy(ActiveMQSession orginatingSession)
Parameters:
orginatingSession - The orginatingSession to set.

isAdvisory

public final boolean isAdvisory()
Returns:
Returns the advisory.

setAdvisory

public final void setAdvisory(boolean advisory)
Parameters:
advisory - The advisory to set.

isConsumerAdvisory

public boolean isConsumerAdvisory()
Returns:
true if this is a destination for Consumer advisories

isProducerAdvisory

public boolean isProducerAdvisory()
Returns:
true if this is a destination for Producer advisories

isConnectionAdvisory

public boolean isConnectionAdvisory()
Returns:
true if this is a destination for Connection advisories

isTempDestinationAdvisory

public final boolean isTempDestinationAdvisory()
Returns:
true if this a destination for Tempoary Destination advisories

isExclusive

public final boolean isExclusive()
Returns:
Returns the exclusive.

setExclusive

public final void setExclusive(boolean exclusive)
Parameters:
exclusive - The exclusive to set.

isOrdered

public final boolean isOrdered()
Returns:
Returns the ordered.

setOrdered

public final void setOrdered(boolean ordered)
Parameters:
ordered - The ordered to set.

getOrderedTarget

public String getOrderedTarget()
Returns:
Returns the orderedTarget.

setOrderedTarget

public void setOrderedTarget(String orderedTarget)
Parameters:
orderedTarget - The orderedTarget to set.

inspect

public static String inspect(Destination destination)
A helper method to return a descriptive string for the topic or queue

Parameters:
destination -
Returns:
a descriptive string for this queue or topic

transformDestination

public static ActiveMQDestination transformDestination(Destination destination)
                                                throws JMSException
Parameters:
destination -
Returns:
@throws JMSException
Throws:
JMSException

writeToStream

public static void writeToStream(ActiveMQDestination destination,
                                 DataOutput dataOut)
                          throws IOException
Write an ActiveMQDestination to a Stream

Parameters:
destination -
dataOut -
Throws:
IOException

readFromStream

public static ActiveMQDestination readFromStream(DataInput dataIn)
                                          throws IOException
Read an ActiveMQDestination from a Stream

Parameters:
dataIn -
Returns:
the ActiveMQDestination
Throws:
IOException

createDestination

public static ActiveMQDestination createDestination(int type,
                                                    String pyhsicalName)
Create a Destination

Parameters:
type -
pyhsicalName -
Returns:

createTemporaryName

public static String createTemporaryName(String clientId)
Create a temporary name from the clientId

Parameters:
clientId -
Returns:

getClientId

public static String getClientId(ActiveMQDestination destination)
From a temporary destination find the clientId of the Connection that created it

Parameters:
destination -
Returns:
the clientId or null if not a temporary destination

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable
Parameters:
o - object to compare
Returns:
1 if this > o else 0 if they are equal or -1 if this < o

compareTo

public int compareTo(ActiveMQDestination that)
Lets sort by name first then lets sort topics greater than queues

Parameters:
that - another destination to compare against
Returns:
1 if this > that else 0 if they are equal or -1 if this < that

getDestinationType

public abstract int getDestinationType()
Returns:
Returns the Destination type

getPhysicalName

public String getPhysicalName()
Returns:
Returns the physicalName.

setPhysicalName

public void setPhysicalName(String name)
Parameters:
name - The physicalName to set.

isTemporary

public boolean isTemporary()
Returns true if a temporary Destination

Returns:
true/false

isTopic

public boolean isTopic()
Returns true if a Topic Destination

Returns:
true/false

isQueue

public boolean isQueue()
Returns true if a Queue Destination

Returns:
true/false

isComposite

public final boolean isComposite()
Returns true if this destination represents a collection of destinations; allowing a set of destinations to be published to or subscribed from in one JMS operation.

If this destination is a composite then you can call getChildDestinations() to return the list of child destinations.

Returns:
true if this destination represents a collection of child destinations.

getChildDestinations

public List getChildDestinations()
Returns a list of child destinations if this destination represents a composite destination.

Returns:

setChildDestinations

public void setChildDestinations(ActiveMQDestination[] children)

toString

public String toString()
Overrides:
toString in class Object
Returns:
string representation of this instance

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
hashCode for this instance

equals

public boolean equals(Object obj)
if the object passed in is equivalent, return true

Overrides:
equals in class Object
Parameters:
obj - the object to compare
Returns:
true if this instance and obj are equivalent

isWildcard

public boolean isWildcard()
Returns:
true if the destination matches multiple possible destinations

matches

public boolean matches(ActiveMQDestination destination)
Parameters:
destination -
Returns:
true if the given destination matches this destination; including wildcards

getDestinationFilter

public DestinationFilter getDestinationFilter()
Returns:
the DestinationFilter

getDestinationPaths

public String[] getDestinationPaths()
Returns:
the associated paths associated with this Destination

getStats

public JMSDestinationStats getStats()
Returns:
stats for this destination

setStats

public void setStats(JMSDestinationStats stats)
Parameters:
stats -

incrementConsumerCounter

public void incrementConsumerCounter()
increment counter for number of interested consumers


decrementConsumerCounter

public void decrementConsumerCounter()
descrement counter for number interested consumers


isDeleted

public boolean isDeleted()
Returns:
true if this destination is deleted

setDeleted

public void setDeleted(boolean value)
det the deleted flag to the new value

Parameters:
value -

delete

public void delete()
            throws JMSException
Used to Deletes a temporary destination. If there are existing consumers still using it, a JMSException will be thrown.

Throws:
JMSException - if the JMS provider fails to delete the temporary queue due to some internal error.

createDestination

protected abstract Destination createDestination(String name)
Factory method to create a child destination if this destination is a composite

Parameters:
name -
Returns:
the created Destination

createDestinationStats

protected abstract JMSDestinationStats createDestinationStats()
Factory method to create a statistics counter object

Returns:

buildFromProperties

protected void buildFromProperties(Properties props)
Set the properties that will represent the instance in JNDI

Specified by:
buildFromProperties in class JNDIBaseStorable
Parameters:
props -

populateProperties

protected void populateProperties(Properties props)
Initialize the instance from properties stored in JNDI

Specified by:
populateProperties in class JNDIBaseStorable
Parameters:
props -

getTopicForTempAdvisory

public ActiveMQTopic getTopicForTempAdvisory()
Returns:
the topic that is used for this destination's temporary destination advisories.

getTopicForConsumerAdvisory

public ActiveMQTopic getTopicForConsumerAdvisory()
Returns:
the topic that is used for this destination's consumer advisories.

getTopicForProducerAdvisory

public ActiveMQTopic getTopicForProducerAdvisory()
Returns:
the topic that is used for this destination's producer advisories.

getDestinationBeingAdvised

public ActiveMQDestination getDestinationBeingAdvised()
Returns:
null if this destination is not an advisory topic, else it returns the destination that the advisories are related.


Copyright © 2004-2008 Protique, Ltd.. All Rights Reserved.