Book Image

Service Oriented Architecture with Java

By : Binildas A. Christudas, Malhar Barai, Vincenzo Caselli
Book Image

Service Oriented Architecture with Java

By: Binildas A. Christudas, Malhar Barai, Vincenzo Caselli

Overview of this book

<p>Service Oriented Architecture provides a way for applications to work together over the Internet. Usually, SOA applications are exposed through web services.<br /><br />Web services have been around for a while, but complex adoption processes and poor standardization hampered their use at first. However, with the adoption of new, simpler protocols such as REST, and major companies supporting SOA, the time is now right to adopt these standards.<br /><br />This book will show you how to build SOA, web services-based applications using Java. You will find out when SOA is the best choice for your application, how to design a sound architecture, and then implement your design using Java.<br /><br />The book covers the important web services protocols: XML-over-HTTP, REST, and SOAP. You will learn how to develop web services at all levels of complexity and for all kinds of business situations.</p>
Table of Contents (11 chapters)

Application Architecture


At the most granular level in a system, you will always find sets of applications running to achieve some business goals. These applications are developed using different kinds of blueprints that we refer to as architecture. They provide an abstract view of the entire application, or let us say a high-level overview of the system.

Application architecture can be considered as a representation of the structure of components and the interaction between them in the system. They provide a framework within which the business objectives are represented.

The previous figure shows a typical architecture of a web-based application. The business requirements are converted into a high-level design where the:

  • First layer of 'HTML or JSP' acts as the presentation layer.

  • The business logic is encapsulated in the middle layer that could be built on Servlets or EJB.

  • Finally, the data is handled in the third layer 'MySQL'

Each organization will have multiple application architectures, which would cater to the need of different business goals. These applications could be web based, or even the custom client server applications.

Client-Server Architecture

The client-server architecture also known as two-tier architecture separates the client from the server. Client is the system requesting a service from the provider (in our case, server). The client will always initiate the request, which the server processes and responds to. The client could send the request to one or more than one server at a time.

Using this architecture, you can divide the responsibilities of the requester from the provider. Earlier, as seen in monolithic systems, objectives were divided into smaller pieces, and then tightly coupled into an application. Due to this, it was difficult to process multiple clients. But, with the client-server architecture in place, business process is done within the provider. This enables multiple clients to be plugged in at the same time.

Large organizations usually have more than one application to support their business goals. These are well supported by mainframes. Mainframes act as the core business-processing unit with capacity to handle large chunks of data transactions. Other computers in the organizations access the mainframe to achieve the business goals. So in a way, the mainframes act as a server, and cater to different clients across the organization. With the advent of monolithic computing, where applications were tied to the data sources, the client-server architecture had become a welcome sign for the industry.

The main advantage of the client-server architecture is that it is scalable. With minimal performance impact, either the client or the server could be added.

Client-server architecture can be divided further into 1, 2, 3....n-tier architecture. We will glance through each of these. The architecture is made up of three basic layers — the presentation layer, the business layer, and the database or services layer.

Presentation layer is the one with which the client will interact. The consumer shall either move through a click-based solution, or will input data into the front-end to initiate the business process.

This layer could either be a thin or a fat client.

Business layer will enumerate the consumer action(s) and process the information supplied by the 'presentation layer' to accomplish a business goal with a set of business rules.

Data layer stores the data and logic that would be used to successfully achieve business goals.

1-Tier Application

The single tier application would have the three layers, that is, the presentation, the business, and the data layer tightly coupled which runs out of a single processing unit. The application is designed in a way that the interaction between the layers is interwoven.

Within the tenets of client-server architecture, the single tier application can share the data layer in a multi-user environment and achieve the client-server capabilities. The limitations of 1-tier application in client-server architecture are as follows:

  • Changes to the database, in case it is being edited by multiple users

  • Difficulty in scalability, as the application is running on a single machine.

2-Tier Application

Within the 2-tier application, the presentation and the business layer combine on the client side, while the data layer acts as the server. This enables the business logic to be separated from the data services.

The 2-tier application would generally consist of a 'fat' client and a 'thin' server - 'fat' client because it will embed the presentation as well as the business logic of the application, and a 'thin' server, as it will only cater to the data needs of the client.

Another flavor of the 2-tier application can be a 'thin' client and a 'fat' server. This would have the presentation logic served in the 'client'. The business logic and data logic reside on the 'server'.

As the business logic was independent of the presentation logic, it enabled different forms of GUI to connect to a particular business process. The GUI would be served as a simple HTML application, or it could be any form of complex presentation logic.

3-Tier Application

Within a 3-tier application, the business layer would reside between the presentation layer and the data layer. This enables the presentation logic to be independent of the data layer, and all its communication will happen through the business layer only.

The business layer is usually multi-threaded so that multiple clients can access the business process. Typically, these business processes take up client calls, convert them to database queries, and then call the data layer. Subsequently, it will translate the response from the data layer and pass it to the presentation layer.

The critical advantages of the 3-tier application are:

  • The business layer can be multithreaded, which enables multiple clients to access the business functions.

  • Enables the presentation layer to be light weight, as it does not have to take care of the database queries.

  • The components in each layer are re-usable.

  • Each of the layers is easily scalable. Thus, it enables load balancing and clustering.

N-Tier application

An n-tier application will usually have more layers than the 3-tier application. Typically, the business logic from the middle layer would get structured in two different layers. Some part of the business logic will reside in the application server that connects to the data layer and the other part of the business logic shall remain in a web server, which will connect to the presentation layer.

In a typical web-based solution, the client will have access to the business through a browser. The browser in turn will call the business logic in the web-server. The web server will subsequently transfer the calls to the application server, which effectively sends the request to the data layer.

Advantages of having n-tier application:

  • N-tier application will offer the advantages of distributed computing.

  • Each of the tiers can reside in a different system.

  • The division of labor would help in reducing load from each of the tiers.

  • Higher code maintainability can be achieved, which will reduce the number of errors.