• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help in stateless and stateful beans

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello people

I have some queries.
It is known that the container, at times, passivates the stateful session beans and stores them in some secondary storage in a serialized form. Later when the client with which the bean is binded,invokes a method.... the container activates the bean and the serialized object is read back in the memory and converted to in-memory bean.
It is also know that we can set the timeout of a stateful session bean.
Now consider the following scenario
_____________________________

A client invokes a method on a stateful session bean which executes some code. Then there is no conversation between the bean and the client .. So the container , either using the LRU algo or some other passivation algo, passivates the bean to a secondary storage.
NOTE:- the session timeout of the bean is set to 10 minutes.
Now the client ends his session with the site.. what happens to the serialized bean which is stored in the database?.. what happens if the bean is kept in the database for more that 10 minutes ( which is the bean session timeout ) .. will the container keep the track of all the beans in the database and check on regular intervals about the states each bean is ..
please reply to me ... as to whether i am going on the right track .. or i have messed up the whole concept.
Bye
and
Thanx in advance
[ February 19, 2002: Message edited by: Dharmesh Chheda ]
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you making the proper distinction between timeout of the appserver Session object and a timeout for a Session EJB? They are really two different kinds of things.
The actual persistency for a Stateful Session EJB is handled by your activate and passivate code, which is called when the bean itself is being recycled. By default, most EJB servers maintain internal consistency with the backing store but not with any updates or deletions to that backing store from external sources (this way they can avoid the overhead of monitoring for external changes).
Although there are many who disagree, I recommend that you use Entity EJBs for DBMS-backed objects rather than Session EJBs. After all, they are designed to provide the session EJB functionality plus be more aware of persistency concerns.
If you're a purist (or expect a lot of changes in the system) put business logic in a Session EJB and have it reference Entity EJB(s) for the persistent data.
 
Dharmesh Chheda
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Tim thanks for replying
here i am using visual age for java .. and in that i am setting the bean properties as stateless and stateful along with a session timeout in case of stateful beans.
Then i tested a code..
what i did is that i created a stateful session bean and kept its timeout as 2 seconds.. then through a servlet i obtained an instance of the bean and made the thread sleep for 4 seconds.. after which i invoked a method on the bean class.
but it gave me the error


which means that the bean has been destroyed after the timeout.. so what in case of passivation?.. i really cant get hold of this
 
Replace the word "snake" with "danger noodle" in all tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic