net.sf.tie.ext
Class CachingInjector
java.lang.Object
net.sf.tie.ext.CachingInjector
- All Implemented Interfaces:
- InterceptionInjector
public class CachingInjector
- extends Object
- implements InterceptionInjector
An InterceptionInjector
that delegates to another injector, and caches the result. The cache makes use of Reference
objects
to prevent the leaking of memory.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CachingInjector
public CachingInjector(InterceptionInjector parent)
clearCache
public void clearCache()
removeFromCache
public void removeFromCache(Object endPoint)
wrapObject
public <T> T wrapObject(Class<T> type,
T endPoint)
- Description copied from interface:
InterceptionInjector
- Wraps the designated object
endPoint
in any preconfigured MethodInterceptors
.
Returns an object O, such that if a method M is invoked on O, then the provided
interceptors
will be called, prior to an invocation of the original method M on endPoint
.
It is acceptable for implementations to return the endPoint
directly if there is no interception to perform, or if the
interception can be performed without constructing additional objects. However, it is typical for the return value to be a dynamically
created proxy around endPoint
.
- Specified by:
wrapObject
in interface InterceptionInjector
- Parameters:
type
- The java type (typically an interface) which the returned object should implement.- See Also:
ProxyInjector
isWrapped
public boolean isWrapped(Object value)
- Description copied from interface:
InterceptionInjector
- Determines whether the supplied
value
is a wrapped value from this interceptor.
NB: If value
has been wrapped multiple times, then only the injector
that performed the last wrapping is required to return true
. It is acceptible for all other
interceptors to return false
.
- Specified by:
isWrapped
in interface InterceptionInjector