[cdi-dev] [JBoss JIRA] (CDI-30) An API for managing built in contexts

arjan tijms (JIRA) issues at jboss.org
Sun May 15 15:35:00 EDT 2016


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

arjan tijms commented on CDI-30:
--------------------------------

[~meetoblivion]
[First PR|https://github.com/cdi-spec/cdi/pull/291/files] looks good!

Would it be an idea to set a wrapped (or decorated) context controller?

What I'm looking for is a way to start contexts possibly earlier than a specific container implementation normally starts them, and stop them possibly later. If the context is started earlier in say a request, then eventually the container will also start that same context later in the request. If that will throw an exception the request will not proceed, which is of course not intended.

Likewise, when the container stops the context this will thus be too early.

With a wrapped context controller, the {{startContexts}} and {{stopContexts}} calls can be ignored for those contexts the application (extension/library) wanted to start earlier and stop later. This does of course assume that the container itself will also use this context controller instead of the current proprietary code.

Additionally, the PR does not contain the check anymore to see if the context is already active or already stopped. Is that still intended to be added? This would be particularly useful for code that needs to be portable between different containers, where one container may already have started the context at a given point, where another container has not (catching the exception would be an alternative here but is obviously not so nice).

Another point, what about letting the caller of the {{startContexts}} method optionally pass in the objects (or a lambda to obtain them) on which that context primarily depends (if any). E.g. for the request scope, pass in an {{HttpServletRequest}} instance.

> An API for managing built in contexts
> -------------------------------------
>
>                 Key: CDI-30
>                 URL: https://issues.jboss.org/browse/CDI-30
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Contexts
>    Affects Versions: 1.0
>            Reporter: Nicklas Karlsson
>            Assignee: John Ament
>             Fix For: 2.0 (discussion)
>
>
> Add management API for built in contexts allowing them to be reused as needed.



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the cdi-dev mailing list