my dog learned polymorphism
The moose likes EJB and other Java EE Technologies and the fly likes Singleton Session Bean - PostConstruct/PreDestroy are Transactional? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Singleton Session Bean - PostConstruct/PreDestroy are Transactional?" Watch "Singleton Session Bean - PostConstruct/PreDestroy are Transactional?" New topic
Author

Singleton Session Bean - PostConstruct/PreDestroy are Transactional?

Anirudh Gupta
Greenhorn

Joined: Dec 08, 2010
Posts: 20

PostConstruct and PreDestroy methods of Singletons with container-managed transactions are transactional.

What are the semantics of the above statement?
Why in the first place do these methods have to be in a transaction context in the first place?
Joemon Anthony
Greenhorn

Joined: May 22, 2011
Posts: 22

Hi Anirudh,
As you might know that Transactional Attributes comes into picture, when your service is associated with a Transaction. If you do not want any transaction from your service then you can use NOT_SUPPORTED Transactional Attribute. But sometimes it can be useful to complete transactional activities during the PostConstruct and PreDestroy life cycle interceptor callbacks for example : logging purpose. So by making PostConstruct and PreDestroy transactional, gives freedom to the developer to write any transactional statements in that.


(SCJP 5, OCA 9i)
(Always interested in learning)
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Singleton Session Bean - PostConstruct/PreDestroy are Transactional?
 
Similar Threads
suppourt for Annotation Programming . In servlets
@PostConstruct and @PreDestory
Relevance of the section "4.8.3" in the EJB 3.1 spec
Method signatures for container callbacks
Beginning EJB 3 Application Development: From Novice to Professional - Errata