Command pattern and SFSBs

I am using the command pattern to interface with the business tier. The commands are generated by the presentation tier and then sent across to a CommandHandlerEJB (sateless) on the business tier, who invokes execute() method on the command. The command in turn calls other EJBs in order to fulfill its logic.

So everything went well as long as the commands were calling the stateless beans...

Now my commands need to call SFSBs, and therefore I need to remember somewhere the references/handlers to the SFSBs for a particular client. The only way I could see to solve this problem was to make the CommandHandlerEJB stateful too, who will create and keep a reference to a ServiceLocator, who in turn memorises stateful beans used by the client. That ServiceLocator instance is passed to the execute() method as parameter by the CommandHandleEJB for reuse. However, I don't find this solution very elegant, since it requires a command handler and a ServiceLocator instances per client.

Am I complicating things due to a flaw in my understanding of how things work? I would be grateful if you could share your solution/opinions...

Many thanks,

Dino

[1189 byte] By [celovicd] at [2007-9-27 17:37:29]
# 1

Hi,

I have the same problem with command pattern and SFSB.

My solution is to keep the commandServerEJB as a Stateless session bean.

When I need to use a SFSB in a command, a handle of this bean is maintained in the HTTPSession.

The Web tier sets this handle into the command (the Servlet, which has access to the HTTPSession, calls a setter method on the command), thus when executing into the stateless serverCommandEJB, the command is able to access the concerned SFSB through its handle (The handle is an attribute of the command).

any feedbacks ?

thanks a lot

raibaut at 2007-7-6 12:55:16 > top of Java-index,Other Topics,Patterns & OO Design...