public class CachingValueResolverWrapper<T> extends Object implements ValueResolver<T>
ValueResolver
in which
the delegate
is only invoked once and the obtained value is cached.
This is useful in cases in which its expensive for the delegate
to resolve the value.
Care should be taken when using this class to wrap resolvers which
isDynamic()
method return true
. Since this wrapper
will cache the result of the first invocation, the resolver's dynamism
is in effect neutralized.
This class is thread safe. Many threads can invoke the resolve(MuleEvent)
method and the underlying delegate
is still guaranteed to be invoked only once
and the return value to be consistent with that of the thread which first got access to it.
This class can also be used without performance considerations since it's optimized to only
perform thread contention until a value is cached. From then on, no locks will be used while
remaining thread safeConstructor and Description |
---|
CachingValueResolverWrapper(ValueResolver<T> delegate) |
public CachingValueResolverWrapper(ValueResolver<T> delegate)
public T resolve(MuleEvent event) throws MuleException
delegate
and the return value is stored. From then on, the stored value is always
returnedresolve
in interface ValueResolver<T>
event
- a MuleEvent
Exception
MuleException
- if the resolution of the value failspublic boolean isDynamic()
false
since the same value will be
returned in each invocationisDynamic
in interface ValueResolver<T>
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.