This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

EJB passivate  RSS feed

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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)
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!