1 / 29

E nterprise J ava B ean

E nterprise J ava B ean. Matt. J2EE. J2EE Overview. J2EE 1.4 API. Distributable Components. Components should provide services to clients running locally or remotely SelfContained Components Components should only contain the code necessary to implement their services

maegan
Télécharger la présentation

E nterprise J ava B ean

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. Enterprise Java Bean Matt

  2. J2EE

  3. J2EE Overview

  4. J2EE 1.4 API

  5. Distributable Components • Components should provide services to clients running locally or remotely • SelfContained Components • Components should only contain the code necessary to implement their services • Infrastructure services should be injected by the execution environment • Standard infrastructure services include • Directory Services • Distributed transaction management • Security management • Concurrent access management • Persistence management • Resource pooling (e.g. DB connections) • Administration interface • Load Balancing • Fault tolerance An application server provides the infrastructure and services to run components/applications

  6. Object Pooling • An application server may create a pool of bare objects that may be used as EJBs when requests are made

  7. Container • A Container • provides the environment in which a bean executes • generates Home Object • generates EJB Object • manages individual bean instances

  8. EJB

  9. EJB • Enterprise Java Bean包括了 • Session Bean: Session beans are essentially service providers • Stateless • Stateful • Entity Bean: Entity beans are used to represent data in a database. • BMP • CMP • Message-Driven Bean: Message driven beans are capable of responding to JMS messages

  10. EJB Overview • EJB simplified distributed development • Develop EJB implementation logic • Define Home/Local Remote/Local interfaces • Container delegates client calls • Container manages resources/lifecycle/callbacks

  11. EJB

  12. EJB Design Approaches • Remote interface • Home interface • Bean class

  13. EJB Architecture

  14. EJB Flow Chart

  15. Client View of EJB

  16. EJB clients utilizes the Java Naming and Directory Interface (JNDI) to look up for the references to home interfaces use home and remote EJB interfaces to utilize all EJB-based functionality EJB Home interface create EJBs remove EJBs find handles to EJB remote interface objects EJB remote interfaces provide business-specific functionality of an EJB are similar to RMI Remote interface EJB implementation (Bean Class) business method invocation database loading logic passivation, database storage Session Context The Container has already reference to the bean The bean interacts with the Container through SessionContext and retrieves home interfaces gets and sets transactions attributes obtains security attribute The setSessionContext method is used to inform the bean about the session context EJB

  17. Steps to Develop an EJB

  18. Hello World Object Model using RMI

  19. Session Bean

  20. Session EJBs View • Stateless • Stateful

  21. Life Cycle of Stateless Session Bean

  22. Life Cycle of Stateful Session Bean

  23. Stateful Bean A stateful bean contains a conversational state that is retained across method calls and transactions. The create method takes argumentse.g. create(String id) , create(int I , String id) There can be one or more arguments in a create method e.gAn EJB that unzips 100 bytes of data An EJB that checks to see if a stock symbol is valid Stateless Bean A stateless bean does not have any state between calls to its methods The create method does not take argumentse.g create() There can be no arguments in a create method e.gAn EJB that books a flight and rents a car at a travel agent’sweb site. Stateful vs Stateless

  24. Entity Bean

  25. Message-Driven Bean

More Related