11/16/2010

An MVC sample


It is the presentation layer of the application. It presents the user an easy to use GUI (Graphical User Interface) to interact with the system. It refers to the View part of MVC architecture.
Struts is a controller framework. Its’ different components are: JSP, ActionServlet, Struts-config.xml, Action and Form classes. This framework adheres to MVC architecture. ActionServlet is the most important component of the framework, since it plays the role of controller, resolving the requests and the destination action classes to be invoked.
Business services embed business logic. Struts Action classes’ invoke these services to perform business functions for e.g. validating a login. These objects would invoke various methods on the Hibernate DAOs to fetch/update data.
It reads the ‘dao.xml’ (having DAOs related information). Once this is done, it can be requested for a DaoManager instance of each context (DAO) that was defined in the dao.xml. Multiple clients can reuse the DAO Manager Factory object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.
Hibernate is a powerful, ultra-high performance object/relational persistence and query service. The Hibernate Query Language, designed as a "minimal" object-oriented extension to SQL, provides an elegant bridge between the object and relational worlds.
Hibernate DAOs would form the data access layer of the application. These would contain the methods to fetch/update data from the database. These would invoke different database methods and return the results to business services.
Hibernate supports natural OO (Object Oriented) idiom. Hibernate DAOs get all the data in the form of object model from Struts action classes. Any object model contains all the information related to that business entity for e.g. Company. After retrieving information from database, DAOs would return the object model or the list of object models.
1.        High accessibility and access from any where.
2.        Achieves adaptability, flexibility and security objective.
3.        Supports multiple platforms (i.e., Windows NT, Linux,).
4.        Centralised database.
5.        Supports multiple database management systems (i.e., MS SQL Server, Oracle, DB2 etc.).
6.        All requests process through single Struts Action servlet and therefore only single servlet is loaded in the container.
7.        Use of Struts avoid hard-coding information into Java programs. Many Struts values are represented in XML or property files. This loose coupling means that many changes can be made without modifying or recompiling Java code, and that wholesale changes can be made by editing a single file. This approach also lets Java and Web developers focus on their specific tasks (implementing business logic, presenting certain values to clients, etc.) without needing to know about the overall system layout.
8.        Struts builtin capabilities make it easy to handle client side validations.
9.        DAO manager factory pattern caches DAOs and enhances performance.
10.     Adoption of industry standards: Struts and Hibernate
11.     Use of Hibernate provides vendor transparency. It means that you can easily switch from SQLServer to Oracle without having to change any of your HQL code.
12.     The big advantage of using Hibernate is that you simply don't have to worry about writing the JDBC code yourself - Hibernate does it for you in the background. Instead you can concentrate on building your business objects. And your business objects are mapped to your db schema using XML config files so changing your table structure may require nothing more than modifying the XML file.
13.     Use of Hibernate provides high-concurrency architecture with no resource-contention issues.
14.     Decoupled presentation, business and data access layers that’s why it is easy to maintain because change in one layer does not effect others.
1.        Rich GUI functions can’t be achieved easily.
2.        Struts applications are less transparent.
3.        Hibernate (Object-relational mapping tool) does not support Stored procedures.
4.        Hibernate may have overhead if you use it to manage small number of data access objects.

0 comments:

Post a Comment