1 / 10

Session Beans

Session Beans. Celsina Bignoli bignolic@smccd.net. Session Beans. reusable components that implement business logic business rules algorithms workflows. Session Bean Lifetime. short lived object lifetime of a session of the client code calling the bean

starbuck
Download Presentation

Session Beans

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. Session Beans Celsina Bignoli bignolic@smccd.net

  2. Session Beans • reusable components that implement • business logic • business rules • algorithms • workflows

  3. Session Bean Lifetime • short lived object • lifetime of a session of the client code calling the bean • client code calls a session bean  container create instance of the bean • client disconnects  container may destroy the bean instance • not shared between multiple clients • non-persistent objects • do not survive server crashes

  4. Types of Session Bean • Stateful session beans • retain (conversational) state for a client that span several method requests or transactions • Stateless session beans • they do not hold state between requests • they only hold state for a single method call • container may destroy them after servicing a request or use the same bean for all clients • All instances are exactly the same

  5. Examples • Stateless Session Bean Examples • Credit card verification • Data compression • Stateful Session Bean Examples • Shopping Cart • Banking

  6. Pooling Stateful Session Beans • Pooling stateful beans is more complicated since they retain a state for a particular client • Yet, resources on the server are limited, some pooling is required • Application servers use a mechanism similar to OS swapping • When a bean is not in use its state is passivated, i.e. swapped out and saved on hard disk • When the original client calls a method the state for that client is activated, i.e. it is swapped in

  7. Pooling Stateful Session Beans(2) • The bean receiving the activated state might not be the original bean • Passivation/activation can entail input/output bottleneck • Passivation can occur at any time and it is responsibility of the container • Passivation cannot occur on beans involved in a transaction • Most container use a Most Recently Used (MRU) passivation strategy • Containers usually use a just-in-time algorithm to activate beans

  8. Conversational State Rules • During passivation the EJB container uses serialization to convert a Bean’s conversational state to a bit-blob and stores it to disk • Possible because javax.ejb.EnterpriseBean extends java.io.Serializable

  9. Passivation 2: Pick the least recently used bean EJB Object Enterprise Bean Remote interface 3: Call ejbPassivate() 1:Invoke Business method 4: Serialize the bean state 5:Store passivated Bean state Client Other Enterprise Beans

  10. Activation 3: Reconstruct bean EJB Object Enterprise Bean Remote interface 4: Call ejbActivate() 1:Invoke Business method 5 : Invoke business method 2: Retrieve passivated state Client Other Enterprise Beans

More Related