[JBoss JIRA] (JBTM-3243) Use PostConstruct/PreDestroy for ApplicationScoped bean (instead of Observer)
by Michael Musgrove (Jira)
[ https://issues.redhat.com/browse/JBTM-3243?page=com.atlassian.jira.plugin... ]
Michael Musgrove updated JBTM-3243:
-----------------------------------
Description:
The LRA implementation needs to observe application shutdown in order to perform clean up activities. It achieves this using an ApplicationScoped bean. But when the destroyed event is fired a new bean may be created which is not what we want with an application scoped bean (this behaviour is seen when running as a Quarkus app). Annotating the method with `@PreDestroy` will ensure the correct application scoped bean used. So instead of
{code}
void disableRecovery(@Observes @Destroyed(ApplicationScoped.class) Object ignore)
{code}
use
{code}
@PreDestroy
void disableRecovery()
{code}
was:
The LRA implementation needs to observe application shutdown in order to perform clean up activities. It achieves this using an ApplicationScoped bean. But when the destroyed event is fired a new bean may be created which is not what we want with an application scoped bean (this behaviour is seen when running as a Quarkus app). Annotating the method with `@ActivateRequestContext` will ensure the correct application scoped bean used. So instead of
{code}
void disableRecovery(@Observes @Destroyed(ApplicationScoped.class) Object ignore)
{code}
use
{code}
@ActivateRequestContext
void disableRecovery(@Observes @Destroyed(ApplicationScoped.class) Object ignore) {
{code}
> Use PostConstruct/PreDestroy for ApplicationScoped bean (instead of Observer)
> -----------------------------------------------------------------------------
>
> Key: JBTM-3243
> URL: https://issues.redhat.com/browse/JBTM-3243
> Project: JBoss Transaction Manager
> Issue Type: Bug
> Components: LRA
> Affects Versions: 5.10.1.Final
> Reporter: Michael Musgrove
> Assignee: Michael Musgrove
> Priority: Major
> Fix For: 5.next
>
>
> The LRA implementation needs to observe application shutdown in order to perform clean up activities. It achieves this using an ApplicationScoped bean. But when the destroyed event is fired a new bean may be created which is not what we want with an application scoped bean (this behaviour is seen when running as a Quarkus app). Annotating the method with `@PreDestroy` will ensure the correct application scoped bean used. So instead of
> {code}
> void disableRecovery(@Observes @Destroyed(ApplicationScoped.class) Object ignore)
> {code}
> use
> {code}
> @PreDestroy
> void disableRecovery()
> {code}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)