jsr345-experts@ejb-spec.java.net

[jsr345-experts] Re: XXX Transactional execution of a PostConstuct or PreDestroy method of a singleton session bean

From: Antonio Goncalves <antonio.goncalves_at_gmail.com>
Date: Mon, 12 Sep 2011 10:20:10 +0200

+1 for transactional callback. Just to be sure, are we also talking about
@PrePassivate @PostActivate SFSB lifecycle ?

Antonio

On Fri, Sep 9, 2011 at 13:27, Adam Bien <abien_at_adam-bien.com> wrote:

> +1 for transactional callbacks. Had the issue in @Singletons, which
> prefetched the data from DB already.
> On 07.09.2011, at 14:40, Pete Muir wrote:
>
> > In general, it's very useful for a postconstruct/predestroy method to be
> able to be called within a transaction.
> >
> > For example, consider seeding data into a database (singleton with
> @Startup and an @PreDestroy), logging user access (http session scoped SFSB)
> and so on.
> >
> > On 7 Sep 2011, at 03:18, Marina Vatkina wrote:
> >
> >> Experts,
> >>
> >> Let's clarify transactional support for PostConstuct or PreDestroy
> methods.
> >>
> >> a) PostConstuct or PreDestroy methods of a singleton session bean can be
> executed in a transaction, while other bean types do not seem to allow this.
> Why would the singleton bean is different from any other bean?
> >>
> >> b) Why would the transactional attribute be specified differently for a
> singleton vs. other beans? See e.g. an XXX marker under section "8.3.7
> Specification of the Transaction Attributes for a Bean’s Methods" in one of
> the bullets of the "Transaction attributes are specified for the following
> methods:" text:
> >>
> >> <...>
> >>
> >> For a singleton session bean, the transaction attributes are specified
> for the PostConstruct and PreDestroy lifecycle callback interceptor methods,
> if any. In order to specify the transaction attribute for a PostConstuct or
> PreDestroy method of a singleton session bean, the transaction attribute
> must be specified for the method(s) on the bean class, rather than for a
> superclass or PostConstruct or PreDestroy interceptor method."
> >>
> >> thanks,
> >> -marina
> >>
> >>
> >>
> >
>
>
>


-- 
Antonio Goncalves
Software architect and Java Champion
Web site <http://www.antoniogoncalves.org> |
Twitter<http://twitter.com/agoncal>|
Blog <http://feeds.feedburner.com/AntonioGoncalves> |
LinkedIn<http://www.linkedin.com/in/agoncal>| Paris
JUG <http://www.parisjug.org>