开发者

need help in EJB stateless beans

I am new to EJB. I have a requirement of calling a method of remote stateless bean and setting a value, before calling any method on the same bean. The value set from first method call should be available to second method. I know that a stateless bean can't hold instance variables values for next calls. Is there any alternative to mak开发者_开发知识库e the value available to the bean method without making bean as stateful bean. any tweaking tip?


Is there any alternative to make the value available to the bean method without making bean as stateful bean?

Without passing the value to the second method or persisting it, for example in database, I don't think so (using an instance variables is certainly not a solution as you're not sure to call the same session bean with each method call because the pool can return any session bean for your method call).


It is a wrong use of stateless session bean. Stateless should depend upon only the parameters that are being passed to it and no other previous state. Even if you put a hack around it, think of poor guys who will support it later. Database is definitely a better way of doing it. Otherwise, can you use interceptors ? They are powerful in EJB 3.0 and can even change the parameters, set some value etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜