Sunday 19 June 2022

Types of Container in Java

 

Types of Container :

There are four basic containers in J2EE. In that two server  containers  and two client  containers are listed below.

Applet Container

Applet container is a client container which is used to manage an execution of the applet on the browser.

1)       Application Container.

Application container is a client container which is used to manage application client and their components.

2)      EJB Container.

EJB container is a server container which is used to manage Enterprise beans components.

3)      Web Container.

Web container is also a server container which is used to manage execution of JSP pages and servlet components.

Introduction to J2EE APIS

 


(Servlet, JSP, EJB, JMS, JavaMail, JSF, JNDI)


1)       Java Servlet :The Java Servlets provides object oriented abstractions for building dynamic web applications. Servlets are server side components that are a platform independent high  performance  replacement for CGI. Like CGI, Servlets dynamically generate HEML as a result  of  a  HTTP request.

2)      Java Server Pages [JSP]

The Java Server Pages are an extension of the Servlet API that simplifies the generation of dynamic web pages by providing template driven web application development. It uses XML/HTML like tags and Java Scrip lets to encapsulate the logic required to generate pages in a platform independent way.

3)      Enterprise Java Beans [EJB]

Enterprise Java Beans are a distributed component based framework. It provides  a  standard means of defining server-side components, and specifies a run-time environment for hosting the components on the server side. There are 3 main types of EJBs : Session beans, Entity beans and Message driven beans.

4)      Java Database Connectivity :

JDBC provides platform and vendor independent access to SQL compliant databases. Basic JDBC (version 2.0) is J2SE. The J2EE platform requires, besides the basic APIs, also the JDBC 2.0 Optional Package. JDBC allows transactional querying, retrieval and manipulation of data in a JDBC drivers or you can use a ODBC-to-JDBC bridge. This means that almost every relational database available can be used on J2EE platform.

5)      Java Message Service (JMS) :

JMS provides a Java API for message queuing, and publish and subscribe types of message- oriented middleware (MOM). This API is to use if applications in a distributed environment cannot be connected all the time and the handling of the communication should be a synchronous.

6)      Java Mail :

This API provides a platform independent and protocol independent framework to build Java  based email applications. Although platform independent, Java Mail depends on an underlying email server like Send Mail or MS Exchange Server for the actual sending of an email. It uses IMAP4, POP3 and SMTP as its underlying transport mechanisms.

7)      Java Beans Activation Framework (JAF) :

The Java Beans Activation Framework is required for Java Mail. Java Mail uses JAF to determine the contents of a Multiple Internet Main Extension (MIME) message and what appropriate actions can be done accordingly.

8)      Java Naming and Directory Interface (JNDI) :

JNDI standardizes access to different types of naming services. The API is designed to be independent of any specific naming or directory service implementation.  J2SE also specifies a  JNDI service provider interface (SPI) for naming and directory service providers to implement. JNDI is not a J2EE API but a J2SE API.

9)      Java Transaction API (JTA) :

This API is for implementing distributed transactional applications.

10)   The Java Connector Architecture (JCA) :

This API has recently been included in J2EE, and provides a means to integrate J2EE application components to legacy information systems.


Sunday 12 June 2022

Enterprise Architecture styles In Java

 

Enterprise Architecture styles

Before we look into J2EE architecture, it is necessary to consider the architectural styles of contemporary distributed applications – 2-tier, 3-tier, and n-tier architecture. The purpose of this section is mainly to enable the reader to recognize the scope of and place for these patterns.

Typically client-server systems are based on the 2-tier architecture, where there is a clear  separation between the data and the presentation/business logic. Such systems are generally data-driven with the server most of time being database server, and the client being a graphical  user interface to operate on data. While this approach allows us to share data  across  the  enterprise, it does have many drawbacks.

Single-Tier Architecture

Simple software applications are written to run on a single computer. User inputs its verification, business logic and data accessed all these could be found together on single computer, this kind of architecture is called

Single Tier Architecture.

Because of all logic application services, the presentation, business rules and  the  data  access  layers exist in a single computing layer.

Advantage:

Single tier system is relatively easy to manage  and data consistency is  simple because data is  stored at only one single location.

Disadvantage:



Single storage location is not sufficient because of the changing business needs. With the single tier application we cannot share the data in the large amount; it can also not handle multiple users.

Two-Tier Architecture

§ Application  which  is  divided  into  two separate tires, client machine and database server machine is called as Two – Tier architecture application.

§ The application includes the presentation and business  logic.  Data  is  accessed  by  connecting client machine to a database which is lying on another machine.

Thin Client :

With the two tier architecture, if the presentation manager resides only with the client tier then the client is called as thin client. Other presentation logic, application logic, business logic, data logic and database manager reside with the server side.

Thick Client :

Server

Client

Request

Presentation Logic

Presentation Manager

Application

Business Logic

Database Logic

Database Manager

 

With the two tiers architecture if the presentation manager,  presentation logic, application logic reside with the client tier then the client is  called  as thick client. Others like business logic, data logic and database manager reside

with the server side.

Normal Client :

With the two tires architecture if the presentation manager and presentation logic reside with the client tier then the client is called as normal client. Others like application logic, business logic,

data logic and database manager reside with the server side.

Advantages :

Any changes made in data access logic will not  affect the presentation and business logic.  With   the two tier architecture it is easy to develop an application.

Disadvantages :

One of the disadvantages of Two – tier architecture is that the application is expected to support a limited number of users. The reason is that each client requires its own connection  and  each  connection requires CPU and memory. As the number of connections increases, the database performance degrades.

§ Another typical problem with a 2-tired approach is that of maintenance

§ Even the smallest of changes to an application might involve a complete rollout to the entire user base.


§ Even if it’s possible to automate the process, you are still faced with updating every single client installation.

Three Tier Architecture

Client

Server

Presentation                                                                    Database

Logic

Logic

Business Logic

§ In 3-tier Architecture an application is broken up into three separate logical layers, each with a well-defined set of interfaces.

§ The first tier is referred to as  presentation  layer and typically consists of a  graphical  user interface of some kind.

§ The middle tier, or business layer consists of the application or business logic.

§ And the third tier –  the  data layer    contains the data that is needed for the application

§ The middle tier (application logic ) is basically the code  that  the  user  calls  upon  to  retrieve  the  desired data.

§ The presentation layer then receives the data and formats it for display.

§  This separation of application logic from the user interface adds enormous flexibility to the design   of the application.

§ Multiple user interfaces can be built and deployed without ever changing the application logic, provided the application logic presents a clearly defined interface to the presentation layer.

§ J2EE provides several abstractions to meet the needs of each of these tiers.

§ The third tier contains the data that is needed for the application.

§ This data can consist of any source of information,  including  an  enterprise  database  such  as  oracle or Sybase, a set of XML documents, or even a directory service.

§ In addition to the traditional relational database storage mechanism, there are many different sources of enterprise data that your applications can access.

Advantages :

It improves scalability since the application servers can  be  deployed  on  many  machines.  The  database no longer requires a connection from every client – it only requires  connections  from  a smaller number of application servers. It provides better reusability  because  client  does  not  have direct access to the database.

Disadvantage :

It increases the complexity because to develop the three tier application is more difficult than developing a two tier applications.

N-Tier Architecture

As the title suggests, there is no hard  and  fast way to define the application layers for an n-tier system.

In fact, this kind of system can support a number of different configurations.

In an n-tier architecture the application logic is logically divided by function, rather than physically.

§  A  user  interface  that  handles  the  user’s interaction with the application – this  can  be  a  web browser  running  through  a  firewall,  a  heavier desktop application, or even a wireless device.

§ Presentation logic that defines what the user interface displays and how a user’s requests are handled. Depending on what user interfaces are supported, you may need  to  have  slightly  different versions of the presentation logic to handle the client appropriately.

§ Business logic that models the application’s business rules, often through interaction with the application’s data.

§ Infrastructure services that provide additional functionality required by the  application  components, such as messaging, transactional support.

§ The data layer where the enterprise’s data resides.

Advantages :

§   Separation  of  user  interface  logic  and  business  logic is done.                Business logic resides on small number of centralized machines (may be just one).

§ Easy to maintain, to manage, to scale, loosely coupled etc.

§ Additional features can be easily added.

Disadvantages :

§ It is having more complex structures and difficult to setup and maintain all the separated layers.

 

Introduction of J2EE (Advance Java)

 

An Introduction to J2EE

J2EE is Java, optimized for enterprise computing. Officially J2EE stands for Java 2 Platform, Enterprise Edition. Unlike the traditional Java, which is often used to build client enhancements, J2EE is designed to build server applications. Officially, the J2EE platform is "a set of coordinated specifications and practices that together enable solutions for developing, deploying,  and managing" such server applications.

As an enterprise platform, the J2EE environment extends basic Java with tools that "provide a complete, stable, secure, and fast Java platform to the enterprise level."

One goal often stated by developers is that by using J2EE, they're reducing  the  cost  and  complexity of creating large-scale solutions. Because Java is a strongly typed language meaning  that it requires data types to be used as specified, use of the language is often inherently more secure in Web applications than Web applications built with less strong typing such as C or even PHP and Perl.

Enterprise Architecture

The economy and technology of today have intensified the need for faster, more efficient, and larger-scale information management solutions. The J2EE specification  satisfies these challenges by providing a programming model that improves development productivity, standardizes the platform for hosting enterprise applications, and ensures portability of developed applications with an extensive test suite.

The J2EE platform uses a multitiered distributed application model for both enterprise applications. Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multitiered J2EE environment to which the application  component belongs. Following figure shows two multitiered J2EE applications divided into the tiers described in the following list.

§ Client-tier components run on the client machine.

§ Web-tier components run on the J2EE server.

§ Business-tier components run on the J2EE server.

§  Enterprise information system (EIS)-tier software runs on  the EIS server.

J2EE architecture supports component-based development of multi-tier enterprise applications. A J2EE application system typically includes the following tiers:

§ Client tier: In the client tier, Web components, such as Servlets and JavaServer Pages (JSPs), or standalone Java applications provide a dynamic interface to the middle tier.

§ Middle tier: In the server tier, or middle tier, enterprise beans and Web Services encapsulate reusable, distributable business logic for the application. These server-tier components are contained on a J2EE Application Server, which provides the platform for these components to perform actions and store data.

§ Enterprise data tier: In the data tier, the enterprise's data is stored and persisted, typically in a relational database.

Enterprise Application is designed into 6 logical  layers,  which  is  related  to  logic  of  client  tier,  middle tier and database tier. It defines which layer belongs to which tier.

§ Presentation Manager

The presentation manager defines the user interface. It always resides on the client  tier.  It  manages the information displayed to the user.

§ Presentation Logic

The presentation logic defines the navigation system of user interface, how and what will be displayed to the user. It may reside the client tier or business tier or database tier based on thin client and thick client and application tier.

§ Application Logic

Application logic defines the actual application logic it with. Application logic can be connectivity, validation etc. It may reside the client tier or business tier or database tier based on thin client and thick client and application tier.

 

§ Business Logic

The business logic layer contains the business rules of the application.  It  should  be shared with  the whole application. It may reside business tier or database tier based on thin client and thick client and application tier.

§ Database Logic


The database logic defines the table structure and the relationship between the tables. It also includes all the constraints of the table. It always reside with database tier.

§ Database Manager

The Database Manager stores the persistent data. It always resides with database tier.