I copied some EJB patterns from someone's note,only for your reference.
Patterns in J2EE
General.
• Bridge
Anything that provides a generic interface to a vendor specific product –
JDBC, JMS, JNDI, JavaMail.
• Facade.
Anything that hides the complexity from the client – InitialContext, Connection, DataSource
Servlets / JSPs
• Decorator, Chain Of Responsibility
– Servlet 2.3 Filter
• Singleton - ServletContext, only one per application
JDBC
• Iterator – ResultSet
JNDI
• Iterator - NamingEnumeration, etc.
• Observer - EventContext.addNamingListener (.., NamingListener);
EJB
• Proxy, Facade - Remote interface
The stub and skeleton combined act as a proxy to a remote EJB object.
The stub and skeleton combined act as a facade – hides the networking details from the client.
• Abstract Factory - EJBHome
A client gets a reference to a home object which implements the EJBHome interface (analogous to
AbstractFactory). The client uses the home object to create an EJB object which implements EJBHome
(analogous to AbstractProduct).
N.B. with EJB the create methods only return a single Product so only one in the family
It’s tempting to say that the FactoryMethod is used in EJBHome but on balance it doesn’t quite match : the
container implementation of the EJBObject may defer creation to a subclass but it’s unlikely (create methods
are different for every EJB); the EJBObject adapts the bean class interface
• Decorator , Adapter - Remote interface
The container provides implementations for EJBHome and EJBObject. The implementations apply
transactions/security to methods before delegating the request to the bean class – e.g. create () checks if the
role is allowed to execute the method, if so bean.ejbCreate () is executed
• Facade - Session Facade (a single session bean method manipulates multiple entity beans)
• Memento - Value Objects, SFSB activation/passivation
• Command - transaction logging
• Flyweight - Instance pooling
A SLSB may contain intrinsic state (e.g. a socket connection). When a client uses a SLSB they pass in
extrinsic state (e.g. the parameters to the method call). Consequently, a small pool of objects can support a
large number of clients.
• Observer - EJB 2.0 MessageDrivenBean
• Interpreter - EJB 2.0 QL
• Template Method - EJB 2.0 CMP
Persistent fields / relationships declared as abstract methods in the bean class. The bean uses the
abstract/primitive methods in other methods. The container subclasses the bean class and implements the
abstract methods. When a client references the EJB object, they’re using the container sub-classed version.
JMS
• Mediator, Observer - Publish/Subscriber
The MOM acts as a Mediator between Colleagues, which in this case are the Subject(s) and Observer(s)
[ April 19, 2002: Message edited by: Win Yu ]