Business Delegate and Session Facade
In the J2EE patterns catalog it is stated that there is typically a one to one mapping between aBusiness Delegate and aSession Facade. I have been, for sometime, been under the impression that the Business Delegate can be asingleton. Does it make sense to have a singleton Business Delegate when your application is complex enough to warrant multiple Session Facades? Or is a Business Delegate never a singleton? That doesn't make sense to me. Any thoughts that help obtain a better understanding is most appreciated.
Thanks
[562 byte] By [
Supes73a] at [2007-10-2 23:11:06]

> In the J2EE patterns catalog it is stated that there
> is typically a one to one mapping between a
> Business Delegate and a Session Facade.
I've very sceptical that you've interpreted that correctly. Can you provide a reference ?
In my experience a Session Facade typically interacts with a single instance of several Business Delegates during its life time.
> I have been, for sometime, been under the impression
> that the Business Delegate can be a
> singleton.
Not the Business Delegate itself, which will typically be an EJB. However the Business Delegate may interact with a constrained resource through a Singleton. A properly written singleton can readily be multi-threaded after it has been instansiated.
> Does it make sense to have a
> singleton Business Delegate when your application is
> complex enough to warrant multiple Session Facades?
Not the Business Delegate itself. But yes. I worked on an very large scale VOD project designed to deliver 10's of thousands of page impressions a minute. The markup, meta-data and content management was all served up to the sessions from a Business Delegate that accessed a Singleton implemented as a startup class.
> Or is a Business Delegate never a singleton? That
> doesn't make sense to me. Any thoughts that help
> obtain a better understanding is most appreciated.
I wouldn't say never, but making the Business Delegate a singleton seems likely to break the principle of a single responsibility. As a delegate it's purpose is to Bridge the gap between the two levels of abstraction and as such interacts with something else which does the real implementation.
> Thanks
I have never heard of the Business Delegate being an EJB. That idea seems to flow against the pattern's description. The Business Delegate pretty much acts as a proxy to an EJB at least according to the pattern's description by Sun.
Reference: http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html