org.springframework.jms.support.destination
Class JndiDestinationResolver

java.lang.Object
  extended byorg.springframework.jndi.JndiAccessor
      extended byorg.springframework.jndi.JndiLocatorSupport
          extended byorg.springframework.jms.support.destination.JndiDestinationResolver
All Implemented Interfaces:
DestinationResolver

public class JndiDestinationResolver
extends JndiLocatorSupport
implements DestinationResolver

Implementation of the DestinationResolver interface which interprets destination names as JNDI locations, falling back to dynamic destinations else.

Allows for customizing the JNDI environment if necessary, for example specifying appropriate JNDI environment properties.

Dynamic queues and topics get cached by destination name. Thus, use unique destination names across both queues and topics. Caching can be turned off by specifying "cache" as "false", if desired. Automatic creation of dynamic destinations is turned off by default. Specify "fallbackToDynamicDestination" as "true" to enable this functionality.

Since:
1.1
Author:
Mark Pollack, Juergen Hoeller
See Also:
JndiAccessor.setJndiTemplate(org.springframework.jndi.JndiTemplate), JndiAccessor.setJndiEnvironment(java.util.Properties), setCache(boolean), setFallbackToDynamicDestination(boolean)

Field Summary
 
Fields inherited from class org.springframework.jndi.JndiLocatorSupport
CONTAINER_PREFIX
 
Fields inherited from class org.springframework.jndi.JndiAccessor
logger
 
Constructor Summary
JndiDestinationResolver()
           
 
Method Summary
 Destination resolveDestinationName(Session session, String destinationName, boolean pubSubDomain)
          Resolve the given destination name, either as located resource or as dynamic destination.
 void setCache(boolean cache)
          Set whether to cache resolved destinations.
 void setDynamicDestinationResolver(DestinationResolver dynamicDestinationResolver)
          Set the DestinationResolver to use when falling back to dynamic destinations.
 void setFallbackToDynamicDestination(boolean fallbackToDynamicDestination)
          Set the ability of JmsTemplate to create dynamic destinations if the destination name is not found in JNDI.
 
Methods inherited from class org.springframework.jndi.JndiLocatorSupport
convertJndiName, isResourceRef, lookup, setResourceRef
 
Methods inherited from class org.springframework.jndi.JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JndiDestinationResolver

public JndiDestinationResolver()
Method Detail

setCache

public void setCache(boolean cache)
Set whether to cache resolved destinations. Default is true.

Can be turned off to re-lookup a destination for each operation, which allows for hot restarting of destinations. This is mainly useful during development.


setFallbackToDynamicDestination

public void setFallbackToDynamicDestination(boolean fallbackToDynamicDestination)
Set the ability of JmsTemplate to create dynamic destinations if the destination name is not found in JNDI. Default is false.


setDynamicDestinationResolver

public void setDynamicDestinationResolver(DestinationResolver dynamicDestinationResolver)
Set the DestinationResolver to use when falling back to dynamic destinations. Default is a DynamicDestinationResolver.

See Also:
setFallbackToDynamicDestination(boolean), DynamicDestinationResolver

resolveDestinationName

public Destination resolveDestinationName(Session session,
                                          String destinationName,
                                          boolean pubSubDomain)
                                   throws JMSException
Description copied from interface: DestinationResolver
Resolve the given destination name, either as located resource or as dynamic destination.

Specified by:
resolveDestinationName in interface DestinationResolver
Parameters:
session - the current JMS Session
destinationName - the name of the destination
pubSubDomain - whether the domain is pub-sub, else P2P
Returns:
the JMS destination (either a topic or a queue)
Throws:
JMSException - if resolution failed


Copyright (C) 2003-2004 The Spring Framework Project.