Unit 5
Unit 5
The Java 2 Platform, Enterprise Edition (J2EE) defines the standard for developing
multitier enterprise applications.
The J2EE platform simplifies enterprise applications by basing them on standardized,
modular components, by providing a complete set of services to those components, and
by handling many details of application behavior automatically, without complex
programming.
The J2EE platform takes advantage of many features of the Java 2 Platform, Standard
Edition (J2SE), such as "Write Once, Run Anywhere" portability, JDBC API for database
access, CORBA technology for interaction with existing enterprise resources, and a
security model that protects data even in internet applications.
Building on this base, the Java 2 Platform, Enterprise Edition adds full support for
Enterprise JavaBeans components, Java Servlets API, JavaServer Pages and XML
technology.
The J2EE standard includes complete specifications and compliance tests to ensure
portability of applications across the wide range of existing enterprise systems capable of
supporting the J2EE platform. In addition, the J2EE specification now ensures Web
services interoperability through support for the WS-I Basic Profile.
The Java 2 Enterprise Edition (J2EE) provides a standard for developing multitier,
enterprise services.
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.
J2EE provides a number of “supporting” APIs. The purpose of most of these APIs is to enable
interaction between the “main” software layers/components in the J2EE architecture.
•Remote Method Interface (RMI)
•Java Naming and Directory Interface (JNDI)
•Java Message Service (JMS)
•Java Transaction API (JTA)
•Java Database Connectivity (JDBC) / SQLJ
•JavaMail /JMC
Although a J2EE application can consist of the three or four tiers shown, J2EE
multitiered applications are generally considered to be three-tiered applications because
they are distributed over three different locations: client machines, the J2EE server
machine, and the database or legacy machines at the back end.
Three-tiered applications that run in this way extend the standard two-tiered client and
server model by placing a multithreaded application server between the client application
and back-end storage.
Fig 5.2 J2EE Components
J2EE components are written in the Java programming language and are compiled in the
same way as any program in the language.
The difference between J2EE components and "standard" Java classes is that J2EE
components are assembled into a J2EE application, verified to be well formed and in
compliance with the J2EE specification, and deployed to production, where they are run
and managed by the J2EE server.
Applets
A Web page received from the Web tier can include an embedded applet.
An applet is a small client application written in the Java programming language that
executes in the Java virtual machine installed in the Web browser.
However, client systems will likely need the Java Plug-in and possibly a security policy
file in order for the applet to successfully execute in the Web browser.
Application Clients
A J2EE application client runs on a client machine and provides a way for users to handle
tasks that require a richer user interface than can be provided by a markup language.
It typically has a graphical user interface (GUI) created from Swing or Abstract Window
Toolkit (AWT) APIs, but a command-line interface is certainly possible.
Application clients directly access enterprise beans running in the business tier. However,
if application requirements warrant it, a J2EE application client can open an HTTP
connection to establish communication with a servlet running in the Web tier.
5.3 Best Practices in J2ee
The most critical element of any application development philosophy is the methodology
that defines the entire application development cycle. Since methodologies used to make
modern J2EE applications are so diverse, we will not endorse any particular
methodology.Instead, we will define five relatively generic steps that any significant
development method will need to support. The best practices under each can then be
integrated into your development cycle.
The above Fig shows the major steps in a development cycle, and the areas in which Best
Practices can be applied for each step.
Development life cycle
Attack risk as early as possible
Design
Design for change with dynamic domain model
Use a standard modeling language
Recycle your resources
Develop
Use proven design patterns
Automate the build process
Integrate often
Optimize communication costs
Test
Build test cases first
Create a testing framework
Automate testing
Deploy
Use j2ee standard packaging specification
Use tools to help in deployment
Back up your production data and environment
Tune
Build a performance plan
Manage memory and plug leaks
Focus on priorities
Environments
Do not restrict deployment options at design time
Create a responsive development environment
5.4 COMPARISON BETWEEN J2EE AND .NET
Both .NET and J2EE target the enormous market for enterprise applications and Web services.
This quick-comparison provides a basic sense of advantages and disadvantages carried by both
frameworks in various areas.
Orientation
J2EE is Java-centric and platform neutral, while .NET is Windows-centric and language-neutral.
This means developers are restricted to Java language in the J2EE and Windows in the .NET
framework.
Difference in Strategies
J2EE is basically a series of standards. One the other hand, .NET is Microsoft's product strategy
based on evolution of its Visual Studio 6.0.
Industry Involvement
Sun has rallied the entire industry behind its J2EE standard, especially the top software vendors
who have adapted the J2EE interface such as BEA, IBM, and Oracle. On the other hand, .NET is
based on Microsoft's sole efforts to grab the Web services market share.
Both .NET and J2EE offer rapid application deployment features in their own way.
Some are more powerful in .NET compared with J2EE and vice versa. J2EE offers state
management services to ease up developers on writing code and managing state.
On the other hand, the real advantage behind ASP.NET is that it is independent of client
device and allows for user interfaces to be rendered to alternative user interfaces without
rewriting code.
J2EE offers solutions from multiple vendors with a wide variety of tools, products and
applications.
This does provide additional and varied functionality but at a cost
J2EE tools often times are not interoperable due to problems in portability.
On the other hand, .NET provides a complete solution of tools and services from
Microsoft, but which may lack some of the higher-end features found in J2EE solutions.
Platform Maturity
Large J2EE vendors such as BEA, Borland, Sybase offer tried and tested solutions to
their large customer base.
J2EE does have certain aspects that are new and immature such as automatic persistence
provided by EJB, Java Connector Architecture, and Web services support.
In the case of Microsoft, some of the .NET is based on Windows DNA but most of it is
rewritten as far as the new CLR is concerned.
Moreover, C# language and Web services support is new and according to many
testers, .NET VB is very different from the earlier VB version.
Hence, we can say that in the overall sense J2EE is the more mature platform.
J2EE enables eBusiness collaboration and Web services through its JAXP (Java API for
XML Parsing).
.NET does create Web services but due to its beta release it does not earn much
credibility as a realistic deployment platform.
Moreover, .NET's lack of support for ebXML poses a real problem for its industry-wide
acceptability.
Tools
Current IDEs for Java development include WebGain's Visual Cafe, IBM's VisualAge for
Java, Borland's JBuilder, etc.
These tools are not entirely interoperable because they do not originate from a single
vendor.
On the other hand, Microsoft's Visual Studio .NET has remarkable productivity features
that include Web forms, .NET's GUI component set, and much more.
The aspect of single-vendor integration, wizards, and other user-friendly features are
highly advantageous for building Web services.
Hardware Costs
Both .NET and J2EE support Win32 platform, a less expensive alternative to Unix and
Mainframe systems. In general, Microsoft's solution has an aggressive price comparative to J2EE
that offers varied price and service levels from high-end to low-end inexpensive solutions.