[jbossts-issues] [JBoss JIRA] (JBTM-3106) Firing an @Initialized(TransactionScoped.class) event

Ondra Chaloupka (Jira) issues at jboss.org
Wed Feb 13 07:17:01 EST 2019

     [ https://issues.jboss.org/browse/JBTM-3106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ondra Chaloupka updated JBTM-3106:
    Git Pull Request: https://github.com/jbosstm/narayana/pull/1403

> Firing an @Initialized(TransactionScoped.class) event
> -----------------------------------------------------
>                 Key: JBTM-3106
>                 URL: https://issues.jboss.org/browse/JBTM-3106
>             Project: JBoss Transaction Manager
>          Issue Type: Enhancement
>          Components: JTA
>    Affects Versions: 5.9.2.Final
>            Reporter: Ondra Chaloupka
>            Assignee: Laird Nelson
>            Priority: Major
> It would be beneficial to have the CDI-specific wrapper around Narayana's TransactionManagerImple that fires an @Initialized(TransactionScoped.class)-qualified event.
> For the CDI, it's a good practice. The all built-in scopes have to provide this behaviour.
> The CDI specification says (in section 6.7):
> {quote}
> Portable extensions are encouraged to synchronously fire:
> * an event with qualifier @Initialized(X.class) when a custom context is initialized, i.e. ready for use,
> * an event with qualifier @BeforeDestroyed(X.class) when a custom context is about to be destroyed, i.e. before the actual destruction,
> * an event with qualifier @Destroyed(X.class) when a custom context is destroyed, i.e. after the actual destruction,
> where X is the scope type associated with the context.
> A suitable event payload should be chosen.
> {quote}
> The {{begin()}} method a Narayana-supplied but CDI-specific transaction manager wrapping Narayana's "ordinary" one should do:
> {code}
> @Inject
> @Initialized(TransactionScoped.class)
> private Event<Transaction> initializationBroadcaster;
> @Inject @BeforeDestroyed(TransactionScoped.class)
> private Event<Transaction> beforeDestructionBroadcaster;
> @Inject @Destroyed(TransactionScoped.class)
> private Event<TransactionManager> destructionBroadcaster;
> // in its begin() method:
> super.begin();
> initializationBroadcaster.fire(this.getTransaction());
> // in its commit() and rollback() methods and anywhere else I'm forgetting: 
> beforeDestructionBroadcaster.fire(this.getTransaction());
> super.commit(); // or rollback or whatever
> destructionBroadcaster.fire(this);
> {code}

This message was sent by Atlassian Jira

More information about the jbossts-issues mailing list