Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. J2EE Kenneth M. Anderson CSCI 7818 - Web Technologies October 3, 2001
  2. 2. Credit where Credit is Due <ul><li>Most (if not all) of the information in this presentation comes from </li></ul><ul><ul><li>Enterprise JavaBeans </li></ul></ul><ul><ul><li>by Richard Monson-Haefel </li></ul></ul><ul><ul><li>O’Reilly & Associates, Inc. </li></ul></ul><ul><ul><li>© 1999 and 2000 </li></ul></ul>
  3. 3. J2EE <ul><li>Stands for “Java 2, Enterprise Edition” </li></ul><ul><li>It is a collection of standards </li></ul><ul><ul><li>JDBC, JNDI, JMX, JMS </li></ul></ul><ul><li>It is a component technology </li></ul><ul><ul><li>Enterprise JavaBeans </li></ul></ul><ul><li>It is an “application server” </li></ul><ul><ul><li>Following in the footsteps of Component Transaction Monitors </li></ul></ul>
  4. 4. History <ul><li>Distributed Objects </li></ul><ul><ul><li>CORBA, DCOM, etc. </li></ul></ul><ul><ul><li>Three-tier scenario: presentation, business logic, and backend databases </li></ul></ul><ul><ul><ul><li>Hard to “get right” without the proper infrastructure </li></ul></ul></ul><ul><li>Server-Side Components </li></ul><ul><ul><li>Focuses on encapsulating “business rules” into objects in the middle tier </li></ul></ul><ul><li>Component Transaction Monitors </li></ul><ul><ul><li>Descendant of CORBA’s Object Request Broker </li></ul></ul><ul><ul><ul><li>provides discovery, persistence, event notification, transactions, etc. for three-tier or n-tier applications </li></ul></ul></ul>
  5. 5. Enterprise JavaBeans, Defined <ul><li>From Sun: </li></ul><ul><ul><li>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 </li></ul></ul>
  6. 6. Enterprise JavaBeans (shorter definition) <ul><li>From O’Reilly’s Enterprise JavaBeans book </li></ul><ul><ul><li>Enterprise JavaBeans is a standard server-side component model for component transaction monitors </li></ul></ul><ul><li>Aha! It’s a standard for building server-side components and deploying them in component transaction monitors </li></ul>
  7. 7. Distributed Objects Scenario Client Stub Skeleton Server-Side Component Client-Side Network Middle 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. 8. Architectural Overview <ul><li>Two Types of Enterprise JavaBeans </li></ul><ul><ul><li>Entity Beans </li></ul></ul><ul><ul><ul><li>Used to model business concepts such as customer, cruise ship, inventory item, etc. </li></ul></ul></ul><ul><ul><li>Session Beans </li></ul></ul><ul><ul><ul><li>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 </li></ul></ul></ul>
  9. 9. Insight into Session Beans EJB Server Client Using Session Beans Client Using only Entity Beans
  10. 10. To Implement an Enterprise Bean <ul><li>Any enterprise bean must define two interfaces and one or two classes </li></ul><ul><ul><li>Remote interface </li></ul></ul><ul><ul><ul><li>defines a bean’s external interface </li></ul></ul></ul><ul><ul><ul><li>must extend javax.ejb.EJBObject (which in turn extends java.rmi.Remote) </li></ul></ul></ul><ul><ul><li>Home interface </li></ul></ul><ul><ul><ul><li>The home interface defines a bean’s “life cycle” methods, eg. create bean, remove bean, find bean, etc. </li></ul></ul></ul><ul><ul><ul><li>must extend javax.ejb.EJBHome which also extends java.rmi.Remote </li></ul></ul></ul>
  11. 11. To Implement, continued… <ul><li>Bean Class </li></ul><ul><ul><li>The java class that actually implements the bean’s external interface, e.g. the bean class provides implementations for the bean’s “business methods” </li></ul></ul><ul><ul><li>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 </li></ul></ul><ul><li>Primary Key </li></ul><ul><ul><li>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) </li></ul></ul>
  12. 12. Additional Info <ul><li>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!) </li></ul><ul><li>Why? This allows the application server to replicate bean instances (for performance reasons), manage transactions, etc. </li></ul><ul><li>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. </li></ul>
  13. 13. Architecture Diagram Client EJB Server EJB Container Home Interface Home Stub Remote Interface EJB Stub Home Interface EJB Home Remote Interface EJB Object Bean Class
  14. 14. Benefits of an Application Server <ul><li>Resource Management </li></ul><ul><ul><li>Instance Pooling and Swapping </li></ul></ul><ul><ul><ul><li>Server can invoke multiple instances of a bean to handle multiple incoming requests (pooling) </li></ul></ul></ul><ul><ul><ul><li>An instance of a bean class can handle requests from multiple skeletons (swapping) </li></ul></ul></ul><ul><ul><li>Activation </li></ul></ul><ul><ul><ul><li>if a bean is “stateful,” application servers automate the process of saving and restoring bean state when a bean is deactived and later activated </li></ul></ul></ul>
  15. 15. Benefits of an Application Server <ul><li>Primary Services </li></ul><ul><ul><li>Concurrency </li></ul></ul><ul><ul><ul><li>Beans are automatically thread safe; application servers handle concurrent access to a bean; They also handle reentrance </li></ul></ul></ul><ul><ul><li>Transactions </li></ul></ul><ul><ul><ul><li>Bean operations can belong to a transaction and the application server handles “rolling back” an application’s state if a partially completed transaction fails </li></ul></ul></ul><ul><ul><li>Persistence </li></ul></ul><ul><ul><ul><li>Application servers can map beans into database entries (and back again) </li></ul></ul></ul><ul><ul><li>Naming (bean discovery) and Security (encrypted communication and access control) </li></ul></ul>
  16. 16. References <ul><li>Enterprise JavaBeans </li></ul><ul><ul><li>by O’Reilly </li></ul></ul><ul><ul><li>ISBN: 1-56592-869-5 </li></ul></ul><ul><li>Sun’s J2EE website </li></ul><ul><ul><li><http://java.sun.com/j2ee/> </li></ul></ul>