a presentation about ejb n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
A Presentation About EJB PowerPoint Presentation
Download Presentation
A Presentation About EJB

Loading in 2 Seconds...

play fullscreen
1 / 18

A Presentation About EJB - PowerPoint PPT Presentation


  • 126 Views
  • Uploaded on

A Presentation About EJB. Basic concept of EJB EJB Design Persistence Transaction Concurrency/Security J2EE Environment. What is EJB. A simple definition EJB is a standard server-side component model for Component Transaction Monitors

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'A Presentation About EJB' - xiang


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
a presentation about ejb
A Presentation About EJB
  • Basic concept of EJB
  • EJB Design
  • Persistence
  • Transaction
  • Concurrency/Security
  • J2EE Environment
what is ejb
What is EJB
  • A simple definition
    • EJB is a standard server-side component model for Component Transaction Monitors
  • EJB denote Enterprise JavaBean based Component Transaction Monitor
    • the EJB container is like mini-server, which provide runtime support for beans it contians.
  • Beyond CTM
    • persistence, security, concurrency and source management ( bean instance pool, connection pool)
need for ejb
Need for EJB
  • It is difficult to group operations on distributed objects into single transaction.
  • Transaction Processing Monitor has been around for 30 years, but it is not object oriented (procedure). The business logic in a TP monitor is not as flexible, extensible, or reusable as business objects in a distributed object system.
  • ORB based distributed object system need to handle concurrency, transaction, security, persistence and everything else.
  • With EJB, the only thing you focus on is the business logic. It makes server developing simpler and faster
component model
Component Model
  • A component model defines a set of interfaces and classes in the form of Java Packages that must be used in a particular way to isolate and encapsulate a set of functionality.
  • Component is developed for a specific purpose but not a specific application, can be used to any business application which needs that component--reusable, portable
  • The component model is a contract that defines the responsibilities of the CTM and the business objects
  • EJB is standard server-side component model
benefit of standard component model
Benefit of Standard Component Model
  • The standard component model is one of the keys for the future success of a distributed system
  • you can develop business objects using EJB and expect them to work on any CTM which support EJB specification--reusability, and portability
  • It can benefit from the third part products, the add-on products and component library is more attractive to software vendors
  • EJB is the only standard server component so far
ejb design

JSP & SERVLETS

Presentation

layer

Business Logic Layer

Session Bean

Entity Bean & Database

Data layer

EJB Design
  • Good Design Style
  • Entity bean logically is representation of database
  • Easy for transaction management
    • One business function could have to access several beans
  • Easy for programming
    • Easy for modification and extension
  • Reduce network traffic and latency
xml deployment descriptor
XML Deployment Descriptor
  • deploy descriptor--ejb-jar.xml
  • Tell the container how to manage the objects
    • decsribe bean--entity or session (stateless/stateful)
    • Specifying the primary key -- <prim-key-class>
    • set environment entries -- <env-entry>
    • set the interaction of beans -- <ejb-ref>
    • set transaction /secyrity property -- <container-transaction>
  • In JBOSS, you also have to write your own
    • jboss.xml
    • jbuild.xml
persistence bmp
Persistence: BMP
  • BMP/CMP
  • EJB has strict specification on BMP, so your implementation can be used for any vendor
  • the bean implementation class must implement all SQL operations.
  • In EJB implementation you have to provide implementation for all the methods which involved in SQL operation.
  • Set persistence management as Bean in --ejb-jar.xml
persistence cmp
Persistence: CMP
  • CMP is vendor specific, the EJB specification does not say how CMP should work
  • You do not have to write any data access code. do not have to provide any method implementation.
  • dramatically different from version1.1 to version2.0
  • set the persistence as container in ejb-jar.xml
  • specify data mapping in ejb-jar.xml
  • the beauty of CMP is freeing you from the coding except business logic
transaction
Transaction
  • Transaction is an integral part of Database application
  • In distributed system, you have to implement a set of operation over several distributed databases
  • Transaction let you to group a set of distributed operations into all-or-nothing operation
  • CTM / BTM/ Client
  • CTM -- Controlled by using the deployment descriptor
  • set transaction property inside <container-transaction> tag
    • Not supported, supported, required, requiresNew, Mandatory, Never
    • method/bean
transaction bmt
Transaction -- BMT
  • An entity bean is not allowed to control its transaction scope at all wherever in CTM or BTM
  • Java Transaction Service (JTS)
  • Java Transaction API ( JTA ) to control JTS
  • Only session bean can call the getUserTransaction method in the SessionContext object
  • context.getUserTransaction().begin()
  • context.getUserTransaction().commit()
  • CMT and BMT can not mixed
distributed objects communication
Distributed Objects Communication
  • Three main distributed object services available
    • CORBA, platform and language independent
    • DCOM, only use in Microsoft platform
    • Java RMI, limited to the Java Remote Method Protocol
  • EJB use Java RMI-IIOP
    • am implementation of the Java RMI over IIOP, which combine the simplicity of the Java RMI and platform and language independence of IIOP
    • Sun also provides API for EJB to communicate with CORBA based distributed objects
    • all communications are remote based
concurrency
Concurrency
  • Session bean do not support concurrent access
    • stateless, no state need to maintain
    • stateful, extension of one client, only serve that client
  • Entity beans are shared component that need to implement concurrency
    • EJB automatically support
    • normally no coding needed
  • reentrant/loopback
    • a thread of control try to reenter a bean instance
    • non reentrant by default
security naming
Security/Naming
  • Security issue
    • Authentication
    • access control
    • secure communication
      • EJB1.1 only specify the access control
      • EJB 2.0 have specification on Authentication too
  • Naming service must provide
    • object binding
    • lookup API
  • EJB use JNDI to locate the beans and sources
web interface
Web Interface
  • Web application uses a combination of servlet and Java server page, we can use servlet to access the session bean directly, but. . . . . .
  • The client -side stubs have no awareness of the HttpSession class
  • when session goes away, the session bean can continue to exist for some period of time before EJB container figure out that the client is gone. It is waste of resource.
  • the Access bean will take care of the problem by using HttpSessionBindingListener interface
j2ee environment
J2EE Environment
  • Basically, when you use EJB, you are not only working with EJB, you are working with J2EE Environment.
  • A typical j2ee server typically include JSP, Servlet, EJB, JNDI, JMS, JDBC, XML, RMI, and CORBA. JBOSS as well.
  • EJB is the core part of J2EE environment
  • A typical J2ee server is typical 3-tier server system
    • Web server
    • EJB server
    • Database
typical j2ee server

Browser

Web Container

JSP Pool

Servlet

Web interface

EJB container

Session Bean

Bean pool

Database

Typical J2EE Server
limitation improvement
Limitation/Improvement
  • the most common knocks against EJB is its performance
    • all Communication among beans must be through Remote interface--data marshalling
    • Even local method call is more expensive in EJB
    • Transaction overhead
    • database access
  • Improve EJB performance
    • minimize the remote method call
    • increased entity and session caching
    • Data connection pool
    • An optimized local call mechanism
    • Data caching