accessing interceptor members from another interceptor
Talip Ozturk <[email protected]> 03 Mar 2003 18:08:12 -0500
| Newsgroups | gmane.comp.java.nanning.devel |
|---|---|
| Message-ID | <1046732892.12625.33.camel@greenland> |
Hey guys,
i have a question about inter-interceptor communication. lets say we
have a interceptor A and B. B needs to access variable that are set and
available at interceptor A. what are the recommended ways of
passing/reading/accessing data that are in another interceptor in an
invocation chain?
i have two ways right now.
1. Use a special State Mixin that holds shared data among interceptors
and other Mixin..
in interceptor A
StateMixin sm = (StateMixin) invocation.getProxy();
sm.setTransactionId (txId);
then in interceptor B
StateMixin sm = (StateMixin) invocation.getProxy();
long txId = sm.getTransactionId ());
2. Each interceptor should keep its own specific data. if they need to
access some other interceptor's data, they need to get a hold on that
interceptor first, and then access its variables. Example.
in interceptor A
setTransactionId (txnId);
then in Interceptor B ..
A a = (A) invocation.getInterceptorNamed("a");
a.getTransactionId();
what do you guys think about this? please be as verbose as you can..
-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
for complex code. Debugging C/C++ programs can leave you feeling lost and
disoriented. TotalView can help you find your way. Available on major UNIX
and Linux platforms. Try it free. www.etnus.com