Professional Documents
Culture Documents
Pattern Definition
Pattern is a best practice solution to a common recurring problem Pattern describes a recurring problem Pattern describes a typical solution to the problem Patterns are collective knowledge Patterns are great vehicle to share knowledge with more people
Pattern Benefits
Provides a high level language for design discussions Provides a well tested solution for a common problem Helps provide some design work Combinations of patterns tend to provide for reusable architecture frameworks
Pattern History
Christopher Alexander: A Pattern Language 1977 Gamma, etc (Gang of Four, GoF): Design Patterns: Elements of Reusable ObjectOriented Software 1994
Structural
Decorator Adapter
Behavioral
Strategy Chain of Responsibility
Session Facade
Benefits:
Lower network overhead Separation of business logic from presentation Inherent transaction support Promotes reusability Looser coupling
Situation in Enterprise
Need to execute a number of session and entity beans in a context of the same transaction Immediate response is not required Client does not have to be required to wait end of execution
Situation in Enterprise
Solutions
Use Session Faade Pattern
Solves the following problems:
Coupling Performance Maintainability Data integrity
Reliability
If a transaction fails, then the MDB can push the message back into destination; the message will be re-delivered
Disadvantages:
Propagate results back to client Cannot perform compile time type checking
Solution:
Place responsibility for creation/consumption of DTOs onto DTO Factories
Multiple applications can reuse the same persistence layer as long as they provide DTO Factories with appropriate logic
Tradeoffs:
No compile time checking Not OO Client may need to know DB structure (can be remedied by Session Facade Pattern)
Benefits:
No transaction dependency DBMS cache mechanism used Simple to join data
Tradeoffs:
Bug prone No compile time type checking Tight coupling of client and persistence layers
Disadvantages:
Extra work for developers
EJBHomeFactory Pattern
Solution:
Provide a factory class, which encapsulates all of the lookup code, and potentially caches home interfaces Usually implemented as Singleton Example:
Account acc = BusinesInterfaceFactory.getInstance().getInterf ace(com.acme.Account.class);
All of the factory parameters for JNDI lookups are stored in the configuration of a factory.
EJBHomeFactory Pattern
Can be used in conjunction with Abstract Factory Pattern to make creation of business interfaces completely transparent to client code
Pattern Categories
EJB Layer
Session Faade Message Faade EJB Command Data Transfer Object Factory Generic Attribute Access Business Interface DTO Data Transfer HashMap Data Transfer RowSet Version Number JDBC for Reading Data Access Command Bean Dual Persistence Entity Bean (CMP/BMP) EJB Home Factory Business Delegate
Transaction/persistence