I want to introduce a global variable, state, so that the application behaves differently based on the state. What I do NOT want is change all my ejbs and the calls to my ejbs. Any ideas how to do it?
Let me walk through some of the alternatives I have already evaluated:
1. A Singleton: This option has been suggested in several previous threads, but the overall conclustion is that a singleton does not work in clustered environments.
2. A Stateful session bean combined with a State Machine as in Petstore: This option seems fine. The problem with this option is that I have to send the session-bean/state-machine back and forth in the application. The latter implies that I have to change the signature of every method in the application. As I am a lazy programmer, I really want to avoid it.
3. Any suggestions???
Based on alternative 2, I have tried the following:
1. create a base class and base interface for all my ejbs.
2. let all ejbs extend the basa class and the base interface
3. in the base class, store the state variable.
4. provide getter and setter methods for the state variable in the base class.
For example bean.setState(myState)
The above scenario is "almost" fine, except that a call like
bean = home.create()
bean = home.findByPrimaryKey(id)
happens before I can call
What can I do?
I would appreciate any suggestions.