org.springframework.messaging.core

## Class CachingDestinationResolverProxy<D>

- java.lang.Object
- - org.springframework.messaging.core.CachingDestinationResolverProxy<D>

Type Parameters:
  `D` - the destination type

All Implemented Interfaces:
  org.springframework.beans.factory.InitializingBean, DestinationResolver<D>

    public class CachingDestinationResolverProxy<D>
    extends Object
    implements DestinationResolver<D>, org.springframework.beans.factory.InitializingBean

`DestinationResolver` implementation that proxies a target DestinationResolver, caching its `resolveDestination(java.lang.String)` results. Such caching is particularly useful if the destination resolving process is expensive (e.g. the destination has to be resolved through an external system) and the resolution results are stable anyway.

Since:
  4.1
Author:
  Agim Emruli, Juergen Hoeller
See Also:
  `DestinationResolver.resolveDestination(java.lang.String)`

### Constructor Summary

Constructors
Constructor and Description
`CachingDestinationResolverProxy()` Create a new CachingDestinationResolverProxy, setting the target DestinationResolver through the `setTargetDestinationResolver(org.springframework.messaging.core.DestinationResolver<D>)` bean property.
`CachingDestinationResolverProxy(DestinationResolver<D> targetDestinationResolver)` Create a new CachingDestinationResolverProxy using the given target DestinationResolver to actually resolve destinations.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `afterPropertiesSet()`
`D` `resolveDestination(String name)` Resolves and caches destinations if successfully resolved by the target DestinationResolver implementation.
`void` `setTargetDestinationResolver(DestinationResolver<D> targetDestinationResolver)` Set the target DestinationResolver to delegate to.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CachingDestinationResolverProxy

    public CachingDestinationResolverProxy()

Create a new CachingDestinationResolverProxy, setting the target DestinationResolver through the `setTargetDestinationResolver(org.springframework.messaging.core.DestinationResolver<D>)` bean property.

#### CachingDestinationResolverProxy

    public CachingDestinationResolverProxy(DestinationResolver<D> targetDestinationResolver)

Create a new CachingDestinationResolverProxy using the given target DestinationResolver to actually resolve destinations.

Parameters:
  `targetDestinationResolver` - the target DestinationResolver to delegate to

### Method Detail

#### setTargetDestinationResolver

    public void setTargetDestinationResolver(DestinationResolver<D> targetDestinationResolver)

Set the target DestinationResolver to delegate to.

#### afterPropertiesSet

    public void afterPropertiesSet()

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`

#### resolveDestination

    public D resolveDestination(String name)
                         throws DestinationResolutionException

Resolves and caches destinations if successfully resolved by the target DestinationResolver implementation.

Specified by:
  `resolveDestination` in interface `DestinationResolver<D>`
Parameters:
  `name` - the destination name to be resolved
Returns:
  the currently resolved destination or an already cached destination
Throws:
  `DestinationResolutionException` - if the target DestinationResolver reports an error during destination resolution