Skip to main content

Java Infrastructure

J2EE Stands for Java 2 Enterprise Edition. J2EE is an environment for developing and deploying enterprise applications. J2EE specification is defined by Sun Microsystems Inc. The J2EE platform is one of the best platform for the development and deployment of enterprise applications. The J2EE platform is consists of a set of services, application programming interfaces (APIs), and protocols, which provides the functionality necessary for developing multi-tiered, web-based applications. You can download the J2EE SDK and development tools from Oracle Technology Network for Java Developers.

Introduction

This article, the first in a series, will introduce J2EE and present an overview of what it is and what it can do. In addition to this, we'll also take a look at how to get started with J2EE by presenting the steps necessary to download, install and start developing J2EE applications.
Future articles will subsequently take a look at some of the core J2EE technologies such as Java Servlets, JavaServer Pages (JSP), Enterprise JavaBeans (EJB) and the Java Message Service (JMS). Following on from this, we'll move on to take a look at J2EE from an architecture and design perspective, covering topics like best practices and design patterns.

What is J2EE?

Using the Java 2 Platform, Standard Edition (J2SE) as a basis, Java 2 Platform, Enterprise Edition (J2EE) builds on top of this to provide the types of services that are necessary to build large scale, distributed, component based, multi-tier applications. Essentially, J2EE is a collection of APIs that can be used to build such systems, although this is only half of the picture. J2EE is also a standard for building and deploying enterprise applications, held together by the specifications of the APIs that it defines and the services that J2EE provides. In other words, this means that the "write once, run anywhere" promises of Java apply for enterprise applications too:
Enterprise applications can be run on different platforms supporting the Java 2 platform.
Enterprise applications are portable between application servers supporting the J2EE specification.
What does J2EE comprise?
J2EE is comprised of many APIs that can be used to build enterprise applications. Although the total list of APIs initially seems overwhelming, it is worth bearing in mind that some are primarily used by the J2EE environment in which your application executes, while some provide services that your specific application may not require. Therefore, it is worth remembering that you don't have to use all of them in order to build J2EE applications. For completeness, however, the full list of technologies that make up J2EE is as follows:

  • Java Servlets
  • JavaServer Pages (JSP)
  • Enterprise JavaBeans (EJB)
  • Java Message Service (JMS)
  • Java Naming and Directory Interface (JNDI)
  • Java Database Connectivity (JDBC)
  • JavaMail
  • Java Transaction Service (JTS)
  • Java Transaction API (JTA)
  • J2EE Connector Architecture (J2EE-CA, or JCA)
Technologies offered by j2ee along with their applications.

From a developer perspective, the main technologies are EJB, JSP, Java Servlets, JDBC and JMS, although JNDI is used for locating EJBs and other enterprise resources. For the moment, let's take a quick look at some of these technologies before moving on to see how to get started with J2EE.

What are Java Servlets?
At a high level, Java Servlets are the Java equivalent of CGI scripts that can be used to perform processing and the servicing of client requests on a web server. From an implementation perspective, servlets are simply Java classes that implement a predefined interface. One use for servlets is that they can be used to dynamically generate content for presentation to the user, and this is achieved by embedding markup language (e.g. HTML) inside the Java code. As Servlets are written in Java, they have access to the rich library of features provided by Java, including access to databases and other enterprise resources such as EJB.

What are JavaServer Pages (JSP)?
JSP is another technology for presenting information to the user over the web and uses a paradigm where Java code is embedded into the HTML - the opposite of servlets, and much like Microsoft ASP. Pages are written as HTML files with embedded Java source code known as scriptlets.
One of the pitfalls in using JSP is that it is very easy to build large pages containing lots of embedded Java code and business logic. For this reason, JSPs provide easy integration with JavaBeans and another feature called JSP tag extensions. These custom tags (also known as custom actions) allow re-usable functionality to be encapsulated into XML-like tags that can be easily used on the pages by both page developers and designers.

What are Enterprise JavaBeans?
EJB is a major part of the J2EE specification and defines a model for building server-side, reusable components. There are three types of enterprise beans currently supported by J2EE - session beans, entity beans and message-driven beans.
Session beans can be seen as extensions to the client application and are typically used to model business processes. There are two types of session bean - stateful and stateless. Stateful session beans are typically used to record conversational state for a single client between requests, whereas stateless session beans are shared between any number of clients at any one time.

Entity beans are typically used to model persistent business entities and, in particular, data in a database. A common mapping is to model an entity bean on a table, there being one instance of that bean for every row in the table. There are two ways that persistence can be achieved - container managed and bean managed persistence. In container managed persistence, a mapping is defined at deployment time between the persistent properties in the bean and the columns in the table. With bean managed persistence, developers write the JDBC code that performs the create, read, update and delete operations.

Finally, message-driven beans allow functionality to be executed on an asynchronous basis, typically triggered by JMS messages from message-oriented middleware.

What is the Java Message Service (JMS)?
JMS is Java API that presents an interface into message-oriented middleware such as IBM MQSeries, SonicMQ and so on. Like JDBC, JMS provides Java applications a mechanism to integrate with such systems by presenting a common programming interface irrespective of the underlying messaging system. Functionally, JMS allows messages to be sent and received using a point-to-point or publish/subscribe paradigm

Comments