[jboss-user] [EJB3] - Passing information via InvocationContext in interceptors
Arjun Kumaar
do-not-reply at jboss.com
Wed Jun 29 23:06:00 EDT 2011
Arjun Kumaar [http://community.jboss.org/people/arjun_kumaar] created the discussion
"Passing information via InvocationContext in interceptors"
To view the discussion, visit: http://community.jboss.org/message/612633#612633
--------------------------------------------------------------
Can I pass data in invocation context via remote method calls?
I have two stateless session beans
BeanA and BeanB
I have an interceptor for each bean
BeanAInterceptor for BeanA.methodA
BeanBInterceptor for BeanB.methodB
In BeanAInterceptor, I set some context data.
In BeanA.methodA, I get an handle to BeanB and call BeanB.methodB
In the process, BeanBInterceptor gets called and I want to read the context data
that I set in BeanAInterceptor, but I get null.
Is there any way to pass data via InvocationContext across remote calls if BeanA
and BeanB are deployed in
a. same jvm
b. different jvm
c. in a clustered environment.
In short I want to send data across ejbs, but via interceptors and not
as parameters to method calls.
I am pasting the relevant code below.
@Stateless
public class BeanA {
@Resource
SessionContext ctx;
@Interceptors(BeanAInterceptor.class)
public void methodA() {
BeanBRemote bRemote = ctx
.getBusinessObject(BeanB.class);
bRemote.methodB();
}
}
public class BeanAInterceptor {
@AroundInvoke
public Object interceptA(InvocationContext ctx) throws Exception {
Map<String, Object> ctxData = ctx.getContextData();
ctxData.put("key", "value");
return ctx.proceed();
}
}
@Stateless
public class BeanB {
@Interceptors(BeanBInterceptor.class)
public void methodB() {
//do something
return;
}
}
public class BeanBInterceptor {
@AroundInvoke
public Object interceptB(InvocationContext ctx) throws Exception {
Map<String, Object> ctxData = ctx.getContextData();
Object val = ctxData.get("key"); //I get val as null here
return ctx.proceed();
}
}
Thanks
Arjun
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/612633#612633]
Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110629/7b154c28/attachment.html
More information about the jboss-user
mailing list