|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
General Java A Paradigm Shift in Distributed Computing
A Paradigm Shift in Distributed Computing
By: Bhaven Shah
Jan. 1, 1999 12:00 AM
As Java takes a leap toward the next generation of enterprise computing, enterprises get ready to deploy large-scale business applications using Java. This article describes how the new Enterprise Java-Beans (EJB) technology from Sun Microsystems can be instrumental in building distributed enterprise applications. We'll first look at the application server implemented by Weblogic, which uses EJB technology to provide business solutions. Then I'll discuss how this powerful technology can be used in the context of a true distributed environment such as CORBA.
Background
Typical EJB Environment Sun Microsystems' Java Platform for the Enterprise (JPE) provides a foundation for the development and deployment of Java-based enterprise-class application systems. EJB is an essential piece of the complete JPE environment that elevates Java to a serious application development language capable of supporting mission-critical distributed enterprise application systems. JPE API consists of nine Java APIs - EJB, Java Naming and Directory Services (JNDI), Remote Method Invocation (RMI), Java Interface Definition Language (Java IDL), Servlets and Java Server Pages (JSP), Java Messaging Service (JMS), Java Transaction API (JTA), Java Transaction Service (JTS) and Java Database Connectivity (JDBC) - that enable Java applications to access the core enterprise-class infrastructure services through a set of standard programming interfaces that include EJB components. Some of the primary EJB components are the EJB server and container, enterprise beans, session objects, entity objects and EJBObjects. The function of an EJB server is to manage resources needed to support EJB components. An EJB container is where an EJB bean "lives." It provides a scalable, secure and transactional environment in which EJBs can operate. The container manages the life cycle of the enterprise bean. It also generates an EJB object that is an interface for the enterprise bean and represents a client view of the enterprise bean. All client requests directed at the EJB object (such as a request to insert transaction, state and security rules) are intercepted by the EJB container (see Figure 2). The EJBObject acts as a proxy, passing method invocation requests to an instance of the enterprise bean installed and executing within the container of the EJB server. Clients use the JNDI and EJBHome interface of the enterprise bean to locate an enterprise bean.
Entity Beans vs Session Beans Entity beans are transactional and can be recovered following a system crash. Entity objects are also implicitly persistent. They can either manage their own persistence or delegate it to their container. Entity beans usually represent a one-to-many relationship to client(s). In a typical enterprise some of the examples of entity beans would be employees, customers and orders. On the other hand, session beans typically are neither transactional nor recoverable following a system crash. They can be stateless or they can maintain conversational state across methods and transactions. Session beans have to manage their own persistence. They usually represent a one-to-one relationship to client(s). Examples of session beans are electronic shopping carts and grocery lists. What do enterprises need in order to develop and deploy an EJB-based application? First, they need to implement enterprise beans containing their business logic and assemble any third-party beans into their applications. Once they've done this, they can use any enterprise server implementation provided by vendors such as Weblogic, Persistence and EJBHome to execute and manage their EJBs. The server provider will take care of distributed transaction management, distributed EJBs and other low-level system services. Since Weblogic Inc. is an industry leader in the Enterprise JavaBeans server market and one of the early adopters of Enterprise JavaBeans, we'll discuss their application server in the following sections.
Tengah Application Server
Tengah Enterprise JavaBeans A unique feature of Tengah is the bean bar for Tengah beans. The bean bar is a collection of EJBs that provide access to Tengah services, including login, event subscribe, publish, Tengah server-side workspace access and more. Users can develop Tengah applications using drag-and-drop programming of Tengah beans in any Java-Beans-compliant IDE.
Tengah COM
Tengah Servlets
Tengah Cluster
Tengah Zero Administration Client
Tengah JDBC
EJB Development and Deployment Using Tengah
Implementation
An Enterprise JavaBean is a class that a developer writes to provide application functionality. The developer can implement the bean as either a session bean or an entity bean by implementing the appropriate interface and declaring its type in the deployment descriptor used while deploying the bean. Typically, the developer will need to extend the javax.ejb.EnterpriseBean class from the javax.ejb package. Both the SessionBean and EntityBean interfaces extend from this class. public class MyEJB implements javax.ejb.SessionBean---. And, an entity bean can be implemented as: public class MyEJB implements javax.ejb.EntityBean---. The methods in your Enterprise Bean will never be invoked directly from the client. The client uses the EJBObject, which acts as a proxy to call the bean's methods. The EJBObject is a "true" network object that gets accessed by clients over the network. You have to create a remote interface that will describe the business methods of the enterprise bean you'd like the client to be able to invoke. The method names and the signatures listed in this remote interface should exactly match those implemented in the enterprise bean. For example, you might provide a remote interface for the EJB as follows:
public interface Account extends javax.ejb.EJBObject { It's important to note that the class javax.ejb.EJBObject will implement the java.rmi.Remote interface. The container vendor will generate the implementation code for the bean remote interface (Account interface in the above example) at the time the enterprise beans are installed. For remote clients to access the enterprise bean, they first need to access the bean's "home" object which implements the home interface of the bean. The home interface lists one or more create() methods that can be used to create an instance of the enterprise bean. The server typically registers the home object (EJBHome) with the JNDI. The clients have to know the location of the namespace and the JNDI context factory class name for the home object. The home interface for an EJB bean might look like this:
public interface myHome extends EJBHome { Again, note that the class javax.ejb.EJBHome implements the java.rmi.Remote interface. The container vendor is responsible for providing the home object that implements this home interface. The implementation code acts as a factory to create the enterprise beans.
Tengah EJB Deployment Wizard
You can invoke Tengah's deployment wizard from the command line with: In this instance, options can be used to get help or to set look and feel for the UI of the wizard.
Starting and Maintaining the
Tengah Server $ java -noasyncgc -noclassgc -ms16m -mx16m weblogic.Server Weblogic also provides an administrative tool to start up, shut down and monitor the execution of the Tengah server.
Current State of Tengah
EJB Meets CORBA EJB architecture will be key to middle-tier solutions in CORBA-based applications. By treating EJB objects as CORBA objects, clients will be able to work with EJB components in different CORBA middle-tier environments without regard to the environment of the vendor hosting that component. A CORBA 3.0-compliant server, when encountering EJB components, will be able to load a Java Virtual Machine at runtime and run the EJB objects. The first draft for the CORBA 3.0 specification was expected to be released by the end of 1998. Products like Weblogic's Tengah are already providing the means to support CORBA objects within EJB containers. This is possible since CORBA objects can be wrapped as EJBeans within an application server environment like Tengah.
EJB and CORBA: Complementary, Not Competing, Technologies One example of this is EJB's transaction model. EJB's transaction architecture closely models CORBA's Object Transaction Service (OTS) specification. The following section describes the EJB transaction architecture and its mapping to the OTS architecture. EJB Transaction Architecture An EJB runtime requires transaction propagation across multiple EJB servers on the network. This requires a distributed transaction service with two-phase commit to ensure recovery of transactions in case of a network failure. The EJB specification also requires the transactions to be able to span multiple EJB servers so that a bean in one server can act as a client to a bean in another server while preserving membership within the transaction. The transaction control for a bean is usually specified in the bean's Deployment Descriptor. The transaction could be bean managed or container managed. Various transaction controls can be specified for the enterprise bean: TX_REQUIRES, TX_NOT_SUPPORTED, TX-_BEAN_MANAGED, TX_REQUIRES_NEW and so on. Session beans can implement the SessionSynchronization interface to receive callbacks from the transaction service. The enterprise beans are transactional. They carry the transactional state in the form of EJBContext, which is provided to every bean when it's first created. The session and entity beans carry SessionContext and EntityContext, respectively, both of which are subclasses of EJBContext. In addition, an EJB vendor may choose to provide support for client-demarcated transactions. This would allow the client to begin a transaction prior to invoking a method on the bean. Mapping OTS Components into EJB Components The EJB transaction model is based on the OTS model specified by CORBA. In fact, the EJB specification requires its transaction service to be accessible using OTS 1.1 API. Hence, each of the OTS components can easily be mapped to an EJB object. For example, the Terminator object in OTS architecture could be viewed as an EJB container. In container-managed transactions the container can either commit or roll back a transaction, as appropriate. A transaction-aware JDBC driver in an EJB environment can act as a coordinator of OTS to register a connection with the transaction. Similarly, an EJB container can also act as a Coordinator to register a bean as a Synchronization object if the bean implements javax.ejb.SessionSynchronization interface (see Figure 4). To keep the server requirements simpler, the current EJB specification doesn't require support for a nested transaction. Several other features of OTS aren't required by the current EJB specification, such as explicit transaction propagation. The JPE provides JTS, which is a Java mapping for the CORBA OTS. Enterprise JavaBeans support transactions using JTS. The EJB container and other transaction coordinator objects use the JTA to interface with the underlying OTS-compliant transaction service. One other feature that I think will make CORBA a true counterpart of EJB is the addition of directory services to CORBA's naming service so that JNDI API can seamlessly access the CORBA service, or allow it to be integrated with any other namespace services.
What's Next? An adaptation of EJB by OMG would contribute significantly to its success. An interesting battle is emerging between Microsoft's middle-tier solution and EJB technology. Microsoft's distributed architecture, which consists of COM, Microsoft Transaction Service (MTS) and MSMQ is currently more stable and ahead in terms of implementation than the EJB architecture. The most recent acquisition of Weblogic Inc. by one of the veterans in distributed computing (BEA Systems) makes the battle even more interesting and indicates that the arrival of Enterprise JavaBeans may just be the beginning of a new era in enterprise computing.
Resources Reader Feedback: Page 1 of 1
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||