J2EE Umbrella

Document Sample
J2EE Umbrella Powered By Docstoc
➔ methodology

                              Under the
                              J2EE Umbrella
                              J2EE introduces a variety of key technologies aimed at making
                              development of high-end systems easier, says Bob Brown

                              Introduction                                            vendors (including Rational, TogetherSoft and Web-
       Bob Brown has          Sun Microsystems’ Java 2 Enterprise Edition (J2EE)      Gain) are stepping up to the challenge and creating
       approximately 15
       years’ experience as
                              is a specification for an open, Object-based middle-    high-end (typically UML-oriented) design tools that
       a software             ware platform that is increasingly finding favour and   make it possible to design, develop, deploy and test
       researcher and
                              application as a tool for bringing advanced function-   complex J2EE-based systems with minimal coding.
       developer, and in
       tertiary-level         ality to Web-accessible systems.                           A related issue is that Sun wants to foster a
       lecturing through-                                                             server-based, enterprise-level component market-
       out the world.
       Brown is a regular     Background                                              place (in much the same way that Microsoft has for
       presenter at confer-   From the Web’s earliest days a progression of           ActiveX and is now developing alongside its .NET
       ences and events
       and is co-author of    technologies ranging from static HTML through           platform). As J2EE advances, we should see the
       the Prentice-Hall      HTML+CGI scripts to Java-based Servlets and             development and introduction of enterprise-level
       book JAVA Thin-
       Client Program-
                              Java Server Pages has emerged. The desire to use        ‘shrink-wrapped’ software.
       ming for a             simple resources such as hit counters and direct           A final major driver underlying the J2EE’s
                              two-tier access to stored data has also evolved         development is the need for software to be
       Environment.           into the need to provide scalable multi-tier access     developed according to ‘Internet Speed’. The strong
       E-mail:                to complex database-based applications and              competitive environment that existed prior to the
       com.au                 sophisticated enterprise-level infrastructure such      Internet crash mandated the rapid development of
                              as SAP/PeopleSoft, etc.                                 correct highly functional software.
       Transentia Pty Ltd        The J2EE arose from Sun’s realisation that
       provides specialist    Internet-accessible systems are increasingly being      Availability
       consulting, develop-
       ment and training
                              called upon to provide ever more complex                Most of today’s major vendors provide J2EE-com-
       services in such       functionality in ever-shortening timeframes.            pliant application server products, including Sun
       technologies as
                                 While cherry-picking much that was good from         (naturally), BEA, IBM, Oracle, HP and Borland. A
       J2EE, Java, Linux,
       CORBA and XML.         various earlier distributed systems development         number of less well-known players such as Pramati,
       Visit: http://www.     platforms (notably CORBA), the J2EE represents a        Orion and Lutris also offer quality products perhaps
                              simplified (but nonetheless extremely powerful)         equally capable in many respects but typically at a
                              technology that is augmented with a smattering of       much lower cost than for those available from the
                              modern object-based ideas.                              first-tier vendors. The Open-Source community is
                                 Tool support for building network-based systems      also well represented with the extremely popular
                              has always been woefully lacking, making it very        JBoss application server which, although not an offi-
                              hard to design and model complex systems. To            cially certified J2EE platform, is still widely used and
                              address this, Sun is attempting to make J2EE            very well thought of in the J2EE community.
                              specify both a powerful execution environment for           This wide spectrum of high-quality implementa-
                              enterprise applications as well as a framework within   tions is one of J2EE’s great strengths: using an
                              which it is possible to easily create solutions while   Open-Source tool like JBoss it is possible to start
                              relying on powerful tool support. A number of           developing very sophisticated projects for very little

56 | software | april 2002
                                                                                        methodology ➔

           Tools                   Blueprints                Patterns

               EJBs                  JSPs                 Servlets

      Mail                                                   Transactions
                      Messaging                                Security

                                 J2SE Facilities

Figure 1 J2EE major components

capital outlay. As the project moves to final deploy-         object that is located in a separate Java Virtual
ment or as the developed system needs to scale, it is         Machine. The version of RMI now specified by
a relatively easy task to move ‘up the food chain’ to a       the J2EE makes use of the mature Internet
more powerful and complex platform purchased                  Inter-Orb Protocol standard (IIOP) and so
from a higher-tier vendor.                                    allows Java to interact with systems written in a
                                                              variety of other languages: C/C++, SmallTalk,
Architecture                                                  COBOL, Ada, etc.
Currently in version 1.3.1, the J2EE platform pro-            Other familiar technologies that have been gath-
vides a very extensive framework. As shown in              ered under the J2EE umbrella and subsequently
Figure 1, the J2EE incorporates both old and new           augmented include:
technologies.                                                 ✚ Java Servlets – a very common technology
   Since the J2EE is based on the Java 2 Standard             that provides an execution and extensibility
Edition (J2SE), a large proportion of it is familiar to       mechanism for the server
existing Java developers.                                     ✚ Java Server Pages (JSP) – originally a Java
   Incorporated into the J2EE from the J2SE are:              adaptation of Microsoft’s Active Server Pages.
   ✚ Applets – provide for extensible functionality           In effect, a JSP is an ‘inverted’ Servlet: where a
    in a browser                                              Servlet is a Java class that contains processing
   ✚ JavaBeans – a tool-oriented technique for                logic and may produce HTML, a JSP is an
    building component-based applications and                 HTML page that contains embedded Java code.
    frameworks                                                JSPs provide a presentation/template system and
   ✚ Java Database Connectivity (JDBC) –                      tool-oriented interface to Java Servlets. They
    facilitates the use of most SQL-addressable               also help solve the problem where graphic
    data sources                                              designers (who are interested in the HTML
   ✚ Java Naming and Directory Interface                      markup and look-and-feel of a project) and
    (JNDI) – provides a standardised interface to the         developers (who are concerned with the logic
    multiplicity of directory services typically found        of an application) end up tripping over each
    scattered throughout an enterprise                        others’ feet while working on the same section
   ✚ Java Remote Method Invocation (RMI) –                    of a project, as they tend to do when Servlets
    allows one object to invoke methods on a second           (which inter-mix markup and logic within one

 A final major driver underlying J2EE’s
 development is the need for software to be
 developed according to ‘Internet speed’
                                                                                                                   software | april 2002 |57
➔ methodology

                                 Client-Side                    Server-Side          Server-Side
                                Presentation                    Presentation        Business Logic

                                   Browser                           Web                EJB
                                                                    Server            Container
                                     Pure                             JSP                EJB

                                      Java                          Servlet              EJB

                                     Java                                                EJB

                                                              View / Controller                               Model

                             Figure 2 Model-View-Controller (MVC) in J2EE context

                             application) are used for dynamically generating               ✚ Java Connector Architecture (JCA) – sits
                             HTML pages.                                                     beneath the J2EE platform and facilitates the
                            Java developers interested in interacting with                   integration of various high-end information
                         legacy Message Oriented Middleware systems, or                      systems, such as SAP, CICS and Oracle
                         who have an interest in supporting asynchronous or                  Financials, allowing them to be plugged into
                         disconnected modes of operation will also be relieved               any J2EE environment and accessed in a
                         to know that J2EE incorporates the pre-existing Java                standardised fashion as ‘resources’
                         Messaging Service (JMS) and JavaMail technologies.                 EJBs are targeted at developers who wish to be
                            In addition to gathering together a number of pre-           able to design and build complex Object-based
                         existing elements, the J2EE introduces a variety of key         systems and also at tool suppliers who need clear,
                         technologies aimed at making development of high-               standard APIs with which to work. EJBs are thus
                         end systems easier. Some of the highlights include:             more suited to the needs of the enterprise than Java
                            ✚ Java Transaction API (JTA), and Java                       Servlets, which essentially only provide a simple
                             Transaction Service (JTS) - JTA provides a                  execution mechanism.
                             standardised Application Programmer Interface                  J2EE defines three basic types of EJB:
                             for transaction handling and JTS effectively                   ✚ Entity – allows for the definition of persistent
                             provides a Java implementation of JTA that                      storage services and provides an Object-Rela-
                             supports distributed transactions.                              tional mapping facility
                            ✚ Enterprise JavaBeans (EJB) – a component                      ✚ Session – represents a client to the application.
                             architecture for the construction of enterprise-                The J2EE defines two types of session bean:
                             level services. More on this later.                             stateless session beans often represent a
                            ✚ Custom tags (usually called ‘taglibs’) –                       single-step workflow or provide some general-
                             provide a simple way to build reusable code                     purpose functionality for multiple clients,
                             blocks, and allow for the clear separation of pro-              whereas stateful session beans maintain a
                             cessing and presentation within a JSP project.                  sequence of interactions with a single client
                             Taglibs are very valuable in mid-to-large projects              over time.
                             and also for those projects where the look and                 ✚ Message-Driven – provides for asynchronous
                             feel of a page is in the hands of a designer                    invocation of a service
                             whereas the provision of business functionality is             Figure 2 (above) shows the unifying idea behind
                             the remit of a separate developer. As with much             the J2EE: that of Model-View-Controller (MVC).
                             of the more recent J2EE activity, custom tags               System designs may be decomposed into Models
                             also provide a foundation for tool developers and           (sources of data such as a database or file; in the
                             ease the creation of reusable code.                         J2EE world, this is typically modelled as Entity

58 | software | april 2002
                                                                                              methodology ➔

                                                                   Now is the time to
                                                                   investigate whether
                                                                   J2EE is an appropriate
                                                                   tool for tackling your
EJB), Views (a presentation of the current state of a
model; represented in the J2EE by JSPs/Servlets/
                                                                   organisation’s needs
custom tags) and Controllers (manipulators of the
model; typically Servlets, Session EJB or Message-
Driven EJB).                                                                                                          Server
   The simplicity of MVC means that it is easy to                                     Transaction Management
design and build for, but at the same time it main-
tains a great deal of flexibility and makes it possible
                                                                            I                                              M
to evolve a system in the face of new requirements                                                                    S
                                                                            n                                              a
and changing environments.                                                  t                                         e    n
                                                                                                                      c    a
   A key aspect to the J2EE is control by interposi-       Incoming         e      Mediated       Developed           u
                                                              Client                                                       g
tion: all server-side code ‘lives’ within a container,      Request
                                                                            r       Request       Component           r    e
                                                                            f                                         i    m
which controls all aspects of an EJB or JSP/Servlet’s
                                                                            a                                         t    e
existence. It does this by placing itself between all                                                                 y    n
                                                                            c                                              t
incoming requests from clients and also between all                         e
interactions with external resources, be they data-
bases, directory services, or other resources.
                                                                                    Persistence Management
   No code that is developer-written is ever accessed                               Relationships Management
directly or ever accesses resources directly: as Figure
3 shows, the container mediates everything. (Of
course, to do its job, the container may request          Figure 3 Control by interposition

resources and services from the underlying
application server proper.)                                  The container is responsible for persistence and
   The container provides a single point of control       relationship maintenance and to provide the ability
for such system aspects as transactions, security,        to search across persistent stores and to give the
concurrency, persistence, relationships and, in some      ability to navigate across relationships; the J2EE
cases, clustering and failover as well. The API           defines a new query language, called EJB-QL. This
between the container and the code it wraps is small      closely follows the spirit of SQL but is defined
and well defined, making it simple to work with and       purely in EJB-property terms, making it at least
(returning to the common theme) amenable to tool          notionally independent of the underlying persis-
utilisation. The container also imposes a well-           tence mechanism. Figure 4 shows how this is used
defined lifecycle on wrapped code that further eases      within an Entity EJB deployment descriptor to add
the demand on the programmer and simultaneously           a new tool-created method called findLineItems-
eases life for our putative J2EE-aware tool.              GivenQuantity to the EJB.
   While retaining simplicity, the J2EE does not             Note that, being based on XML, deployment
throw away power. The operation of the container is       descriptors are (once again) ideal for tool-based
easily configured in a declarative fashion by means       manipulation.
of an XML-based deployment descriptor. This pro-             Sun does not talk solely about technology when
vides configuration information guiding the con-          defining the J2EE. Its ‘Blueprints’ site
tainer’s operation. Among other things, it is possible    (http://java.sun.com/blueprints) provides an
to specify which individual methods can be invoked        extensive list of resources covering J2EE guidelines
and by whom, which methods should be infected             for implementation, best practices, direct Q&A,
with a transaction and which should establish a new       discussions of various patterns appropriate to the
transactional boundary, which database table fields       effective design of J2EE-based systems as well as
are mapped to particular EJB properties and which         providing a valuable code resource showing how to
of these should be considered to define relationships     develop end-to-end applications.
between EJBs and maintained appropriately.                     o
                                                             T aid in identifying the tasks that must be

                                                                                                                      software | april 2002 |59
➔ methodology

                                                       SELECT OBJECT (o) FROM Orders AS o
                                                         IN (o.lineItems) li WHERE li.quantity = ?1
                                   Figure 4 EJB-QL

                         performed by various parties throughout a project’s        The Future
                         lifecycle, the J2EE platform defines various distinct      J2EE is now becoming well-established and is
                         roles (these are fairly self-explanatory; a more in-       allowing vendors to re-examine their existing
                         depth exposition of these roles is given on Sun’s web-     products. Macromedia have announced that their
                         site at: http://java.sun.com/blueprints/                   popular ColdFusion product will become a value-
                         guidelines/designing_enterprise_applications/              added service that runs on existing J2EE application
                         platform_technologies/platform_roles) includ-              servers such as those from IBM, Sun, BEA,
                         ing: J2EE Product Provider, Application Compo-             Oracle, and Macromedia’s own JRun. IBM has
                         nent Provider, Application Assembler, Deployer,            also recently announced that it will be undertaking
                         System Administrator and Tool Provider. Although           a similar migration for Lotus Notes, which will
                         a given individual typically performs several roles        closely integrate with its Websphere J2EE applica-
                         as a project progresses, the above breakdown               tion server.
                         attempts to guide the definition of responsibilities           The only potential external threat to J2EE’s con-
                         and workflow to ensure that all aspects of a system        tinued wellbeing is from Microsoft’s new .NET
                         can be considered, regulated and supported by the          technology. At this stage, it is impossible to gauge
                         provision of an appropriate tool set.                      how much impact this will have.
                                                                                        One key positive indicator for J2EE is the existence
                         Issues                                                     of an extremely active and vital community of users.
                         Many people cite performance as their main reason          This is reflected in both the growing number of
                         for being wary of the technology. As the J2EE speci-       application servers and commercial products appear-
                         fication matures and as the vendors’ offerings             ing in the marketplace and in the growing amount of
                         become more sophisticated and as people grow to            community-sponsored development (products, tools
                         better understand how to apply it, this is one issue       and design techniques) that is taking place.
                         that may go away over time. When I went to univer-             J2EE is currently enjoying strong commercial
                         sity, the common mantra was that SQL databases             and community support. The number of J2EE
                         simply would not perform sufficiently well for ‘real       projects being undertaken both internationally and
                         world’ applications. Since that time, SQL has              within Australia is growing. Now is the time to
                         become universal. Performance issues (real or imagi-       investigate whether J2EE is an appropriate tool for
                         nary) have now, for the most part, been devalued. So       tackling your organisation’s needs.

                         it will be with J2EE, I believe.
                             Of greater concern is the potential for fragmenta-
                         tion of the marketplace. While the J2EE is standard-        FURTHER INFORMATION
                         ised and closely shepherded by Sun, the various             http://www.theserverside.com, a very useful site
                         vendors and J2EE licensees are introducing sophisti-        for understanding latest developments in the J2EE
                         cated frameworks that build on top of J2EE: numer-          and server-side infrastructure in general.
                         ous personalisation, commerce and portal frameworks         Nicholas Kassem, Enterprise Team, Designing Enter-
                         are being introduced at a rate of knots and without         prise Applications with the Java™ 2 Platform, Enter-
                          the guiding influence (good or bad) of a single stan-      prise Edition, Addison Wesley, 2000 (ISBN
                         dards-setting body. This has the potential to create the    0-201-70277-0).
                         same sort of lock-in that has caused suffering since        http://java.sun.com/j2ee, the definitive J2EE site.
                         commercial computing first arrived: caveat emptor!

60 | software | april 2002