About Question enthuware.oce-ejbd.v6.2.591 :
Moderator: admin
-
- Posts: 3
- Joined: Tue Jul 02, 2013 1:14 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.591 :
I think that third answer is correct as well:
Acquire the resources in @PostConstruct and @PostActivate and release them in @Remove and @PrePassivate.
If @Remove is called - it will clean up resources.
If @Remove is not called bean will eventually time out and @PrePassivate method will execute, and cause resource cleanup.
Am i wrong?
Acquire the resources in @PostConstruct and @PostActivate and release them in @Remove and @PrePassivate.
If @Remove is called - it will clean up resources.
If @Remove is not called bean will eventually time out and @PrePassivate method will execute, and cause resource cleanup.
Am i wrong?
-
- Posts: 3
- Joined: Tue Jul 02, 2013 1:14 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.591 :
I've thought it through one more time, and after considering container shoutdown i think that second answer is the only one correct.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.591 :
The question mentions that passivate/activate of a bean happens from time to time.
Is it more efficient not to clean up and restore in @PrePassivate or @PreDestroy ?
If passivate/activate happen very frequently and clean up/restore happen as frequently, it is time consuming.
Can we leave the resources open during a bean's passivation, so that the resources are still available after the bean is activated again?
Is it more efficient not to clean up and restore in @PrePassivate or @PreDestroy ?
If passivate/activate happen very frequently and clean up/restore happen as frequently, it is time consuming.
Can we leave the resources open during a bean's passivation, so that the resources are still available after the bean is activated again?
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.591 :
It depends on what you want to clean up. If cleaning up a resource takes a lot of time and if the resource is not required by other beans, then you may decide not to clean up at all.
If you like our products and services, please help us by posting your review here.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.591 :
According to p.71 of JSR 318, session 4.2,
I think the option about cleaning up in @PreDestroy and @PrePassivate is correct.a session object's conversational state may contain open resources, such as open sockets and open database cursors. A container cannot retain such open resources when a session bean instance is passivated. A developer of a stateful session bean must close and open the resources in the PrePassivate and PostActivate lifecyle callback interceptor methods.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.591 :
For the explanation in option 1 :
The specification does not mandate that resources need to be released in PrePassivate.You need to release the resources when the bean is passivated as well.
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.591 :
The whole purpose of PrePassivate call back is to give the bean an opportunity to release resources before the bean is passivated. The quote from specification that you quote above says that as well.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 34 guests