1 / 19

EJB Fundamentals

EJB Fundamentals. Celsina Bignoli bignolic@smccd.net. Enterprise Bean. Server-side software component that can be deployed in a distributed multi-tier environment Must conform to the EJB specification Must expose specific methods

dysis
Download Presentation

EJB Fundamentals

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EJB Fundamentals Celsina Bignoli bignolic@smccd.net

  2. Enterprise Bean • Server-side software component that can be deployed in a distributed multi-tier environment • Must conform to the EJB specification • Must expose specific methods • Methods are used by the EJB container (Application Server) to manage the bean

  3. Types of Beans • Session Beans • Model business processes • Ex: pricing engine, catalog engine, credit card authorizer • Entity Beans • Model business data • Ex: product, order, employee • Message-driven Beans • Similar to session beans • Can only be called implicitly via messages • Ex: beans that receive credit card authorization messages

  4. Distributed Objects • EJB components are based on distributed objects • A distributed object is an object that is callable from a remote system • In-process client • Out-process client • Client located elsewhere on the network

  5. Distributed Objects Client Implementation Object Remote Interface Remote Interface Stub Skeleton Network

  6. Distributed Objects(2) • Stub:client-side proxy object • Masks network communications from the client • Knows how to call over the network using sockets • Knows how to convert parameters into their network representation • Skeleton: server-side proxy object • Masks network communication from the distributed object • Understands how to receive calls on a socket • Knows how to convert parameters from their network representation to their Java representation

  7. Distribution Transparency • The stub, skeleton and implementation object together constitute the abstraction known as distributed object • The client has the impression it is calling the object directly – instead, it calls an empty stub which knows how to go over the network • The stub clones the implementation object signatures (both implement same interface) • Can be achieved using several technologies (CORBA, DCOM, RMI-IIOP)

  8. Middleware • Distributed objects allow to distribute an application across a network. • They require middleware services • Explicit Middleware • Difficult to write • Requires unnecessary large amounts of code • Difficult to maintain • Need to write new code to accomplish changes • Difficult to support • Code is not distributed to clients • Clients cannot make changes

  9. Middleware(2) • Implicit Middleware • Easy to write • No middleware code • Declare things in a text file (descriptor file) • Easy to maintain • Separation between business logic and middleware • Changes to middleware do not require changes to code • Easy to support • Changes can be accomplished by tweaking descriptor file

  10. Enterprise Bean Class • Contains implementation details of the component (i.e. the logic) • It is a Java class that conforms to a well-defined interface and obeys certain rules • All beans implement the javax.ejb.EnterpriseBean java.io.Serializable javax.ejb.EnterpriseBean javax.ejb.SessionBean javax.ejb.MessageDrivenBean javax.ejb.EntityBean

  11. The EJB Object • Surrogate object that knows about networking, transactions, security etc… • It is request interceptor, or glue between the client and the bean • Replicates and exposes every method that the bean itself exposes • Delegates client requests to beans • Each container generates automatically a vendor specific EJB class object

  12. The Remote Interface • Special interface created by the Bean Provider • Must comply with special rules defined by the EJB specification • Must derive from javax.ejb.EJBObject • Must duplicate the bean’s business methods • Client code does not call the bean object directly but the EJBObject methods. • When the client invokes a business object method the EJB object delegates the method to the bean, where the actual implementation of the method resides

  13. The Remote Interface public interface javax.ejb.EJBObject extends java.rmi.Remote {public javax.ejb.EJBHome getEJBHome() throws java.rmi.RemoteException; public java.jang.Object getPrimaryKey() throws java.rmi.RemoteException; public void remove() throws java.rmi.RemoteException, javax.ejb.RemoveException; public javax.ejb.Handle getHandle() throws java.rmi.RemoteException; public boolean isIdentical(javax.ejb.EJBObject) throws java.rmi.RemoteException; }

  14. The Home Object • Create EJB objects • Clients cannot instantiate EJB objects directly because EJB objects might reside on a different machine • Finds existing EJB objects • Remove EJB objects • Home objects are specific to the container therefore they are automatically generated by the container

  15. The Home Interface • Define methods for creating, finding and destroying EJB objects • The container’s home Object implement the (user-defined) Home Interface • javax.ejb.EJBHome define required methods all Home Interfaces must support

  16. Home Interface public interface javax.ejb.EJBHome extends java.rmi.Remote {public EJBMetaData getEJBMetaData() throws java.rmi.RemoteException; public javax.ejb.HomeHandle getHomeHandle() throws java.rmi.RemoteException; public void remove(javax.ejb.Handle handle) throws java.rmi.RemoteException, javax.ejb.RemoveException; public void remove(Object primaryKey) throws java.rmi.RemoteException, javax.ejb.RemoveException; }

  17. The Local Interfaces • Used to improve performance. • Similar to the remote interfaces and objects except they are local, therefore eliminate some tasks • only work when calling beans in the same process.

  18. Deployment Descriptor File • key to implicit middleware • used by the container to determine what services to provide for the bean • Used to specify bean requirements • bean management and lifecycle • persistence • transaction • security

  19. Home Interfaces Local Interfaces Enterprise Bean Classes Remote Interfaces Deployment Descriptor Vendor-specific files Ejb-jar File • compressed file that follows the .zip compression format Jar File Creator EJB Jar File

More Related