Sunday, August 29, 2010

Famous J2EE (Java EE) Design Patterns

As most of my friends and juniors occasionally ask about frequently and popular J2EE patterns. So I thought of listing down patterns which every Java developer or designer should know. I'm dividing patterns into presentation, business and integration tier.

List of popular patterns & its usage which comes under Presentation Tier:
1. Intercepting Filter:
  • It can be used when there is a requirement of centralized and common processing across requests
  • When pre and post processing is required across or selected requests
2. Front Controller (& Application Controller):
  • When there is a requirement of common logic to multiple requests
  • When there is a requirement of separate processing logic from the presentation view
  • When there is a requirement of centralized controlled access points
3. View Helper:
  • When template based views is required like JSP, Apache Velocity etc
  • When separate programming logic from view
4. Service To Worker:
  • Service To Worker = Front Controller + Application Controller + View Helper
  • Any presentation framework like Apache Struts

List of popular patterns & its usage which comes under Business Tier:
1. Business Delegate:
  • When business-tier access from presentation-tier
  • Hides service creation, invocation
2. Service Locator:
  • Patterns can be used when lookup to any enterprise resource like JNDI lookup, JMS, web services etc
  • When requirement of centralized and reuse (cache or reestablish connection) lookup
3. Session Facade:
  • When requirement is to avoid direct client access to application's business-tier
  • When requirement is to hide complex integration of business components
4. Transfer Object:
  • When requirement is to access component of different tier to retrieve and update data
  • When requirement is to reduce remote requests across the tier and network (enhance network performance)
5. Value List Handler:
  • When requirement is to avoid the overhead of using EJB "finder" methods
  • Requirement of an efficient search and iterate searched data
  • Cache search result on the server side

List of popular patterns & its usage which comes under Integration Tier:
1. Data Access Object:
  • Requirement of uniform data access APIs
  • Requirement of decouple persistent storage from other tier
2. Service Activator:
  • Requirement is to call business service, EJBs in an asynchronous manner
  • Requirement is to plug topic and point-to-point messaging to enable async process
3. Web Service Broker:
  • It is like exposing services to client i.e. web service
Above are main patterns which generally been used in J2EE based application. Some patterns which internally been used by frameworks like Apache Struts and Java EE components like JPA.

3 comments:

Krishna said...

Please read this article:
EJB 3.0 Transaction

Javin Paul said...

Thanks for sharing Gaurav. Patterns are good to know. I have also shared my view on core Java patterns like Singleton Pattern , Decorator Pattern and Factory Pattern in java, let me know how do you find it.

malini ecorp said...

Ecorptrainings.com provides J2EE in hyderabad with best faculties on real time projects. We give the best online trainingamong the J2EE in Hyderabad. Classroom Training in Hyderabad India