jsr236-experts@concurrency-ee-spec.java.net

[jsr236-experts] CDI issue from EE7 platform EG [was Re: JSR 236]

From: Anthony Lai <anthony.lai_at_oracle.com>
Date: Mon, 18 Feb 2013 15:32:45 -0800

Dear experts,

To address this issue raised by Pete Muir, the spec lead for CDI 1.1:
> > * Support propagation or creation of new CDI contexts for tasks,
> > mapping section 2.3 to CDI contexts as appropriate (looks to me like
> > just the application context)

I am proposing adding the following subsection under section 2.3.2 in
the JSR 236 spec to clarify the usage of CDI beans as tasks:

2.3.2.1 Tasks and Contexts and Dependency Injection (CDI)

CDI beans can be used as tasks. Such tasks could make use of injection
if they are themselves components or are created dynamically using
various CDI APIs. However, application developers should be aware of the
following when using CDI beans as tasks:

- Tasks that are submitted to a managed instance of ExecutorService may
still be running after the lifecycle of the submitting component.
Therefore, CDI beans with a scope of @RequestScoped, @SessionScoped, or
@ConversationScoped are not recommended to use as tasks as it cannot be
guaranteed that the tasks will complete before the CDI context is
destroyed.

- CDI beans with a scope of @ApplicationScoped or @Dependent can be used
as tasks, as long as the tasks can run into completion before the
application is destroyed.

- The transitive closure of CDI beans that are injected into tasks
should follow the above guidelines regarding their scopes.

Feedback welcome as usual.

Regards
Anthony

On 2/11/13 12:54 PM, Anthony Lai wrote:
> Forwarding some issues raised on the Java EE platform spec expert
> group regarding JSR 236 for discussion.
>
> Regards
> Anthony
>
>
> -------- Original Message --------
> Subject: Re: [jsr342-experts] Re: JSR 236
> Date: Mon, 11 Feb 2013 11:36:11 -0800
> From: Linda DeMichiel <linda.demichiel_at_oracle.com>
> Organization: Oracle Corporation
> To: jsr342-experts_at_javaee-spec.java.net
> CC: Anthony Lai <anthony.lai_at_oracle.com>
>
>
>
> Hi Pete,
>
> On 2/11/2013 2:25 AM, Pete Muir wrote:
> > Hi Linda
> >
> > Apologies for the late reply.
> >
>
> Thanks for your feedback. Please also feel free to join the
> users list on thehttp://java.net/projects/concurrency-ee-spec project
> to communicate these items directly to the spec lead.
>
> I think the latest draft of the spec (see
> http://java.net/projects/concurrency-ee-spec/downloads/download/EE%20Concurrency%20Utilities-2013-01-25.pdf)
> addresses some of the example items, but feel free to make more concrete
> suggestions.
>
>
> -Linda
>
>
>
> > (1) It should be included in the full platform
> > (2) Probably not.
> >
> > I've also had quite a few comments that the spec is missing CDI
> > integration. I've cc'd David, our spec rep, so he can communicate
> > this to the JSR-236 EG as well.
> >
> > * Support injecting into tasks (runnable and callable) using all
> > types of injection - constructor, method and field
> > * support injecting a default managed executor services using @Inject
> > natively
> > * Show examples of using resource producers to map alternative
> > managed executor services to CDI injection (as we normally do for
> > @Resource)
> > * Support propagation or creation of new CDI contexts for tasks,
> > mapping section 2.3 to CDI contexts as appropriate (looks to me like
> > just the application context)
> > * Support for @Transactional as well as EJB transactions
> > * support injecting a default managed scheduled executor services
> > using @Inject natively
> > * Show examples of using resource producers to map alternative
> > managed scheduled executor services to CDI injection (as we normally
> > do for @Resource)
> > * Show examples of using resource producers to map context services
> > to CDI injection (as we normally do for @Resource)
> > * support injecting a default managed thread factory using @Inject
> > natively
> > * Show examples of using resource producers to map alternative
> > managed thread factories to CDI injection (as we normally do for
> > @Resource)
> >
> > With these changes, I think this will be a really excellent set of
> > services for Java EE, and fill a big gap in the programming model
> > for users.
> >
> > It would also be interesting to explore the relationship between CDI events and JSR-236 in the future.
> >
> > I really like the spec overall, particularly as it's really focused
> > on not reinventing the wheel, but on trying to stick to existing
> > designs as close as possible.
> >
> > Pete
> >
> > On 24 Jan 2013, at 23:23, Linda DeMichiel wrote:
> >
> >>
> >> We are very pleased to see that the JSR-236 Expert Group has made
> >> excellent progress and JSR-236 is now in the JCP Public Review phase.
> >>
> >> At this point, we expect that JSR-236 will meet our target dates for
> >> inclusion into Java EE 7. JSR-236 is an obvious candidate for inclusion
> >> in the full Java EE Platform, and we believe that it should be.
> >>
> >> Pleases let us know:
> >>
> >> (1) Whether you see any reason that JSR 236 should not be included in
> >> the full platform?
> >>
> >> (2) Whether you think that JSR 236 should also be included in the Web Profile?
> >>
> >> thanks,
> >>
> >> -Linda
> >
>
>