July 03, 2017

J2EE Patterns

J2EE Design Patterns
  • MVC Pattern
  • Business Delegate Pattern
  • Composite Entity Pattern
  • Data Access Object Pattern
  • Front Controller Pattern
  • Intercepting Filter Pattern
  • Service Locator Pattern
  • Transfer Object Pattern
MVC Pattern
MVC is abbreviation of Model-View-Controller. Models are basically POJO's, which are used as blueprints/models for all of the objects that will be used in the application. Views represent the presentational aspect of the data and information located in the models. And the Controllers controls both of these.

Controller serve as a connection between the Model and View. It instantiate, update and delete models, populate them with information, and then send the data to the views to present to the end-user.

Front Controller Pattern
Upon sending a request, the Front Controller is the first controller it reaches. Based on the request, it decides which controller is the most adequate to handle it, after which it passes the request to the chosen controller. The Front Controller is most often used in Web Applications in the form of a Dispatcher Servlet.

Business Delegate Pattern
This pattern is used to decouple the presentation layer from the business layer. It is basically use to reduce communication or remote lookup functionality to business tier code in presentation tier code. In business tier we have following entities.

  • Business Service: Business Service interface. Concrete classes implement this business service to provide actual business implementation logic.
  • LookUp Service: Lookup service object is responsible to get relative business implementation and provide business object access to business delegate object.
  • Business Delegate: A single entry point class for client entities to provide access to Business Service methods.
  • Client: Presentation tier code may be JSP, servlet or UI java code.



Composite Entity Pattern
A Composite entity is an EJB entity bean which represents a graph of objects. When a composite entity is updated, internally dependent objects beans get updated automatically as being managed by EJB entity bean. Following are the participants in Composite Entity Bean.
  • Dependent Object: Dependent object is an object which depends on coarse grained object for its persistence lifecycle.
  • Coarse-Grained Object: This object contains dependent objects. It has its own life cycle and also manages life cycle of dependent objects.
  • Composite Entity: It is primary entity bean. It can be coarse grained or can contain a coarse grained object to be used for persistence purpose.
  • Strategies: Strategies represents how to implement a Composite Entity.



Service Locator Pattern
A pattern often seen in Web Applications, the Service Locator pattern is used to decouple the Service Consumers and the concrete classes like DAO implementations.

The pattern looks for the adequate service, saves it in cache storage to reduce the number of requests and therefore the strain on the server and provides the application with their instances.

-K Himaanshu Shuklaa..

No comments:

Post a Comment