Recent Posts

Friday, 7 June 2019

Introduction to Spring



What is Enterprise?
     It is a business organization, it is a group of organizations running under single label.

What is Enterprise Application?
    It is a software application prepared for an enterprise in order to simplify their business processing.

     To prepare Enterprise Applications, we have to provide the following three layers.

1. User Interface Layer
☀ User Interface layer is the topmost layer in enterprise application.
☀ It will provide starting point to the users in order to interact with enterprise application.
☀ It will provide very good environment to get data from users to submit data to server-side application.
☀ It will provide very good environment to perform client-side data validations with java script functions.
☀ User interface will provide very good environment to send different request types from client o server like GET, POST, HEAD etc.
☀ To prepare User Interface layer, we have to use a separate logic called as "Presentation Logic".
☀ In Enterprise Application development, to prepare presentation logic we have to use the technologies like AWT, SWING, html, JSPs, Velocity, Free Marker etc.

2. Business Processing Layer
☀ It is heart of the enterprise application, it can be used to define and execute all business rules and regulations which are required by the clients actually.
☀ In Enterprise Application development, to prepare Business Processing layer we have to use a separate logic called as "Business Logic".
☀ To provide Business Logic we have to use the technologies like Servlets, EJBs, DAOs.

3. Data Storage and Access Layer
☀ This layer is bottom most layer in enterprise applications, it will provide very good environment to interact with databases in order to perform persistence operations.
☀ To prepare this layer in enterprise applications we have to use a separate logic called as "Persistence Logic".
☀ To provide persistence logic we have to use a set of technologies like JDBC, EJBs-Entity Beans, Hibernate etc.
System Architecture
     To define level or height of the enterprise applications we have to use System Architecture. Mostly there are 4 types of System Architectures.
1-Tier Architecture.
2-Tier Architecture.
3-Tier Arch.
n-Tier Arch.

1-Tier Architecture
☀ In 1-Tier Arch, we have to prepare and execute the complete enterprise application with in a single machine.
☀ In 1-Tier Arch, all the enterprise application layers like presentation Layer, Business Layer and Persistence layer must be provided in a single machine, no separation between all the layers, it will provide tightly coupled design in enterprise applications, it is not suggestible.
☀ In 1-Tier arch, the complete enterprise application must be executed in a single machine, where single machine resources may not be sufficient to manage the complete enterprise application, it may affect the application performance.
☀ 1-Tier Arch is suggestible for Standalone Applications, not for enterprise Applications or distributed Applications.
☀ In 1-Tier Arch, Shareability and Reusability are very less, it may increase application length.
☀ In 1-Tier Arch, multi user environment is not existed, only Single user environment is existed. 


2-Tier Architecture 
☀ In 2-Tier Arch, we have to distribute the complete enterprise application over two machines.
☀ In 2-Tier Arch, Tier-1 machine is able to manage presentation logic and Business Logic, Tier-2 machine is able to manage Persistence Logic.
☀ In 2-Tier Arch, we are able to get loosely coupled design when compared with 1-Tier Arch, because, Persistence layer is separated from Presentation layer and Business Layer.
☀ In 2-Tier Arch, database components are shared to client applications, so that, shareability and Reusability are increased.
☀ 2-Tier Arch will provide multi user environment to access application.

Note: If want to use 2-Tier arch for web applications then we have use Tier-1 is for client, it has to manage presentation layer and Tier-2 is for Server, it has to manage Business Layer and Persistence Layer. 
3-Tier Architecture 
☀ This arch will propose to use three machines in order to execute the complete enterprise application.
☀ In 3-Tier Arch, we will provide Presentation Layer at Tier-1 Machine, Business Layer at Tier-2 machine and Persistence layer at Tier-3 machine.
☀ 3-Tier arch will provide more loosely coupled design to design applications.
☀ 3-Tier Arch will provide Multi User environment, it will improve shareability and Reusability.
☀ 3-Tier arch will improve application Server components shareability and database components shareability.

Note: If we increase no of Tiers in applications then flexibility will be increased, but maintenance cost will be increased. In enterprise applications we have to increase no of ties as per the purpose only, we must not increase no of tiers unnecessarily.

There are two types of Enterprise Applications.
1. Web applications [Web Related Distributed Applications]
2. Distributed Applications [Remote based Distributed Applications].

Differences between Web Applications and Distributed Applications?
1. Web Application is a Client-Server Application, where the complete application logic is distributed over Server machine.
Distributed Application is a client-server Application, where the complete application logic is distributed over Client machine and Server machine.

2. To prepare web applications, we will use a set of technologies called as web technologies.
E.g. Servlets, JSP etc.
To prepare Distributed Applications, we will use a set of technologies called as Distributed technologies.
E.g. Socket programming, RMI, CORBA, EJBs, Web Services etc.

3. The main intention of Web applications is to generate dynamic response from server.
The main intention of Distributed Applications is to establish Communication between local machine and remote machine in order to get Remote Services from Remote machine.

4. Web applications are executed by both web servers and application servers.
Distributed applications are executed by only application servers.

5. Web application is the collection of web components like servlets, JSP etc. which are executed by web containers.
Distributed Application is the Collection of distributed components like EJBs, which are executed by EJB Container.

6. In web applications, Client is fixed, that is, Browser.
In Distributed Applications, Client is not fixed, it may be a normal java program with main () method, it may be a GUI Application, it may be a Servlet program, it may be a JSP program etc.

     To prepare web applications, SUN Microsystems has provided the following Modeled Architecture.
1. Model-I Architecture.
2. Model-II Architecture.

1. Model-I Architecture
☀ In Model-I Web Application Arch, we will use a JSP page as controller as well as Presentation part and a Java Bean component is acting as Model Component.
☀ In Model-I web application Arch, a JSP page is acting as Controller to control the complete web application, so that, Model-I Web application Arch is also called as "Page-Centric Arch".
☀ In Model-I web application Arch, a JSP page is taking responsibility to take requests from client, so that, Model-I web application Arch is also called as "JSP Front".
☀ In Model-I web application Arch, we will use JSP pages as Controller and for presentation, there is no clear-cut separation between Controller logic and presentation logic, it will provide tightly coupled design in web applications, it is not suggestible in web applications.
☀ In Model-I web application Arch, a JSP page is acting controller, to perform controller functionalities the existed JSP features are not sufficient, where it is required to write java code inside JSP pages, it is against to JSP rules and regulations.
Model-II Architecture
☀ In Model-II web application Arch, we will use a Servlet as controller, a set of JSP pages as View part and Java bean, DAO, JDBC etc. as used as Model Components.
☀ In Model-II Arch, a servlet is acting as controller to control the complete web applications, so that, Model-II web Arch is called as "Servlet-Centric Arch".
☀ In Model-II Arch, a servlet is taking responsibility to take all the requests from Client, so that, Model-II Arch is also be called as "Servlet Front Arch".

Note: Model-II Arch is an implantation of MVC Arch, on the basis of Model-II Arch only the web frameworks like Struts, JSF etc. are designed.

Rules and regulations of MVC Architecture
1. MVC is a design pattern, it will define a standard template to prepare web applications.
2. MVC will define standard flow of execution to prepare web applications.
3. In MVC based web applications, we must use a Servlet as controller and a set of JSP pages as view part.
4. In MVC based web applications, we must provide single controller per application.
5. In MVC based web applications, Controller component must take all the requests which are coming from clients and View part must take the responsibility to generate response to client.
6. IN MVC based web applications, both controller and view part are not responsible to interact with database, they have to interact with database through Model component.
7. In MVC based web applications, Controller is able to set data to model component, not to get data from model component and View part is able to get data from model component, not to set data to Model component.
8. IN MVC based web applications, we can provide any no of pages as view part, but we must provide all the pages as Java code less.
9. IN MVC based web applications, we can provide no of pages as view part, where we must not provide page-to-page communication directly, where we have to provide page-controller-page communication.

     In general, from application to application, some components like Controller, Servlet and some generic Services like Internationalization, Security, Data Validations etc. are very mush common, these common components may provide 70% implementation in the complete enterprise application. In the above context, if any third-party organization is providing the common 70% implementation then developers may take responsibility to provide the remaining 30% of the implementation. In the above situation, some third-party organizations like Apache Software Foundations, Soft Tree etc. has provided the common 70% of the implementation in the form of their own products called as "Frameworks".

☀ Framework is a pre-fabricated Software component that programmer can reuse, share and customize in order to simplify enterprise application development.
☀ Framework is a semi implemented application, it will provide very good environment to prepare enterprise applications as per developer's convenience.
☀ Framework is the Collection of Tools and APIs, it will provide very good environment to prepare enterprise applications in simplified manner.
     In enterprise application development, Frameworks will provide the following advantages.
1. Frameworks will define standard template to design applications.
2. Frameworks will define a fixed flow of execution between the components.
3. Frameworks provide parallel development and modularization.
4. Frameworks will provide all the commonly used generic services like I18N, Security, Exception handling, Data validations etc.
5. Frameworks will reduce development time.
6. Frameworks will reduce application development cost.
7. Frameworks will increase productivity.

There are two types of Frameworks.
1. Web Frameworks
2. Application Frameworks

1. Web Frameworks
     Web frameworks will provide environment to design and execute only web applications.
E.g. Struts, JSF, Xwork2,

2. Application Frameworks
     Application Frameworks will provide very good environment to prepare all the types of applications like Standalone Applications, Web Applications, Distributed Applications.
E.g. Spring

Next Tutorial : Differences between Struts, JSF and Spring

1 comment: