Wednesday, November 18, 2015

Struts

 Q1. Explain Struts.

Struts is open source software used to develop java based web page.
  • Struts uses Jakarta Packages, Java Servlets, JavaBeans, ResourceBundles, and XML
  • Struts takes the help of Model View Controller (MVC) architecture. Where Model is referring to business or database, View is referring to the Page Design Code, and Controller is referring to navigational code.

 Q2. What is Action Class?

An Action class in the struts application is used to handle the request.
  • It acts as interface or communication medium between the HTTP request coming to it and business logic used to develop the application.
  • Action class consists of RequestProcessor which act as controller. This controller will choose the best action for each incoming request, generate the instance of that action and execute that action.
  • This should be in thread-safe manner, because RequestProcessor uses the same instance for no. of requests at same time.

Q3. What is Struts Validator Framework?

Struts Validator Framework enables us to validate the data of both client side and server side.
  • When some data validation is not present in the Validator framework, then programmer can generate own validation logic, this User Defined Validation logic can be bind with Validation Framework.
  • Validation Framework consist of two XML configuration Files:
    o Validator-Rules.xml file
    o Validation.xml file

Q4. What is the need of Struts?

We need Struts in Java because of following reasons:
  • Helps in creation and maintenance of the application.
  • Make use of Model View Controller (MVC) architecture. Where Model is referring to business or database, View is referring to the Page Design Code, and Controller is referring to navigational code.
  • Enables developer to make use of Jakarta Packages, Java Servlets, JavaBeans, ResourceBundles, and XML

Q5. What are the classes used in Struts?

Struts Framework consists of following classes:
  • Action Servlets: used to control the response for each incoming request.
  • Action Class: used to handle the request.
  • Action Form: it is java bean, used to referred to forms and associated with action mapping
  • Action Mapping: used for mapping between object and action.
  • Action Forward: used to forward the result from controller to destination.

Q6. How exceptions are handled in Struts application?

Exceptions are handled in struts by using any one of the following two ways:
  • Programmatically handling: In this exception are handled by using try and catch block in program. Using this programmer can define how to handle the situation when exception arises.
  • Declarative handling: In this exception handling is done by using the XML file. Programmer defines the exception handling logic in the XML file. There are two ways of defining the exception handling logic in the XML file:
    -Global Action Specific Exception Handler Definition.
    -Local Action Specific Exception Handler Definition.

Q7. What is MVC?

Model View Controller (MVC) is a design pattern used to perform changes in the application.
  • Model: Model is referring to business or database. It stores the state of the application. Model has no knowledge of the View and Controller components.
  • View: View is referring to the Page Design Code. It is responsible for the showing the result of the user’s query. View modifies itself when any changes in the model happen.
  • Controller: Controller is referring to navigational code. Controller will chose the best action for each incoming request, generate the instance of that action and execute that action.

Q8. Describe Validate() and reset() methods.

Validate() Method: this method is used to validate the properties after they are explored by the application.
  • Validate method is Called before FormBean is handed to Action.
  • This method returns a collection of ActionError.
  • Syntax of Validate() Method:
    public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
Reset() Method: this method is called by the Struts Framework with each request that uses the defined ActionForm.
  • Used to reset all the data from the ActionForm
  • Syntax of Reset() Method:
    public void reset() {}

Q9. What design patterns are used in Struts?

There are following types of design patterns are used in Struts:
  • Service to Worker
  • Dispatcher View
  • Composite View (Struts Tiles)
  • Front Controller
  • View Helper
  • Synchronizer Token

Q10.What is the difference between session scope and request scope when saving FormBean?

The difference between session scope and request scope when saving FormBean are following:
  • In Request Scope, values of FormBean are available to current request but in Session Scope, values of FormBean are available throughout the session.

Q11.What is the different actions available in Struts?

The different kinds of actions in Struts are:
  • ForwardAction
  • IncludeAction
  • DispatchAction
  • LookupDispatchAction
  • SwitchAction

Q12.What is DispatchAction?

The DispatchAction enable the programmer to combine together related function or class.
  • Using Dispatch Action programmer can combine the user related action into a single UserAction. like add user, delete user and update user
  • DispatchAction execute the action based on the parameter value it receives from the user.

Q13. How to use DispatchAction?

We can use the Dispatch Action we executing following steps:
  • Create a class that extends DispatchAction.
  • In a new class, add a method: method has the same signature as the execute() method of an Action class.
  • Do not override execute() method.
  • Add an entry to struts-config.xml

Q14. .What is the difference between ForwardAction and IncludeAction?

The difference between ForwardAction and InculdeAction are:
  • IncludeAction is used when any other action is going to intake that action whereas ForwardAction is used move the request from one resource to another resource.

Q15.What is difference between LookupDispatchAction and DispatchAction?

The difference between LookupDispatchAction and DispatchAction are given below:
  • LookupDispatchAction is the subclass of the DispatchAction
  • Actual method that gets called in LookupDispatchAction whereas DispatchAction dispatches the action based on the parameter value.

Q16.What is LookupDispatchAction?

The LookupDispatchAction class is a subclass of DispatchAction
  • The LookupDispatchAction is used to call the actual method.
  • For using LookupDispatchAction, first we should generate a subclass with a set of methods.
  • It control the forwarding of the request to the best resource in its subclass
  • It does a reverse lookup on the resource bundle to get the key and then gets the method whose name is associated with the key into the Resource Bundle.

Q18. What is the use of ForwardAction?

The ForwardAction is used when we want to combine Struts with existing application.
  • Used when we want to transfer the control form JSP to local server.
  • Used to integrate with struts in order to take benefit of struts functionality, without writing the Servlets again.
  • Use to forward a request to another resource in your application

Q19.What is IncludeAction?

The IncludeAction is used to integrate the one action file in another action file.
  • It is same as ForwardAction but the only difference is that the resource is present in HTTP response.
  • Is used to combine the Struts functionality and control into an application that uses Servlets.
  • Use the IncludeAction class to include another resource in the response to the request being processed.

Q20. What are the various Struts tag libraries?

The various Struts tag libraries are:
  • HTML Tags: used to create the struts input forms and GUI of web page.
  • Bean Tags: used to access bean and their properties.
  • Logic Tags: used to perform the logical operation like comparison
  • Template Tags: used to changes the layout and view.
  • Nested Tags: used to perform the nested functionality
  • Tiles Tags: used to manages the tiles of the application

Q21. What is the life cycle of ActionForm?

The lifecycle of ActionForm is as follows:
  • Retrieve or Create Form Bean associated with Action
  • "Store" FormBean in appropriate scope (request or session)
  • Reset the properties of the FormBean
  • Populate the properties of the FormBean
  • Validate the properties of the FormBean
  • Pass FormBean to Action

Q22. What are the loop holes of Struts?

The drawbacks of Struts are following:
  • Absence of backward flow mechanism.
  • Only one single controller Servlets is used.
  • Bigger learning curve
  • Worst documentation
  • No exception present in this framework
  • Less transparent
  • Rigid approach.
  • With struts 1, embedding application into JSP can’t be prevented.
  • Non-XML compliance of JSP syntax

Q23. Difference between Html tags and Struts specific HTML Tags

Difference between HTML tag and Struts specific HTLM tags are:
  • HTML tags are static in nature but Struts specific HTML tags are dynamic in nature.
  • HTML tags are not User Defined whereas Struts tags can be user defined.
  • HTML tags provide the different templates and themes to the programmer whereas Struts specific HTML tag provides the integrating the property value with the Formbean properties.
  • HTML tags are integral part of Struts whereas Struts have HTML tag libraries.

Q24. What is the difference between session scope and request scope when saving FormBean?

The difference between session scope and request scope when saving FormBean are following:
  • In Request Scope, values of FormBean are available to current request but in Session Scope, values of FormBean are available throughout the session.

Q25. How to display validation errors on JSP page?

Validation error: Validation error are those error which arises when user or client enters the invalid format data into the form. For this validation of data struts enables the programmer with the Validator() method which validates both the data from client side and the server side.
We can display all error in the JSP page by using the following syntax in the code.
SYNTAX: <html:error/>

Q26. How to use forward action to restrict a strut application to MVC?

We can use the ForwarAction to restrict the Struts application to Model View Controller by following coding:
<global-forwards>
<statements>
<forward name="CitizenDetailsPage"
path="/gotoCitizenDetails.do" />
</global-forwards>

<action-mappings>
<statements>
<action path=”/gotoCitizenDetails”
parameter=”/CitizenDetails.jsp”
type=”org.apache.struts.actions.ForwardAction” />
</action-mappings>

Q27. What is ActionMapping?

In action mapping is the mapping of the action performed by the user or client on the application.
-We specify the action class for a specific user’s action. Like we provide the path or URL and different view based on user event.
-We can also define where control of the page deviate in case of validation error in the form.
-We can include ActionMapping in code like this:
<action-mappings>
<action path="/a" type=myclasse.A name="myForm">
<forward name="Login" path="/login.jsp"/>
<forward name="error" path="/error.jsp"/>
</action-mappings>

Q28. What is role of Action Class?

An Action class in the struts application is used to handle the request.
  • It acts as interface or communication medium between the HTTP request coming to it and business logic used to develop the application.
  • Action class consists of RequestProcessor which act as controller. This controller will choose the best action for each incoming request, generate the instance of that action and execute that action.
  • This should be in thread-safe manner, because RequestProcessor uses the same instance for no. of requests at same time.

Q29. How to combine the Struts with Velocity Template?

We can combine Struts and Velocity template by performing following steps:
1. Set classpath to Velocity JARs
2. Make web.xml file to identify the Velocity servlet.
3. Select Velocity toolbox.xml in WEB-INF directory.
4. Modify struts-config to point its views to Velocity templates instead of JSPs.
5. Create a Velocity template for each page you want to render.

Q31. In how many ways duplicate form submission can occurs?

The submission form can be duplicated by the any of the following ways:
  • Using refresh button.
  • By clicking submit button more than once before the server sent back the response.
  • By clicking back navigation button present in browser.
  • The browser is restores to submit the form again.
  • By clicking multiple times on a transaction that is delayed than usual.

Q32. What is the difference between Struts 1 and struts2?

The difference between struts1 and struts2 are below:
  • Struts1 uses ActionServlet as Controller where as Struts2 uses Filter as a controller.
  • Struts1 uses the ActionForm for mapping the JSP forms but in struts2 there no such ActionForm.
  • Struts1 uses Validation() method to validate the data in the page forms where as struts 2 validation of data is ensure by Validator Framework.
  • In Struts 1 the bean and logic tag libraries are often replaced by JSTL, but Struts 2 has such tag libraries that we don’t need to use JSTL.

Q33. What are the steps used to setup dispatch action?

To setup the dispatch action the following steps are used:
  • Create a subclass for DispatchAction.
  • Create method for logical action and their related actions.
  • Request Parameter is created for each action.
  • Define ActionMapping.
  • The JSP takes on the subclass defined for dispatch action method names as their values

Q34. What is difference between Interceptors and Filters?

The difference between Interceptors and filter are below:
  • Filters are based on Servlet Specification whereas Interceptors are based on Struts2.
  • Filters are executed only when patter matches whereas Interceptors executes for all request qualifies for a front controller.
  • Filters are not Configurable method calls whereas Interceptors methods can be configured.

Q35. What are the Custom tags?

Custom Tags are User Defined Tags, which means that user can create those tags depending upon their need in the application.
  • When a JSP page consisting of user- defined or custom tag is translated into a Servlet, the custom is also get translated into operation
  • Help in fast development of the application due to custom tag reusability.

Q36. What is the difference between empty default namespace and root namespace?

The difference between the empty default namespace and root name space are:
  • When namespace attribute is not defined then it is referred to as Empty Default Namespace whereas when name space attribute is assign with forward slash(/) then it is referred to as Root Name Space.
  • The root namespace must be matched.

Q37. What is the difference between RequestAware and ServletRequestAware interface?

The difference between RequestAware and ServletRequestAware are:
  • RequestAware enables programmer with the attributes in the Servlet Request as a map whereas ServletRequestAware enables programmer with HttpServletRequest object.
  • ServletRequestAware are more flexible than RequestAware.
  • ServletRequestAware makes action class highly coupled with Servlet environment which is not possible in RequestAware.

Q38. What are inner class and anonymous class?

Inner class: classes that are defined within other classes.
  • The nesting is a relationship performed between two different classes.
  • An inner class can access private members and data.
  • Inner classes have clearly two benefits:
    o Name control
    o Access control.
    Anonymous class: Anonymous class is a class defined inside a method without a name.
  • It is instantiated and declared in the same method.
  • It does not have explicit constructors.

Q39. What is struts.devMode?

The struts.devMode is used to make sure that framework is running in development mode or production mode by setting true or false. struts.devMode is set to false in production phase to reduce impact of performance. By default it is "false". It is used because of the following reasons:
  • Resource Reloading: Resource bundle reload on every request
  • Modification: struts.xml can be modified without restarting or redeploying the application
  • Error Handling: The error occurs in the application will be reported, as oppose to production mode.

Q40. What are action errors?

Action error: when user or client submits the incorrect or invalid data in the application, then these errors are known as Action error.
  • Action errors are generated by the clients.
  • Action error should be determined as soon as possible.
The impacts of such Action Error are:
  • Wastage of server time and resources.
  • Negative impact on code quality.

Tuesday, October 20, 2015

Design Patterns

What are Design Patterns?
Design patterns represent the best practices used by experienced object-oriented software developers. Design patterns are solutions to general problems that software developers faced during software development. These solutions were obtained by trial and error by numerous software developers over quite a substantial period of time.
What is Gang of Four (GOF)?
In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book titled Design Patterns - Elements of Reusable Object-Oriented Software which initiated the concept of Design Pattern in Software development. These authors are collectively known as Gang of Four (GOF).
Name types of Design Patterns?
Design patterns can be classified in three categories: Creational, Structural and Behavioral patterns.
·        Creational Patterns - These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new opreator. This gives program more flexibility in deciding which objects need to be created for a given use case.
·        Structural Patterns - These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
·        Behavioral Patterns - These design patterns are specifically concerned with communication between objects.

What are J2EE Patterns?
These design patterns are specifically concerned with the presentation tier. These patterns are identified by Sun Java Center.
What is Factory pattern?
Factory pattern is one of most used design pattern in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object.
In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.
What is Abstract Factory pattern?
Abstract Factory patterns work around a super-factory which creates other factories. This factory is also called as factory of factories. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object.
In Abstract Factory pattern an interface is responsible for creating a factory of related objects without explicitly specifying their classes. Each generated factory can give the objects as per the Factory pattern.
What is Singleton pattern?
Singleton pattern is one of the simplest design patterns in Java. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object.
This pattern involves a single class which is responsible to create an object while making sure that only single object gets created. This class provides a way to access its only object which can be accessed directly without need to instantiate the object of the class.
How can you create Singleton class in java?
It is two step process. First, make the constructor private so that new operator cannot be used to instantiate the class. Return an object of the object if not null otherwise create the object and return the same via a method.
What are the difference between a static class and a singleton class?
Following are the differences between a static class and a singleton class.
·        A static class can not be a top level class and can not implement interfaces where a singleton class can.
·        All members of a static class are static but for a Singleton class it is not a requirement.
·        A static class get initialized when it is loaded so it can not be lazily loaded where a singleton class can be lazily loaded.
·        A static class object is stored in stack whereas singlton class object is stored in heap memory space.

Can we create a clone of a singleton object?
Yes.
How to prevent cloning of a singleton object?
Throw exception within the body of clone() method.
Name some of the design patterns which are used in JDK library?
Following are some of the design patterns which are used in JDK library.
·        Decorator patttern is used by Wrapper classes.
·        Singleton pattern is used by Runtime, Calendar classes.
·        Factory pattern is used by Wrapper class like Integer.valueOf.
·        Observer pattern is used by event handling frameworks like swing, awt.

What is the benefit of Factory pattern?
Factory pattern encapsulates the implementation details and underlying implementation can be changed without any impact on caller api.
What is Builder pattern?
Builder pattern builds a complex object using simple objects and using a step by step approach. This builder is independent of other objects.
What is Prototype pattern?
Prototype pattern refers to creating duplicate object while keeping performance in mind. This pattern involves implementing a prototype interface which tells to create a clone of the current object.
When Prototype pattern is to be used?
This pattern is used when creation of object directly is costly. For example, an object is to be created after a costly database operation. We can cache the object, returns its clone on next request and update the database as and when needed thus reducing database calls.
What is Adapter pattern?
Adapter pattern works as a bridge between two incompatible interfaces. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces.
Give an example of Adapter pattern.
A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop.
What is Bridge pattern?
Bridge is used when we need to decouple an abstraction from its implementation so that the two can vary independently. This type of design pattern comes under structural pattern as this pattern decouples implementation class and abstract class by providing a bridge structure between them.
This pattern involves an interface which acts as a bridge which makes the functionality of concrete classes independent from interface implementer classes. Both types of classes can be altered structurally without affecting each other.
What is Filter pattern?
Filter pattern or Criteria pattern is a design pattern that enables developers to filter a set of objects using different criteria and chaining them in a decoupled way through logical operations. This type of design pattern comes under structural pattern as this pattern combines multiple criteria to obtain single criteria.
What is Composite pattern?
Composite pattern is used where we need to treat a group of objects in similar way as a single object. Composite pattern composes objects in term of a tree structure to represent part as well as whole hierarchy. This type of design pattern comes under structural pattern as this pattern creates a tree structure of group of objects.
This pattern creates a class that contains group of its own objects. This class provides ways to modify its group of same objects.
What is Decorator pattern?
Decorator pattern allows a user to add new functionality to an existing object without altering its structure. This type of design pattern comes under structural pattern as this pattern acts as a wrapper to existing class.
This pattern creates a decorator class which wraps the original class and provides additional functionality keeping class methods signature intact.
What is Facade pattern?
Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. This type of design pattern comes under structural pattern as this pattern adds an interface to existing system to hide its complexities.
This pattern involves a single class which provides simplified methods required by client and delegates calls to methods of existing system classes.
What is Flyweight pattern?
Flyweight pattern is primarily used to reduce the number of objects created and to decrease memory footprint and increase performance. This type of design pattern comes under structural pattern as this pattern provides ways to decrease object count thus improving the object structure of application.
Flyweight pattern tries to reuse already existing similar kind objects by storing them and creates new object when no matching object is found.
What is Proxy pattern?
In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern.
In proxy pattern, we create object having original object to interface its functionality to outer world.
What is Chain of Responsibility pattern?
As the name suggests, the chain of responsibility pattern creates a chain of receiver objects for a request. This pattern decouples sender and receiver of a request based on type of request. This pattern comes under behavioral patterns.
In this pattern, normally each receiver contains reference to another receiver. If one object cannot handle the request then it passes the same to the next receiver and so on.
What is Command pattern?
Command pattern is a data driven design pattern and falls under behavioral pattern category. A request is wrapped under an object as command and passed to invoker object. Invoker object looks for the appropriate object which can handle this command and passes the command to the corresponding object which executes the command.
What is Interpreter pattern?
Interpreter pattern provides a way to evaluate language grammar or expression. This type of pattern comes under behavioral pattern. This pattern involves implementing an expression interface which tells to interpret a particular context.
Give an example where Interpreter pattern is used?
This pattern is used in SQL parsing, symbol processing engine etc.
What is Iterator pattern?
Iterator pattern is very commonly used design pattern in Java and .Net programming environment. This pattern is used to get a way to access the elements of a collection object in sequential manner without any need to know its underlying representation. Iterator pattern falls under behavioral pattern category.
What are the entities of Service Locator pattern?
Following are the entities of this type of design pattern.
·        Service - Actual Service which will process the request. Reference of such service is to be looked upon in JNDI server.
·        Context / Initial Context - JNDI Context carries the reference to service used for lookup purpose.
·        Service Locator - Service Locator is a single point of contact to get services by JNDI lookup caching the services.
·        Cache - Cache to store references of services to reuse them.
·        Client - Client is the object that invokes the services via ServiceLocator.

What is Mediator pattern?
Mediator pattern is used to reduce communication complexity between multiple objects or classes. This pattern provides a mediator class which normally handles all the communications between different classes and supports easy maintenance of the code by loose coupling. Mediator pattern falls under behavioral pattern category.
What is Memento pattern?
Memento pattern is used to restore state of an object to a previous state. Memento pattern falls under behavioral pattern category.
Name the actor classes used in Memento pattern?
Memento pattern uses three actor classes. Memento contains state of an object to be restored. Originator creates and stores states in Memento objects and Caretaker object is responsible to restore object state from Memento.
What is Observer pattern?
Observer pattern is used when there is one-to-many relationship between objects such as if one object is modified, its depenedent objects are to be notified automatically. Observer pattern falls under behavioral pattern category.
Name the actor classes used in Observer pattern?
Observer pattern uses three actor classes. Subject, Observer and Client. Subject is an object having methods to attach and detach observers to a client object. We have created an abstract class Observer and a concrete class Subject that is extending class Observer.
What is state pattern?
In State pattern a class behavior changes based on its state. This type of design pattern comes under behavior pattern. In State pattern, we create objects which represent various states and a context object whose behavior varies as its state object changes.
What is Null Object pattern?
In Null Object pattern, a null object replaces check of NULL object instance. Instead of putting if check for a null value, Null Object reflects a do nothing relationship. Such Null object can also be used to provide default behaviour in case data is not available.
In Null Object pattern, we create an abstract class specifying various operations to be done, concrete classes extending this class and a null object class providing do nothing implemention of this class and will be used seemlessly where we need to check null value.
What is Strategy pattern?
In Strategy pattern, a class behavior or its algorithm can be changed at run time. This type of design pattern comes under behavior pattern.
In Strategy pattern, we create objects which represent various strategies and a context object whose behavior varies as per its strategy object. The strategy object changes the executing algorithm of the context object.
What is Template pattern?
In Template pattern, an abstract class exposes defined way(s)/template(s) to execute its methods. Its subclasses can override the method implementation as per need but the invocation is to be in the same way as defined by an abstract class. This pattern comes under behavior pattern category.
What is Visitor pattern?
In Visitor pattern, we use a visitor class which changes the executing algorithm of an element class. By this way, execution algorithm of element can vary as and when visitor varies. This pattern comes under behavior pattern category. As per the pattern, element object has to accept the visitor object so that visitor object handles the operation on the element object.
What is MVC pattern?
MVC Pattern stands for Model-View-Controller Pattern. This pattern is used to separate application's concerns.
·        Model - Model represents an object or JAVA POJO carrying data. It can also have logic to update controller if its data changes.
·        View - View represents the visualization of the data that model contains.
·        Controller - Controller acts on both model and view. It controls the data flow into model object and updates the view whenever data changes. It keeps view and model separate.

What is Business Delegate pattern?
Business Delegate Pattern is used to decouple presentation tier and business tier. 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.
·        Client - Presentation tier code may be JSP, servlet or UI java code.
·        Business Delegate - A single entry point class for client entities to provide access to Business Service methods.
·        LookUp Service - Lookup service object is responsible to get relative business implementation and provide business object access to business delegate object.
·        Business Service - Business Service interface. Concrete classes implement this business service to provide actual business implementation logic.

What is Composite Entity pattern?
Composite Entity pattern is used in EJB persistence mechanism. 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.
·        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.
·        Coarse-Grained Object - This object contains dependent objects. It has its own life cycle and also manages life cycle of dependent objects.
·        Dependent Object - Dependent object is an object which depends on coarse grained object for its persistence lifecycle.
·        Strategies - Strategies represents how to implement a Composite Entity.

What is Data Access Object Pattern(DAO) pattern?
Data Access Object Pattern or DAO pattern is used to separate low level data accessing API or operations from high level business services. Following are the participants in Data Access Object Pattern.
·        Data Access Object Interface - This interface defines the standard operations to be performed on a model object(s).
·        Data Access Object concrete class - This class implements above interface. This class is responsible to get data from a data source which can be database / xml or any other storage mechanism.
·        Model Object or Value Object - This object is simple POJO containing get/set methods to store data retrieved using DAO class.

What is Front Controller pattern?
The front controller design pattern is used to provide a centralized request handling mechanism so that all requests will be handled by a single handler. This handler can do the authentication/ authorization/ logging or tracking of request and then pass the requests to corresponding handlers. Following are the entities of this type of design pattern.
·        Front Controller - Single handler for all kinds of requests coming to the application (either web based/ desktop based).
·        Dispatcher - Front Controller may use a dispatcher object which can dispatch the request to corresponding specific handler.
·        View - Views are the object for which the requests are made.

What is Intercepting Filter pattern?
The intercepting filter design pattern is used when we want to do some pre-processing / post-processing with request or response of the application. Filters are defined and applied on the request before passing the request to actual target application. Filters can do the authentication/ authorization/ logging or tracking of request and then pass the requests to corresponding handlers.
What are the entities of Intercepting Filter pattern?
Following are the entities of this type of design pattern.
·        Filter - Filter which will performs certain task prior or after execution of request by request handler.
·        Filter Chain - Filter Chain carries multiple filters and help to execute them in defined order on target.
·        Target - Target object is the request handler.
·        Filter Manager - Filter Manager manages the filters and Filter Chain.
·        Client - Client is the object who sends request to the Target object.

What is Service Locator pattern?
The service locator design pattern is used when we want to locate various services using JNDI lookup. Considering high cost of looking up JNDI for a service, Service Locator pattern makes use of caching technique. For the first time a service is required, Service Locator looks up in JNDI and caches the service object. Further lookup or same service via Service Locator is done in its cache which improves the performance of application to great extent.
What is Transfer Object pattern?
The Transfer Object pattern is used when we want to pass data with multiple attributes in one shot from client to server. Transfer object is also known as Value Object. Transfer Object is a simple POJO class having getter/setter methods and is serializable so that it can be transferred over the network. It does not have any behavior. Server Side business class normally fetches data from the database and fills the POJO and send it to the client or pass it by value. For client, transfer object is read-only. Client can create its own transfer object and pass it to server to update values in database in one shot. Following are the entities of this type of design pattern.
·        Business Object - Business Service fills the Transfer Object with data.
·        Transfer Object - Simple POJO having methods to set/get attributes only.
·        Client - Client either requests or sends the Transfer Object to Business Object.