Presentation is loading. Please wait.

Presentation is loading. Please wait.

J2EE Kenneth M. Anderson CSCI 7818 - Web Technologies October 3, 2001.

Similar presentations


Presentation on theme: "J2EE Kenneth M. Anderson CSCI 7818 - Web Technologies October 3, 2001."— Presentation transcript:

1 J2EE Kenneth M. Anderson CSCI 7818 - Web Technologies October 3, 2001

2 Credit where Credit is Due Most (if not all) of the information in this presentation comes from –Enterprise JavaBeans –by Richard Monson-Haefel –O’Reilly & Associates, Inc. –© 1999 and 2000

3 J2EE Stands for “Java 2, Enterprise Edition” It is a collection of standards –JDBC, JNDI, JMX, JMS It is a component technology –Enterprise JavaBeans It is an “application server” –Following in the footsteps of Component Transaction Monitors

4 History Distributed Objects –CORBA, DCOM, etc. –Three-tier scenario: presentation, business logic, and backend databases Hard to “get right” without the proper infrastructure Server-Side Components –Focuses on encapsulating “business rules” into objects in the middle tier Component Transaction Monitors –Descendant of CORBA’s Object Request Broker provides discovery, persistence, event notification, transactions, etc. for three-tier or n-tier applications

5 Enterprise JavaBeans, Defined From Sun: –The Enterprise JavaBeans architecture is a component architecture for the development and deployment of component-based distributed business applications. Applications written using the Enterprise JavaBeans architecture are scalable, transactional, and multi-user secure. These applications may be written once, and then deployed on any server platform that supports the Enterprise JavaBeans specification

6 Enterprise JavaBeans (shorter definition) From O’Reilly’s Enterprise JavaBeans book –Enterprise JavaBeans is a standard server-side component model for component transaction monitors Aha! It’s a standard for building server-side components and deploying them in component transaction monitors

7 Distributed Objects Scenario Client Stub Skeleton Server-Side Component Client-SideNetworkMiddle Tier invokes return results connect to remote object invoke return results return results Stub and Skeleton are auto-generated; client “thinks” its making a local call, most networking details are hidden from client; the main detail is obtaining a reference to the remote object  naming service

8 Architectural Overview Two Types of Enterprise JavaBeans –Entity Beans Used to model business concepts such as customer, cruise ship, inventory item, etc. –Session Beans A server-side “representative” of the client; session beans are responsible for managing processes or tasks; for instance in an airline reservation scenario, the session bean would be responsible for reserving a seat on a particular flight and verifying payment

9 Insight into Session Beans EJB Server Client Using Session Beans Client Using only Entity Beans

10 To Implement an Enterprise Bean Any enterprise bean must define two interfaces and one or two classes –Remote interface defines a bean’s external interface must extend javax.ejb.EJBObject (which in turn extends java.rmi.Remote) –Home interface The home interface defines a bean’s “life cycle” methods, eg. create bean, remove bean, find bean, etc. must extend javax.ejb.EJBHome which also extends java.rmi.Remote

11 To Implement, continued… Bean Class –The java class that actually implements the bean’s external interface, e.g. the bean class provides implementations for the bean’s “business methods” –An entity bean must implement the javax.ejb.EntityBean interface, while a session bean must implement the (you guessed it) javax.ejb.SessionBean. Both of these interfaces extend javax.ejb.EnterpriseBean Primary Key –The primary key is a very simple class that provides a pointer into a database; Only entity beans need a primary key. This class must implment java.io.Serializable (so the entity bean can automatically be sent to persistent storage)

12 Additional Info Clients never interact directly with a bean class, they use stubs (which connect to skeletons, which connect to “containers” which call the bean class…whew!) Why? This allows the application server to replicate bean instances (for performance reasons), manage transactions, etc. A bean also interacts with its server via a container interface: the container calls the bean’s life cycle methods, manages the bean’s persistence, etc.

13 Architecture Diagram Client Home Interface Home Stub Remote Interface EJB Stub EJB Server EJB Container Home Interface EJB Home Remote Interface EJB Object Bean Class

14 Benefits of an Application Server Resource Management –Instance Pooling and Swapping Server can invoke multiple instances of a bean to handle multiple incoming requests (pooling) An instance of a bean class can handle requests from multiple skeletons (swapping) –Activation if a bean is “stateful,” application servers automate the process of saving and restoring bean state when a bean is deactived and later activated

15 Benefits of an Application Server Primary Services –Concurrency Beans are automatically thread safe; application servers handle concurrent access to a bean; They also handle reentrance –Transactions Bean operations can belong to a transaction and the application server handles “rolling back” an application’s state if a partially completed transaction fails –Persistence Application servers can map beans into database entries (and back again) –Naming (bean discovery) and Security (encrypted communication and access control)

16 References Enterprise JavaBeans –by O’Reilly –ISBN: 1-56592-869-5 Sun’s J2EE website –


Download ppt "J2EE Kenneth M. Anderson CSCI 7818 - Web Technologies October 3, 2001."

Similar presentations


Ads by Google