Bind arbitrary data to ejb call context

I have a bunch of inactive ejb 3.0 beans calling each other in a chain. Consider BeanA.do (message) → BeanB.do () → BeanC.do () → BeanD.do (). Now I would like to access data from BeanD.do (). The obvious solution is to pass the message as a parameter to all do () calls (actually, how it works now), but I want a nicer solution.

Is there some kind of calling context? And can I bind arbitrary data to it?

What I would like to do is just put the message in BeanA.do (message) in the local storage associated with the bean function call and retrieve it in BeanD.do ().

Any ideas?

0


source to share


5 answers


I don't believe there is anything in the EJB specification that provides this functionality. If you are on a specific application server you can use server specific applications (I think JBoss allows stuff to be added to the calling context). you can also spoof something with JNDI.



personally, this seems like bad design to me. I could see this if you had some code in the middle that you couldn't control, but why is it different? you complicate your code logic a lot, because you have a bunch of "magic" data that just appears in your function.

+1


source


You can have a class with static get / set methods that access a static ThreadLocal field. However, I would take James's advice and consider very carefully if you want to bind your EJBs to this other class. Definitely double check your application server docs as I'm not sure if using ThreadLocals in an EJB is supported.



0


source


I have exactly the same problem. The ironic part is that it's easy to do with SOAP in jax-ws or jax-rpc, but difficult to do with EJB.

I am discussing whether to abandon the use of local or remote EJB interfaces and instead pass messages through JMS, which also simplifies the process.

There are legal cases where this is necessary and does not represent a design flaw.

0


source


This is what Seam provides. A bit awkward to work with pure web services (i.e. no web interface). However, I did it and it works nicely.

0


source


I need to use call context in JAX WS. Brent says "The ironic part is that it's easy to do with SOAP in jax-ws or jax-rpc, but hard to do with EJB."

Could you please advise me how to use Call context in JAX WS

0


source







All Articles