[JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts
by Chris Rankin (JIRA)
[ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.sy... ]
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 {{(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
(v6.4.11#64026)
8 years, 7 months
Managing Dependent Scoped Beans
by John D. Ament
Hey guys
Seems like we have some issues in JIRA all focused on managing the
lifecycle of Dependent scoped beans. It also seems like we have many
differing opinions about how to manage them.
- Martin raised a PR to add a release() method to Instance to help destroy
a dependent bean https://github.com/cdi-spec/cdi/pull/286
- I raised a PR https://github.com/cdi-spec/cdi/pull/289 to update the spec
to clarify how to manage a dependent scoped bean.
Right now, it seems that the big disagreement is whether Instance.destroy()
can destroy objects not created by it (the case being around the CDI
utility class, being an impl of Instance). I'm currently heavily against
Martin's proposed changes, but want to get input from others on the group
to understand their perspective.
- Does the spec require destroy() to be called only on instances that it
created? When I read 5.6.1 the only requirement I see is that it has to be
a dependent scoped bean. Note when I ask this I'm asking from the spec
perspective, its a different problem if there's some issues with
implementations following suite (I would imagine there needs to be some
shared global registry of dependent scoped beans for this to work).
- Do we want two methods that effectively do the same thing? I don't see a
strong difference between the two.
On the flipside, my change is more a spec clarification. I'm thinking more
now that it belongs as a reword of 5.6.1 to clarify how to use destroy() on
dependent beans, rather than where I put it. I think realistically we have
all of the tools needed to manage the lifecycle of these classes, just need
to clarify them for people to use.
John
8 years, 7 months
[JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-601:
----------------------------------
I'm not sure I understand. But I would say `no`, this event would merely ensure the injected dependencies are not destroyed during notification. And possibly this could be used together with observer ordering if needed.
> 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
(v6.4.11#64026)
8 years, 7 months
[JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts
by John Ament (JIRA)
[ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.sy... ]
John Ament commented on CDI-601:
--------------------------------
>From your point of view, does observer method ordering also take into account dependencies of beans that the observers will use?
> 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
(v6.4.11#64026)
8 years, 7 months
[JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-601:
----------------------------------
[~meetoblivion] It might not work properly if you call dependencies in the callback (e.g. another {{@ApplicationScoped}} bean).
> 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
(v6.4.11#64026)
8 years, 7 months
[JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts
by John Ament (JIRA)
[ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.sy... ]
John Ament commented on CDI-601:
--------------------------------
If I'm already subscribed via a `@PreDestroy` method, shouldn't that continue to work?
> 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
(v6.4.11#64026)
8 years, 7 months
[JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-601:
----------------------------------
[~manovotn] Yes, sooner. It should be something like _"The container is about to destroy all contexts and shut down. Please execute all cleaning up business which involves invocation of dependencies."_.
> 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
(v6.4.11#64026)
8 years, 7 months
[JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts
by Matej Novotny (JIRA)
[ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.sy... ]
Matej Novotny commented on CDI-601:
-----------------------------------
Similar to {{@Destroyed}} but fired sooner than the actual destruction happens, right?
At least that is what the user (in the forum reference link) needs; at least from what I understood.
> 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
(v6.4.11#64026)
8 years, 7 months
[JBoss JIRA] (CDI-601) Add container lifecycle event fired before container destroys all contexts
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-601?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba updated CDI-601:
-----------------------------
Description: 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). (was: 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. )
> 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
(v6.4.11#64026)
8 years, 7 months