CDI 1.1: Is @Observes @Initialized(TransactionScoped.class) supposed to work?
@ApplicationScoped
public class MyClass {
public void processConversationScopedInit(@Observes
@Initialized(TransactionScoped.class) Object payload) {}
public void processConversationScopedDestroyed(@Observes
@Destroyed(TransactionScoped.class) Object payload) {}
}
It's a standard scope in CDI 1.1, but it's conspiciuously missing from this list here:
http://www.next-presso.com/2014/06/you-think-you-know-everything-about-cdi-events-think-again/
I can't seem to get it to work in TomEE 7.0.5/OpenWebBeans, and I'm curious if that's just an oversight in the spec. Thanks!
@TransactionScopedis not a standard scope in a way that it is not implemented by CDI (or, well, CDI impls). It comes from JTA and it also has their package -javax.transaction.That being said, it should behave as all other
@NormalScopecontexts and hence should fire the@Initializedevents for you to observe. Although do note that CDI spec only recommends this by saying:I haven't tried this myself but I would wager this works for most up to date implementations. Then again, you are in CDI 1.1 which is now pretty ancient.