EJB Design Patterns refers the best practices to be used while architecting the EJB based Enterprise J2EE application. All these design patterns fit somewhere across the layers including web presentation, business and EIS layers
EJB Design Patterns
1. JDBC for Reading
Session facade layer directly accesses the database instead of going through the layer of Entity Beans.
In Bean Managed Persistence, perform listing operations on Relational databases using JDBC. Use Entity Beans when making updates.
2. Session Facade
EJB Client will be able to execute the Use Case Business Login in one transaction and one network call.
Session facade mean wrapping the layer of entity bean with the layer of Session Beans. Client will have access to only session beans but not to entity beans.
3. Generic Attribute Access
4. Custom Data Transfer Object
5. Message Facade
EJB clients is able to invoke the methods of multiple session or entity beans within a single tranasaction without the need to block and wait for responses from each bean.
Using Message Driven Beans(MDB) a fault toletrant asynchronous facade can be created. Clients will access the MDB but not entity beans.
6. Busienss Delegate
Create an intermediary between a client and a session façade to facilitate the decoupling of the client from an EJB layer. This will be implemented by creating a layer of pure java classes that hide the EJB API complexity by encapsulating the code required to discover, delegate to and recover from invocations on the session and message façade EJB Layers.
7. Business Interface
8. Data Transfer HashMap
9. Data Access Command Bean
10. Sequence Blocks
Here integer-based incrementing primary keys will be generated in a Portable and Efficient manner
Front a sequence entity bean with a session bean that grabs blocks of integers at a time and caches them locally. Clients interact with the session bean which passes out cached keys and hides all the complexity from the other entity bean clients.
11. Data Transfer Objects
12. Data Transfer Rowset
13. Dual Persistent Entity Bean
14. UUID in EJB
Allows to generate universally unique primary keys in memory without requiring a database or a singleton.
Universally Unique Identifier(UUID) will be created that combines enough system information to make it unique across space and time.
15. Version Number
Allows to determine that the data used to update the server is STALE.
Version Numbers can be used to implement the staleness checks in case of Entity Beans
16. Data Transfer Object Factory
17. Domain Data Transfer Object
18. EJB Command
19. EJBHomeFactory
EJB Client will lookup EJB Home only once in the lifetime of it application and abstract the details of that lookup.
EJB Home lookup code is abstracted in the reusable EJBHomeFactory which can cache EJB Home for the life time of a client application.
20. Stored Procedures for Autogenerated Keys