[cdi-dev] [JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts

Chris Rankin (JIRA) issues at jboss.org
Mon May 16 10:37:00 EDT 2016

    [ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13238152#comment-13238152 ] 

Chris Rankin commented on CDI-601:

For reference, I think {{BeforeApplicationShutdown}} or {{BeforeApplicationUndeploy}} would be semantically better event names than {{BeforeContainerShutdown}}.
Also, the _particular_ bean which I was struggling to shut down was actually {{@Dependent}} scoped with {{@ApplicationScoped}} dependencies, so I don't think that I could have replaced its {{@PreDestroy}} method with an event observer method in this case. What I actually did was locate the {{@ApplicationScoped}} bean that owned the target bean, and then direct the shutdown from a {{@Destroyed(ApplicationScoped.class)}} observer method there instead.
My original notion was for {{@ApplicationScoped}} beans not to be destroyed while other beans still hold contextual references to them, although I have no idea how feasible that would be to implement.

> Add container lifecycle event fired before container destroys all contexts
> --------------------------------------------------------------------------
>                 Key: CDI-601
>                 URL: https://issues.jboss.org/browse/CDI-601
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>            Reporter: Martin Kouba
>             Fix For: 2.0 (discussion)
> The name might be something like {{BeforeContainerShutdown}}. Note that we probably cannot change the name or semantics of {{BeforeShutdown}}, which is fired after container destroys all contexts. The motivation is to allow the beans to perform some kind of cleanup before dependencies could be disposed (the ordering of destruction is not defined).

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list