Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Invoking remove( )  RSS feed

 
Ravi Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using session beans, if you do not invoke remove on the remote or home interface to remove the ejbObject on the server what happens to the ejbObject?

Is it automatically removed after some time period of inactivity?
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After some period of time, the bean will be passivated. At some later time it may be discarded. A lot of this is app server dependent. For example, on JBoss, the default is to passivate after 10 minutes and discard after 30 minutes. ejbPassivate is called when the passivation occurs, but you don't get called when the bean is discarded.
 
Ravi Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the case of stateless session beans, I'm under the impression that when you invoke create(), an ejbObject is created on the server and a remote reference returned.

Then when you invoke remove(), the ejbObject is invalidated.

What would happen to the ejbObject if you didn't invoke remove(). Would it continue to persist or would it be automatically invalidated after some period of time?
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Incase of a stateless session bean, the bean instances would be placed in a pool, from which they would be retrieved on an as needed basis.
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling remove on a stateless session bean does not get turned into a call to ejbRemove.

Also, calling create on the home interface of a stateless session bean does not lead to a call to ejbCreate. A container will create SLSB instances as it needs to. When it creates one it will call ejbCreate, and then put that instance in a pool. If ejbCreate is called at the same time you call create, it is just a coincidence. When the container no longer needs/wants the instance in the pool, it will call ejbRemove.
 
Ravi Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what happens to the ejbObject on the server if you don't invoke remove().
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!