Java
  Home arrow Java arrow Page 2 - Session Beans in EJB 3.0
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Session Beans in EJB 3.0
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-03-28

    Table of Contents:
  • Session Beans in EJB 3.0
  • Stateful Session Beans
  • Implementing Session Beans
  • Session Beans in the Real World

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Session Beans in EJB 3.0 - Stateful Session Beans


    (Page 2 of 4 )

    According to the definition a Stateful Session Bean is "A bean that is designed to service business processes that span multiple method requests or transactions." Since the Stateful Session Bean is designed for servicing requests spanning multiple method calls, it saves the Conversational State for each client. So for each client a different Bean instance services the request. The main characteristic features of Stateful Beans are:

    1. The state of the bean represents the conversation between the client and the bean.
    2. The bean instance holds information about the client across method calls/invocations.
    3. The Stateful Bean mediates between client and other components of the system to present simplified view to the client.



    Though the third property can be attributed to Stateless Session Beans as well, the "stateful" property of the Stateful Session Bean makes it a better candidate to be the mediator. The next important point to be kept in mind is about the instance variables. Whenever an instance variable comes into the picture, the following is true it if it is a part of the Conversational State:

    1. The member variable is transient and its data type is primitive i.e. it's of type int, boolean etc.
    2. It is of non transient Java object type i.e. it's an instance of another class.

    If the above points are satisfied then that member variable becomes a part of a Conversational State. In other words the states of such variables are saved and updated according to the method invocations and across method invocations.

    The next aspect is pooling. Since the Conversational State has to be saved, the logic behind pooling of Stateful Session Bean is complex. I will be discussing it in the future.

    An example of a use of a Stateful Session Bean is a shopping cart. Each time a user adds a product, a method invocation occurs and a request is sent to the bean instance; the bean executes the logic and saves the current result. When the user checks out, the final result (in this case the total cost of the cart) is given. The focus here is on tracking the user requests until checkout is performed which may be after many requests. And tracking a user across requests is the forte of Stateful Session Beans. Next let's look at the steps involved in developing both sub-types of Session Beans.

    More Java Articles
    More By A.P.Rajshekhar


       · In this article I have discussed the basics of the Session Bean development in EJB...
       · Good article about Enterprise Java Beans. However, there is no information...
     

    JAVA ARTICLES

    - Deploying Multiple Java Applets as One
    - Deploying Java Applets
    - Understanding Deployment Frameworks
    - Database Programming in Java Using JDBC
    - Extension Interfaces and SAX
    - Entities, Handlers and SAX
    - Advanced SAX
    - Conversions and Java Print Streams
    - Formatters and Java Print Streams
    - Java Print Streams
    - Wildcards, Arrays, and Generics in Java
    - Wildcards and Generic Methods in Java
    - Finishing the Project: Java Web Development ...
    - Generics and Limitations in Java
    - Getting Started with Java Web Development in...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT