views:

68

answers:

2

Hi,

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 make the value available to the bean method without making bean as stateful bean. any tweaking tip?

+1  A: 

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).

Pascal Thivent
+1  A: 

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.

Shamik