Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB passivate  RSS feed

 
Hari babu
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
 
Susil Parida
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" ?
 
Sunil Sahu
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)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!