1 / 20

EJB

EJB. Johan Muskens Technische Universiteit Eindhoven. Agenda. Topic: Introduction to EJB. Enterprise JavaBeans.

zwi
Télécharger la présentation

EJB

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 Johan Muskens Technische Universiteit Eindhoven

  2. Agenda • Topic: • Introduction to EJB

  3. Enterprise JavaBeans 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. (Sun Microsystems’ definition) … and it is Java based

  4. Goal • Let developer focus on the business logic • In the context of EJB the notion of component is played by ‘beans’ that implement certain business logic. • An EJB provides: • mechanisms that allows beans to be deployed in a distributed setting • managing services such as transactions, persistence, concurrency, and security

  5. Context: Three-tier architectures First Tier Middle Tier Third Tier Presentation Business Logic Backend Database Database

  6. Implementing Distributed Objects using Stubs and Skeletons Client Server 2. Communicate method invoked 1. Client invokes a method SKELETON Object Server STUB NETWORK 3. Invoke on server 5. Return result 4. Communicate return value

  7. Encapsulation of business logic • OO languages are used to improve development of GUIs, simplify access to data and to encapsulate business logic. • By encapsulating business models into objects you increase: • flexibility • extensibility • reusability • …and therefore the software can evolve as the business evolves • There are 2 types of business logic: • Business processes • Business data

  8. Different types within business logic A bean implements business logic: Business process SessionBean Business data EntityBean Remote Interface Home Interface Primary Key

  9. Enterprise JavaBeans architecture EJB Server Client EJB Container Client code EJB home Home interface EJB object Remote interface Bean class Red: define your self Purple: automatically generated

  10. Bean deployment Beans are deployed using JAR (Java ARchive) files. JAR file Class files Deployment descriptor

  11. Resource Management • One of the benefits of EJB servers is that they are able to handle heavy workloads while maintaining a high level of performance. • EJB servers increase performance by • synchronizing object interactions • sharing resources

  12. Resource Management Instance pooling 1. Create() newInstance() EJB Home EJB Object Home stub Assign instance to EJB Bean pool 2. EJB Home Home stub EJB Object Remote reference Bean pool

  13. Resource Management Instance swapping Client EJB server Instance pool P C stub A E Q bean instances D stub EJB object Client P stub E C Q D A stub Client P stub E C Q A D stub Works only for stateless beans!

  14. Resource Management Bean Instance activation and passivation EJB Server secondary storage Client 1. P A stub EJB Server secondary storage Client bean instance eviction 2. P stub EJB Server secondary storage Client 3. P B stub

  15. Resource Management Session beans reduce network traffic and thin down clients • Client using only Entity beans • Logic is in client • Clients does lots of small updates on entity beans • Client using Session beans • Logic is in the session beans • Client only gives small number of commands to • Session beans EJB SERVER

  16. Conclusion EJB is about hiding • EJB hides a lot of things for the developer. Such that the developer can focus on the business logic of the application. • EJB hides: • Distribution of objects • Resource Management • Transactions • Security • Concurrency

  17. Enterprise JavaBeans properties Control Flow: Managed by EJB container / EJB server Beans are passive (do a transaction and stop) Distribution: Bean resides on a Enterprise Bean Server Topology: Dynamic (bean creation/destruction/replacement/activation/…) Interaction Style: Remote Method Invocation Binding Time: Binding at Run Time Binding Type: External and Internal binding (Client and bean can do binding) Multiplicity: Multiple occurrences of a bean can be created.

  18. COM vs. Enterprise JavaBeans • Deploy the class as a Dynamic Link Library or Executable • Deploy bean as a JAR file • Notion of interfaces and implementations • Notion of interfaces (Remote Interface & Home Interface) and implementation (bean) • Use abstract base class to define binary interfaces • Enterprise Java Bean Server / Container specification • Techniques for dynamically selecting implementations • Use Java Naming and Directory Interface for locating Beans (actually home object) • Dynamic discovery of implemented interfaces • ??? Not applicable because you never talk to bean directly.

  19. COM vs. Enterprise JavaBeans Focus: Hiding distribution of objects and managing services in a business transaction system. • Enterprise Java Beans: • + OS independence • Language dependence • COM: • OS dependance • + Language independance Focus: Dynamic & Efficient composition of a system using binary components (without recompilation).

  20. References Enterprise Java Beans (2nd ed) (2000) Richard Monson-Haefel ISBN: 1-56592-869-5

More Related