• 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

EJB passivate

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
In my EJB what fields can be transient and
what references has to be set to null in ejbPassivate method ?
Suppose session bean A is servicing my client A, Due to memory constraint the bean A is passivated to service another client B.
In my bean client A has set the following values, i have the following attributes and its value
String a = "hari";
transient String b = "name";
which of the above variable should set to null in my passivate method for the above case, so that there is no corrupt data for client B
What should be done if "a" or "b" points to a resource like "database connection"

Hari
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The variables declared as transient will be not passivated so as good as automatically becoming null. If you have some resources like DB connection and Files then you need to release them in passivation. In above example only String a with value "Hari" will be passivated.
String b will be initialized as null when the bean will get activated.
 
Hari babu
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Susil Parida:
The variables declared as transient will be not passivated so as good as automatically becoming null. If you have some resources like DB connection and Files then you need to release them in passivation. In above example only String a with value "Hari" will be passivated.
String b will be initialized as null when the bean will get activated.


If a variable "V" (V=10) is not passivated and if the bean instance is assigned from client "A" to some other client "B". Does the Client "B" instance gets the the same value (V=10, same as client A) for its instance variable "V" ?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make Transient :
Temporary that do not need to persist across bean activation should be declared transient

Make null :
And non serializable attributes like ResultSet or resources like DBconnection should be made null before passivation (in ejbPassivate method )and then occupied back when activation (in method ejbActivate method)
 
reply
    Bookmark Topic Watch Topic
  • New Topic