|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.skife.intercept.InterceptionBroker
provide interception matches against arbitrary non-final objects
Constructor Summary | |
InterceptionBroker()
|
Method Summary | |
void |
addInterceptor(java.lang.Class interceptor,
org.skife.intercept.Signature signature)
Used to add an interceptor where a new Interceptor
will be instantiated for each invocation. |
void |
addInterceptor(org.skife.intercept.Interceptor interceptor,
org.skife.intercept.Signature signature)
The Interceptor passed here will be used for every method
invocation. |
org.skife.intercept.InterceptedObject |
wrap(java.lang.Object obj)
Wrap an arbitrary object in whatever interceptors match it. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public InterceptionBroker()
Method Detail |
public org.skife.intercept.InterceptedObject wrap(java.lang.Object obj)
It is important to note that an object can only be wrapped by a single broker at a time, or to put it more specifically, a broker will NOT wrap an already wrapped object -- this is a meaningless triviality when attempting to wrap the same object via the same broker multiple times, but it means that if an InterceptedObject is passed to this method, you will get the same object back with no changes.
A single object can in fact be wrapped by multiple brokers concurrently, however the wrapped objects will be different, for example:
HashMap foo = new HashMap();
HashMap wrappedFooOne = (HashMap)broker1.wrap(foo);
HashMap wrappedFooTwo = (HashMap)broker2.wrap(foo);
is perfectly okay, however calls to the two wrapped foos
will go through the interception stacks defined in their
respective brokers -- not through both.
The following code is an example of the behavior warned about:
HashMap foo = new HashMap();
HashMap wrappedFooOne = (HashMap)broker1.wrap(foo);
HashMap wrappedFooTwo = (HashMap)broker2.wrap(wrappedFooOne);
In this case the wrappedFooTwo will not execute
the interception stack defined in broker2, only the one
defined in broker1.
TODO Change above mentioned behavior to expected behavior
obj
- must not be declared final
public void addInterceptor(java.lang.Class interceptor, org.skife.intercept.Signature signature)
Interceptor
will be instantiated for each invocation.
interceptor
- Class implementing Interceptor
signature
- Signature which will be matched for interceptionpublic void addInterceptor(org.skife.intercept.Interceptor interceptor, org.skife.intercept.Signature signature)
Interceptor
passed here will be used for every method
invocation. Make sure it is threadsafe if you are in a multithreaded environment!
interceptor
- Singleton interceptorsignature
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |