Tuesday, August 16, 2011

Abstract Factory, DAO Factory, DAO Design Pattern.

Image design have combination of DAO Design pattern , Factory Design Pattern, Abstract DAO Factory design pattern.
With this architecture application can use multiple database frameworks . Easy to switch frameworks to frameworks. Loose coupled.
Maintenance easy.

The Data Access Object (DAO) pattern is now a widely accepted mechanism to abstract away the details of persistence in an application. The idea is that instead of having the domain logic communicate directly with the database, file system, web service, or whatever persistence mechanism your application uses, the domain logic speaks to a DAO layer instead. This DAO layer then communicates with the underlying persistence system or service.
Here is how it looks:

 
The advantage of the DAO layer is that if you need to change the underlying persistence mechanism you only have to change the DAO layer, and not all the places in the domain logic where the DAO layer is used from. The DAO layer usually consists of a smaller set of classes, than the number of domain logic classes that uses it. Should you need to change what happens behind the scene in the DAO layer, the operation is somewhat smaller, since it only affects the DAO layer. It is also a somewhat more controlled operation, since you can search for all DAO classes, and make sure they are changed to use the new persistence mechanism.
For this encapsulation of the underlying persistence mechanism to work it is important that no details of the underlying persistence mechanism leak out of the DAO layer. Ensuring this is, however, a bit of a challenge, as I show you in the next text in this trail.

continued ....

Tuesday, August 2, 2011

Struts 1.3 Flow


Q1.         Explain the flow of the Struts 1.3?
Ans:      The user fills the fields of the form in a jsp page. The form have action name with default method ‘get’ , This form fields and the form properties  in framework should match each other. Once you completed filling the values in a jsp page and when you click the submit button, the values in a form are stored in a request body with variable names, the request name will be action name of the form. According to the servlet, the request comes to the web.xml file for routing the request. Struts maintain Front Control Design Pattern (FCD),  That means all request comes to the single servlet called ActionServlet given by struts framework. That will be the Controller of the MVC architecture. This class takes the request and Delegates it to RequestProcessor Struts provided class. The name itself indicates that this class will process the request. Here they used Action Controller Design Pattern (AC).This class will process the request as mentioned in the strutsconfig.xml.  First it compares the path name of the action tag and request name. And it matches the name in action tag to the name in the beans. There it verifies the form name. Then the control goes to the Form which extends one Form provided by struts and it creates the object and initializes the request field values to the forms by getter & setter methods. Again the control returns to the strutsconfig.xml file to the same action tag it goes to the Action class which mentioned in actiontag .That Action class must extends one of the Action Class provided by Struts. In Action class having default execute method with four parameters and ActionForward return type. The four parameters are ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse . The Action Form object contains the Values of the fields .From here the business logic will be called and will get the result back with some information. Based on the condition we set the result to the ActionMapping and returning back with ActionForward. Then the controls back to the strutsconfig.xml file where it matches the forward name and redirect to the particular jsp. And this jsp uses some tags provided by struts.Struts 1.3 flow