How I may help
LinkedIn Profile Email me!
Call me using Skype client on your machine

Reload this page Java Enterprise Edition (J2EE) Middleware

This page summarizes how Java Enterprise Edition (J2EE) programs work for enterprise developmentanother page on this site

 

Topics this page:

  • Versions
  • Architectures,
  • Vendors,
  • JavaBeans,
  • EJBs,
  • Tools,
  • Your comments???

  •  

    Site Map List all pages on this site 
    About this site About this site 
    Go to first topic Go to Bottom of this page


    Newsgroup: comp.lang.java

    A website external to this site Roedy Green's Java Glossary

    Set screen Versions of J2EE

      PDF The J2EE v1.3 Specification [174 pages dated July 1, 2001] is the original version. webpage article Official website

      PDF The J2EE v1.4 Specification [246 pages dated Nov 24, 2003] webpage article Official website

      Since then, AOP (Aspected Oriented Programming) implemented in packages such as AspectJ have made J2EE more agile with open-source Spring and the Hibernate persistence provider.

      webpage article Java Platform, Enterprise Edition (Java EE 5) makes optional XML deployment descriptors (side files for defining components and specifying deployment instructions) with annotations in the code. It also features Enterprise JavaBeans (EJB) Technology 3.0, JavaServer Faces (JSF) Technology for interface design, and the Java Persistence API.

    • MyEclipse IDE ($199 Pro version) is a plug-in built on top of base Eclipse to add facilities specific to web application development, such as JSP and JavaScript debugging, browsing and Hibernate map generation from databases, formatted editing of XML, JSP, XSD, Struts, JSF, Hibernate, etc. files (rather than via the Text Editor in Eclipse). Apps are deploy manually using an Ant script.

     

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen J2EE Architecture

      J2EE J2EE is called "middleware" because it sits in the middle between web servers responding to clients at the presentation layer and databases in Enterprise Information Systems (EIS).

      1. Interaction with user GUI requests are managed by web servers, which in large sites usually sit behind a load balanceranother page on this site
      2. process-oriented or service-based requests are managed by application servers.
      3. Database servers provide data to application servers.
      4. In more complex environments, there is an additional business objects server. These servers manage Behaviors, Properties, Relationships with other entities, and Rules or policies.

      Behind the scenes, unnoticed by users of a typical web application, run web services :

      • Single-signon login servers providing authentication, usually via an infrastructure LDAP server.
      • Java Naming and Directory Interface (JNDI) allows named resources to be located.
      • Java Message Service (JMS) and Java API for XML Messaging (JAXM) allows programs to exchange messages.
      • Java Transaction Service (JTS) allows requests to be segmented into transactions that succeed or fail as a whole, so that partial transactions are not persisted if only a part of the transaction is successful.
      • JTA
      • JCA for connection to legacy systems
      • JDBCanother page on this site servers provide access to underlying databases.
      • JMX provide access to monitoring mbeans.

      Java Server Pages (JSP) has Java (usually presentation logic) code embedded in HTML-like text documents. v1.2 JSPs may contain HTML-like tags from the JSTL (JSP Standard Tag Library) in \WEB-INF\lib. See JSP Standard Tag Library Kick Start (published by Sams) or Making Use of JSP by Madhushree Ganguli (published by Wiley Publishing, Inc.).

      Java Servlets are Java programs which issue HTML. See Java Servlet Programming Bible by Suresh Rajagopalan (Editor), Ramesh Rajamani, Ramesh Krishnaswamy, and Sridhar Vijendran (published by Wiley Publishing, Inc.).

      J2EE app servers integrate with other web-based apps using resource adaptor components developed with an Common Client Interface (CCI) Sun introduced with the Java 2 Enterprise Edition (J2EE) 1.3 specification J2EE Connector Architecture (JCA) common interface of scalable, secure, and transactional integrity mechanisms just like JDBC provides for databases. iWay


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen J2EE Software Vendors

      The major J2EE vendors are:

      Company Product Architecture Notes
      SourceForge on this page  JBoss Application Server (AS) an open source architecture
      BEA another page on this site WebLogic Server WebLogic Platform
      IBM on this page  WebSphere Visual Age
      Oracle on this page  10g, 9iAS for 11i Applications integrated with applications

      To avoid the complexity of deploying Web services in a Java environment, some projects have stuck with individual API's like JAX-RPC or frameworks such as Apache Axis for plain old Java objects (POJO's) with no inheritance dependencies.

      MiddleAware.com


    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen IBM WebSphere

     



     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

      Set screen JBoss

     



     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen J2EE Deployment Descriptors

      In an attempt to make modules portable between EJB servers that support the EJB specification, J2EE was specified to cleanly separate development of Java class code and deployment in XML files.

      The META-INF/application.xml file is the standard J2EE deployment descriptor that defines an Enterprise application.

      It contains an element for each Web application, EJB, and connector module, as well as additional elements to describe security roles and application resources such as databases.

      An Enterprise application consists of one or more of the following:

      • .WAR archive files holding Web application modules described by weblogic-application.xml for each WebLogic Server-specific extension
      • .JAR archive files holding EJB modules
      • .RAR archive files holding resource adapter/connector modules described by ra.xml
      • .EAR archive files holding client-application.xml

      These are all within an .EAR archive file also holding compiled Java .class files, .JSP files, .HTML files, and descriptor XML files.

      The J2EE-specified deployment descriptor, ejb-jar.xml describes the enterprise beans packaged in an EJB application. It defines the beans’ types, names, and the names of their home and remote interfaces and implementation classes. It also defines security roles for the beans, and transactional behaviors for the beans’ methods.

      Additionally, the weblogic-cmp-rdbms-jar.xml deployment descriptor unique to container-managed entity beans maps a bean to tables in a database. The weblogic-ejb-jar.xml deployment descriptor supplies additional information specific to the WebLogic Server environment, such as JNDI bind names, clustering, and cache configuration.

     



     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen J2EE Deployment Packages

      Module Type Archive J2EE Descriptor Weblogic Descriptor

      The .ear package file contains the classes that implement the Home and Remote interfaces using IIOP (IIO Protocol). The stub class file for the serve communicates with the skeleton class on the server.

      They are both in the .ear file generated by the delopyment tool (deploytool.exe form the Sun J2EE Reference Platform) and copied to (deployed on) the EJB server and all EJB client machines.

     



     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Java Beans

      The JavaBeans standard is a low-level component model tailored to the Java language.

      Java beans are reusable platform-neutral software components that can be visually manipulated with a software development tool. Bean interface components include: methods, properties, and events.

      "Coarse-grained" methods which communicate several items of information at a time are more efficient than
      "fine-grained" methods which require more round trips to the server.

      Beans communicate state changes to their properties. So other interested Beans can listen to the changes fired and behave appropriately. Listening Beans with an identical property can match the change, such as a change to the color of one component causing a whole group of components to change as well.

      Bounding changes among beans make it possible for one bean to act as a controller for any component that wants to subscribe to its service.

      Beans can veto changes sent to them, rejecting values that exceed a defined range for the target Bean (or whatever rule that Bean institutes). Of course, this process only has value to the sending Bean if it can learn whether its target accepts or rejects a change, and then it can respond. The sending Bean may wish to roll back to the previous state if the target Bean cannot comply or, in the case of multiple targets, the sender may attempt to set all target Beans to the last agreed-upon state.

     

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen J2EE (Enterprise Endition) Java Beans

      Java beans run within (are managed by) an EJB Container maintained by an application server (j2ee.exe in the Sun J2EE Reference Platform). It uses interfaces in the J2EE extension javax.ejb.EnterpriseBean, which is extended by several bean libraries:
      • SessionBean
      • EntityBean
      • MessageDrivenBean (Mail service)
      • Session beans execute a particular business task on behalf of a single client. Session beans are non-persistent. When a client finishes with a session bean, the bean goes away. There are 2 kinds of session beans:

        • Stateless Session beans are used to cache and manage infrequently changed data. They must be updated explicitly.
        • Stateful Session beans, which "most architects avoid if at all possible."[1]
        Entity beans represent business objects in a data store, usually in a relational database system. Entity bean methods model the behaviors of the business objects they represent. There are 2 kinds of beans which load and save data:

        • Container-managed persistence (CMP) entity bean for declarative transaction management.
        • Bean-managed persistence (BMP) entity bean
        Entity beans can be accessed concurrently by multiple clients and they are persistent by definition. So they are pooled.

        Entity beans are the only dedicated data access components in J2EE and also the most questionable part of J2EE, Their non-J2EE alternatives include Hibernate and JDO.

        Message beans are not associated with any client since they simply handle messages as they arrive.

      Reminder EJBs may not spawn threads, access files directly, use graphics or sockets.

      Idea webpage article Local interfaces in EJB 2.0 is one attempt to improve overall performance: local interfaces provide for beans in the same container to interact locally without involving RMI.

      Set screen Run client

      Instead of java.exe, EJB clients are run with a client program which enforces user password authentication.

      The Sun J2EE Reference Platform provides the runclient.exe program:

        runclient -client xx.ear -name xx.class

      WebLogic Server 8.1 supports a true J2EE application thin client in a small footprint (400 KB) standard wlclient.jar and wljmsclient.jar for JMS. These are provided in the /server/lib subdirectory of the weblogic81 installation directory. In previous versions of WebLogic Server, a Java client required the full WebLogic Server JAR on the client machine.

      This client JAR file also contains a Main-Class entry in its META-INF/MANIFEST.MF file to specify the entry point for the program.

      Application clients directly access Enterprise JavaBeans running in the business tier, and may, as appropriate communicate through HTTP with servlets running in the Web tier.

      The client doesn't invoke EJB methods directly, but through a remote interface proxy exposed by EJB remote objects which contain business methods such as “getPubNames()”.

      RMI/IIOP remoting is an outstanding remoting technology with EJB. There are better alternatives for thread pooling web services remoting because a web container provides thread pooling and there’s no need to duplicate it in the business object tier.

     

     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen EJB Coding

       

      try (
          // 1. Use JNDI to lookup home object:
          Context initial = new InitialContext();
          Object o = initial.lookup( "PubInfoBeanJNDIName" );
          // 2. 
          PubInfoHome home = (PubInfoHome)PortableRemoteObject.narrow(
              o, PubInfoHome.class);
          // 3. Use home factory object to create remote object:
          PubInfo pubInfo = home.create();
          // 4. Invoke business method:
          String[] pubs = pubInfo.getPubNames()
          ...
      }
      catch {
          system.err.println("Caught unexpected exception");
          ex.printStackTrace();
      }	
      

    1. The client performs a lookup() of a JNDI Name string (such as “PubInfoBeanJNDIName”) from a JNDI (Java Naming Directory Interface) Name Service. method from the javax.naming.Context and javax.naming.NamingContext libraries' Stateless InitialContext() or the Stateful Class.newInstance() method.

      Idea Use a dedicated session bean to perform and cache JNDI lookups, since ServletRequest.getRemoteHost() is inefficient, and can take seconds to complete the reverse DNS lookup it performs.

      The Home interface extends javax.ejb.EJBHome, which extends java.rmi.Remote.

    2. The JNDI service returns to the client a reference to a context — the Home Factory object on some EJB server. Example: “PubInfoHome” Some JNDI servers assign references so that load balancing is achieved among several EJB servers.

      The stateful setSessionContext(SessionContext ctx) is invoked on the session bean instance. For an entity bean, connnection initailizes the class JdbcOdbcDriver.

    3. The client obtains an instance of the bean's remote object by invoking the Stateless create() or Stateful ejbCreate() method programmed in the custom beanHome class.

    4. The container instantiates stateless beans from a pool of method-ready beans in memory. This makes them much faster than stateful beans.
      The container instantiates stateful beans dedicated to a client. Stateful beans can timeout into a “Does not exist” state.
      The container can temporarily swap (idle)another page on this site a bean out of memory into a “Passivated” state by calling the ejbPassivate() method.

    5. The EJB references the Deployment Descriptor file defined for each bean. This XML file describes relationships among beans. It may also specify run-time Environment Entries.

    6. When the client is finished with a bean, it invokes the remove() method, to which the container calls the bean's Stateful ejbRemove() method.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen Resource Adaptor Connectors

      Sample "cciblackbox" resource adapter for the "CCIEIS" EIS.

      import javax.resource.cci.*;
      import javax.resource.*; // contains the root ResourceException class.
      import com.sun.connector.cciblackbox.*;
      import javax.servlet.*;
      import javax.servlet.http.*;
      import java.io.*;
      import javax.naming.*;
      import java.math.BigDecimal;
      import java.util.*;

      To access the underlying app, JCA Version 1.0 defined CCI portable contracts for

      • security.
      • connection management for authentication, and authorization
      • transaction management,

      JcA Version 1.5 added system-level contracts:

      • lifecycle management for adapter start-up and shut-down
      • work management of threads,
      • transaction inflow to propagate a transaction context and handle crash recovery.
      • message inflow for asynchronous message delivery.


    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Set screen J2EE Tools & Resources

      Open source efforts include:

    • J2EE Blueprints

    • The Jakarta Struts project

    • The Jakarta Commons project

    • The Castor project

      the Cloudscape database included with the J2EE SDK supports stored procedures written in Java.

      3 modes: IN (only pass data into the DBMS), OUT (only receive data from the DBMS), INOUT

      /*
       *
       * Stored procedures for accounts table
       *
       */
      
      import java.sql.*;
      import java.io.*;
      import java.lang.Integer;
      
      // Cloudscape stored procedures are written using Java
      public class AccountProcs implements Serializable {
      
          public static void insertAccount(String name, int bal) {
              try {
                  Connection con =
                      DriverManager.getConnection("jdbc:cloudscape:;current=true");
                  PreparedStatement ptstmt =
                      con.prepareStatement("INSERT INTO ACCOUNTS VALUES (?,?)");
                  ptstmt.setString(1, name);
                  ptstmt.setInt(2, bal);
                  ptstmt.executeUpdate();
                  ptstmt.close();
              } catch(Exception ex){
                  ex.printStackTrace();
              }
          }
      
          public static int countAccounts() {
              int count = 0;
              try {
                  Connection con =
                      DriverManager.getConnection("jdbc:cloudscape:;current=true");
                  PreparedStatement ptstmt =
                      con.prepareStatement("SELECT COUNT(*) FROM ACCOUNTS");
                  ResultSet rs = ptstmt.executeQuery();
                  while (rs.next()) {
                      count = rs.getInt(1);
                  }
                  ptstmt.close();
              } catch (Exception ex) {
                  ex.printStackTrace();
              }
              return count;
          }
      
      	public static int getAccountBal(String name) {
      		int bal = 0;
      		try {
      			Connection con =
      				DriverManager.getConnection("jdbc:cloudscape:;current=true");
      			PreparedStatement ptstmt =
      				con.prepareStatement("SELECT BALANCE FROM ACCOUNTS WHERE NAME = ?");
                  ptstmt.setString(1, name);
      			ResultSet rs = ptstmt.executeQuery();
      			while (rs.next()) {
      				bal = rs.getInt(1);
      			}
      			ptstmt.close();
      		} catch (Exception ex) {
      			ex.printStackTrace();
      		}
      		return bal;
          }
      }
      

     



     
    Go to Top of this page.
    Previous topic this page
    Next topic this page

    Portions ©Copyright 1996-2014 Wilson Mar. All rights reserved. | Privacy Policy |

    Related:

  • Exception Handling
  • RMI & CORBA
  • PATH & CLASSPATH
  • Design Patterns,
  • Data Types, Strings, Escape Characters, Dates
  • Programming Logic, Operators, Functions, Threads, AWT/Swing, Events, I/O
  • Applications Development
  • On the web

  • How I may help

    Send a message with your email client program


    Your rating of this page:
    Low High




    Your first name:

    Your family name:

    Your location (city, country):

    Your Email address: 



      Top of Page Go to top of page

    Thank you!