You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "John D. Ament" <jo...@gmail.com> on 2013/10/13 21:29:05 UTC

CDI ContextControl - only available in SE mode?

Hey guys,

Just wanted to check with everyone.  Looking at the documentation
around context control, it seems a little puzzling and wanted to get
others opinions.

I don't need to be in SE mode to start a context manually, right?

The docs seem to imply this, but if I'm already in a CDI container
doing work, I should be able to inject ContextControl to my class and
start a new context right?  I'd need to look up the bean, e.g. through
BeanManager but it should work in theory, right?

If we agree it should work, I can update the docs to make it clearer,
as right now it looks like it should only work in SE mode.

Thanks,

John

Re: CDI ContextControl - only available in SE mode?

Posted by "John D. Ament" <jo...@gmail.com>.
Thanks guys.  My question is not really in tune with jsr 236, but I
was able to get it working.  I'll update the docs in the next day or
two on how to make it work in EE.

On Mon, Oct 14, 2013 at 4:34 AM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> @AppScope will work for sure but other scopes would need to be
> initialized/resetted. There isn't enough link between jsr 236 and cdi to
> suppose it but CDI tend to impose container to start request/session scopes
> if not already started so I think it can work out of the box, no?
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/10/14 Mark Struberg <st...@yahoo.de>
>
>> Hmm, I remember talking with Romain about this a few months ago and if I
>> remember correctly we had the conclusion that at least @ApplicationScoped
>> context and @RequestScoped context needs to be set up. But I'd be happy to
>> learn that this is not the case.
>> We could also redirect this question to the EE or EJB EG which seems to
>> have been in charge about the concurrency util integration into EE7.
>>
>>
>> In any case ContextControl should work :)
>>
>> LieGrue,
>> strub
>>
>>
>>
>> ----- Original Message -----
>> > From: Martin Kouba <mk...@redhat.com>
>> > To: dev@deltaspike.apache.org
>> > Cc:
>> > Sent: Monday, 14 October 2013, 10:00
>> > Subject: Re: CDI ContextControl - only available in SE mode?
>> >
>> > Dne 14.10.2013 09:22, Mark Struberg napsal(a):
>> >>  Hi John!
>> >>
>> >>  Yes, the ContextControl is also designed for being used in JavaEE.
>> This is
>> > very helpful if you need to manually for new threads which need CDI setup
>> > properly in JavaEE6 or a pure Servlet container based environment.
>> >>
>> >>  In JavaEE7 you should be able to utilize JSR-236 "concurrency utils
>> > for JavaEE" to create a 'Managed Thread' which has at least the
>> > @RequestScoped and @ApplicationScoped contexts set up properly.
>> >>  Still you can use the ContextControl to start a dummy @RequestScoped
>> > context even in this case.
>> >
>> > Mark, I think JSR-236 only comments on using CDI beans as tasks, it says
>> > nothing about CDI context propagation. WRT JSR-236 it seems the
>> > container must only support propagation of JNDI naming context,
>> > classloader, and security information. So I think request context is not
>> > set up properly. The application context should be ok. Maybe I'm missing
>> > something...
>> >
>> >
>> >>
>> >>
>> >>  There are of course a few restriction in jsr-236. You can read more
>> about
>> > it in section "2.3.2.1 Tasks and Contexts and Dependency Injection
>> > (CDI)". In that case ContextControl could be an easy way to work around
>> it.
>> >>
>> >>
>> >>  hth.
>> >>
>> >>  LieGrue,
>> >>  strub
>> >>
>> >>
>> >>
>> >>  ----- Original Message -----
>> >>>  From: John D. Ament <jo...@gmail.com>
>> >>>  To: dev@deltaspike.apache.org
>> >>>  Cc:
>> >>>  Sent: Monday, 14 October 2013, 0:59
>> >>>  Subject: Re: CDI ContextControl - only available in SE mode?
>> >>>
>> >>>  Interesting.  I guess my big curiosity is that it was "shipped in
>> > 0.4"
>> >>>  but it's not clear what was shipped.  Better handling if you're
>> > in EE
>> >>>  so that it doesn't crash?
>> >>>
>> >>>  Clearly yes, you shouldn't be able to boot weld if you're
>> > already in
>> >>>  EE, but I'm more interested in starting contexts.
>> >>>
>> >>>
>> >>>  On Sun, Oct 13, 2013 at 4:17 PM, Karl Kildén
>> > <ka...@gmail.com>
>> >>>  wrote:
>> >>>>   Hi. It works for OWB.
>> >>>>
>> >>>>   See: https://issues.apache.org/jira/browse/DELTASPIKE-284
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>>   On 13 October 2013 21:29, John D. Ament
>> > <jo...@gmail.com>
>> >>>  wrote:
>> >>>>
>> >>>>>   Hey guys,
>> >>>>>
>> >>>>>   Just wanted to check with everyone.  Looking at the
>> > documentation
>> >>>>>   around context control, it seems a little puzzling and wanted
>> > to get
>> >>>>>   others opinions.
>> >>>>>
>> >>>>>   I don't need to be in SE mode to start a context manually,
>> > right?
>> >>>>>
>> >>>>>   The docs seem to imply this, but if I'm already in a CDI
>> > container
>> >>>>>   doing work, I should be able to inject ContextControl to my
>> > class and
>> >>>>>   start a new context right?  I'd need to look up the bean,
>> > e.g.
>> >>>  through
>> >>>>>   BeanManager but it should work in theory, right?
>> >>>>>
>> >>>>>   If we agree it should work, I can update the docs to make it
>> > clearer,
>> >>>>>   as right now it looks like it should only work in SE mode.
>> >>>>>
>> >>>>>   Thanks,
>> >>>>>
>> >>>>>   John
>> >>>>>
>> >>>
>> >
>>

Re: CDI ContextControl - only available in SE mode?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
@AppScope will work for sure but other scopes would need to be
initialized/resetted. There isn't enough link between jsr 236 and cdi to
suppose it but CDI tend to impose container to start request/session scopes
if not already started so I think it can work out of the box, no?

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/10/14 Mark Struberg <st...@yahoo.de>

> Hmm, I remember talking with Romain about this a few months ago and if I
> remember correctly we had the conclusion that at least @ApplicationScoped
> context and @RequestScoped context needs to be set up. But I'd be happy to
> learn that this is not the case.
> We could also redirect this question to the EE or EJB EG which seems to
> have been in charge about the concurrency util integration into EE7.
>
>
> In any case ContextControl should work :)
>
> LieGrue,
> strub
>
>
>
> ----- Original Message -----
> > From: Martin Kouba <mk...@redhat.com>
> > To: dev@deltaspike.apache.org
> > Cc:
> > Sent: Monday, 14 October 2013, 10:00
> > Subject: Re: CDI ContextControl - only available in SE mode?
> >
> > Dne 14.10.2013 09:22, Mark Struberg napsal(a):
> >>  Hi John!
> >>
> >>  Yes, the ContextControl is also designed for being used in JavaEE.
> This is
> > very helpful if you need to manually for new threads which need CDI setup
> > properly in JavaEE6 or a pure Servlet container based environment.
> >>
> >>  In JavaEE7 you should be able to utilize JSR-236 "concurrency utils
> > for JavaEE" to create a 'Managed Thread' which has at least the
> > @RequestScoped and @ApplicationScoped contexts set up properly.
> >>  Still you can use the ContextControl to start a dummy @RequestScoped
> > context even in this case.
> >
> > Mark, I think JSR-236 only comments on using CDI beans as tasks, it says
> > nothing about CDI context propagation. WRT JSR-236 it seems the
> > container must only support propagation of JNDI naming context,
> > classloader, and security information. So I think request context is not
> > set up properly. The application context should be ok. Maybe I'm missing
> > something...
> >
> >
> >>
> >>
> >>  There are of course a few restriction in jsr-236. You can read more
> about
> > it in section "2.3.2.1 Tasks and Contexts and Dependency Injection
> > (CDI)". In that case ContextControl could be an easy way to work around
> it.
> >>
> >>
> >>  hth.
> >>
> >>  LieGrue,
> >>  strub
> >>
> >>
> >>
> >>  ----- Original Message -----
> >>>  From: John D. Ament <jo...@gmail.com>
> >>>  To: dev@deltaspike.apache.org
> >>>  Cc:
> >>>  Sent: Monday, 14 October 2013, 0:59
> >>>  Subject: Re: CDI ContextControl - only available in SE mode?
> >>>
> >>>  Interesting.  I guess my big curiosity is that it was "shipped in
> > 0.4"
> >>>  but it's not clear what was shipped.  Better handling if you're
> > in EE
> >>>  so that it doesn't crash?
> >>>
> >>>  Clearly yes, you shouldn't be able to boot weld if you're
> > already in
> >>>  EE, but I'm more interested in starting contexts.
> >>>
> >>>
> >>>  On Sun, Oct 13, 2013 at 4:17 PM, Karl Kildén
> > <ka...@gmail.com>
> >>>  wrote:
> >>>>   Hi. It works for OWB.
> >>>>
> >>>>   See: https://issues.apache.org/jira/browse/DELTASPIKE-284
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>   On 13 October 2013 21:29, John D. Ament
> > <jo...@gmail.com>
> >>>  wrote:
> >>>>
> >>>>>   Hey guys,
> >>>>>
> >>>>>   Just wanted to check with everyone.  Looking at the
> > documentation
> >>>>>   around context control, it seems a little puzzling and wanted
> > to get
> >>>>>   others opinions.
> >>>>>
> >>>>>   I don't need to be in SE mode to start a context manually,
> > right?
> >>>>>
> >>>>>   The docs seem to imply this, but if I'm already in a CDI
> > container
> >>>>>   doing work, I should be able to inject ContextControl to my
> > class and
> >>>>>   start a new context right?  I'd need to look up the bean,
> > e.g.
> >>>  through
> >>>>>   BeanManager but it should work in theory, right?
> >>>>>
> >>>>>   If we agree it should work, I can update the docs to make it
> > clearer,
> >>>>>   as right now it looks like it should only work in SE mode.
> >>>>>
> >>>>>   Thanks,
> >>>>>
> >>>>>   John
> >>>>>
> >>>
> >
>

Re: CDI ContextControl - only available in SE mode?

Posted by Mark Struberg <st...@yahoo.de>.
Hmm, I remember talking with Romain about this a few months ago and if I remember correctly we had the conclusion that at least @ApplicationScoped context and @RequestScoped context needs to be set up. But I'd be happy to learn that this is not the case. 
We could also redirect this question to the EE or EJB EG which seems to have been in charge about the concurrency util integration into EE7.


In any case ContextControl should work :)

LieGrue,
strub



----- Original Message -----
> From: Martin Kouba <mk...@redhat.com>
> To: dev@deltaspike.apache.org
> Cc: 
> Sent: Monday, 14 October 2013, 10:00
> Subject: Re: CDI ContextControl - only available in SE mode?
> 
> Dne 14.10.2013 09:22, Mark Struberg napsal(a):
>>  Hi John!
>> 
>>  Yes, the ContextControl is also designed for being used in JavaEE. This is 
> very helpful if you need to manually for new threads which need CDI setup 
> properly in JavaEE6 or a pure Servlet container based environment.
>> 
>>  In JavaEE7 you should be able to utilize JSR-236 "concurrency utils 
> for JavaEE" to create a 'Managed Thread' which has at least the 
> @RequestScoped and @ApplicationScoped contexts set up properly.
>>  Still you can use the ContextControl to start a dummy @RequestScoped 
> context even in this case.
> 
> Mark, I think JSR-236 only comments on using CDI beans as tasks, it says
> nothing about CDI context propagation. WRT JSR-236 it seems the
> container must only support propagation of JNDI naming context,
> classloader, and security information. So I think request context is not
> set up properly. The application context should be ok. Maybe I'm missing
> something...
> 
> 
>> 
>> 
>>  There are of course a few restriction in jsr-236. You can read more about 
> it in section "2.3.2.1 Tasks and Contexts and Dependency Injection 
> (CDI)". In that case ContextControl could be an easy way to work around it.
>> 
>> 
>>  hth.
>> 
>>  LieGrue,
>>  strub
>> 
>> 
>> 
>>  ----- Original Message -----
>>>  From: John D. Ament <jo...@gmail.com>
>>>  To: dev@deltaspike.apache.org
>>>  Cc: 
>>>  Sent: Monday, 14 October 2013, 0:59
>>>  Subject: Re: CDI ContextControl - only available in SE mode?
>>> 
>>>  Interesting.  I guess my big curiosity is that it was "shipped in 
> 0.4"
>>>  but it's not clear what was shipped.  Better handling if you're 
> in EE
>>>  so that it doesn't crash?
>>> 
>>>  Clearly yes, you shouldn't be able to boot weld if you're 
> already in
>>>  EE, but I'm more interested in starting contexts.
>>> 
>>> 
>>>  On Sun, Oct 13, 2013 at 4:17 PM, Karl Kildén 
> <ka...@gmail.com> 
>>>  wrote:
>>>>   Hi. It works for OWB.
>>>> 
>>>>   See: https://issues.apache.org/jira/browse/DELTASPIKE-284
>>>> 
>>>> 
>>>> 
>>>> 
>>>>   On 13 October 2013 21:29, John D. Ament 
> <jo...@gmail.com> 
>>>  wrote:
>>>> 
>>>>>   Hey guys,
>>>>> 
>>>>>   Just wanted to check with everyone.  Looking at the 
> documentation
>>>>>   around context control, it seems a little puzzling and wanted 
> to get
>>>>>   others opinions.
>>>>> 
>>>>>   I don't need to be in SE mode to start a context manually, 
> right?
>>>>> 
>>>>>   The docs seem to imply this, but if I'm already in a CDI 
> container
>>>>>   doing work, I should be able to inject ContextControl to my 
> class and
>>>>>   start a new context right?  I'd need to look up the bean, 
> e.g. 
>>>  through
>>>>>   BeanManager but it should work in theory, right?
>>>>> 
>>>>>   If we agree it should work, I can update the docs to make it 
> clearer,
>>>>>   as right now it looks like it should only work in SE mode.
>>>>> 
>>>>>   Thanks,
>>>>> 
>>>>>   John
>>>>> 
>>> 
> 

Re: CDI ContextControl - only available in SE mode?

Posted by Martin Kouba <mk...@redhat.com>.
Dne 14.10.2013 09:22, Mark Struberg napsal(a):
> Hi John!
> 
> Yes, the ContextControl is also designed for being used in JavaEE. This is very helpful if you need to manually for new threads which need CDI setup properly in JavaEE6 or a pure Servlet container based environment.
> 
> In JavaEE7 you should be able to utilize JSR-236 "concurrency utils for JavaEE" to create a 'Managed Thread' which has at least the @RequestScoped and @ApplicationScoped contexts set up properly.
> Still you can use the ContextControl to start a dummy @RequestScoped context even in this case.

Mark, I think JSR-236 only comments on using CDI beans as tasks, it says
nothing about CDI context propagation. WRT JSR-236 it seems the
container must only support propagation of JNDI naming context,
classloader, and security information. So I think request context is not
set up properly. The application context should be ok. Maybe I'm missing
something...

> 
> 
> There are of course a few restriction in jsr-236. You can read more about it in section "2.3.2.1 Tasks and Contexts and Dependency Injection (CDI)". In that case ContextControl could be an easy way to work around it.
> 
> 
> hth.
> 
> LieGrue,
> strub
> 
> 
> 
> ----- Original Message -----
>> From: John D. Ament <jo...@gmail.com>
>> To: dev@deltaspike.apache.org
>> Cc: 
>> Sent: Monday, 14 October 2013, 0:59
>> Subject: Re: CDI ContextControl - only available in SE mode?
>>
>> Interesting.  I guess my big curiosity is that it was "shipped in 0.4"
>> but it's not clear what was shipped.  Better handling if you're in EE
>> so that it doesn't crash?
>>
>> Clearly yes, you shouldn't be able to boot weld if you're already in
>> EE, but I'm more interested in starting contexts.
>>
>>
>> On Sun, Oct 13, 2013 at 4:17 PM, Karl Kildén <ka...@gmail.com> 
>> wrote:
>>>  Hi. It works for OWB.
>>>
>>>  See: https://issues.apache.org/jira/browse/DELTASPIKE-284
>>>
>>>
>>>
>>>
>>>  On 13 October 2013 21:29, John D. Ament <jo...@gmail.com> 
>> wrote:
>>>
>>>>  Hey guys,
>>>>
>>>>  Just wanted to check with everyone.  Looking at the documentation
>>>>  around context control, it seems a little puzzling and wanted to get
>>>>  others opinions.
>>>>
>>>>  I don't need to be in SE mode to start a context manually, right?
>>>>
>>>>  The docs seem to imply this, but if I'm already in a CDI container
>>>>  doing work, I should be able to inject ContextControl to my class and
>>>>  start a new context right?  I'd need to look up the bean, e.g. 
>> through
>>>>  BeanManager but it should work in theory, right?
>>>>
>>>>  If we agree it should work, I can update the docs to make it clearer,
>>>>  as right now it looks like it should only work in SE mode.
>>>>
>>>>  Thanks,
>>>>
>>>>  John
>>>>
>>

Re: CDI ContextControl - only available in SE mode?

Posted by Mark Struberg <st...@yahoo.de>.
Hi John!

Yes, the ContextControl is also designed for being used in JavaEE. This is very helpful if you need to manually for new threads which need CDI setup properly in JavaEE6 or a pure Servlet container based environment.

In JavaEE7 you should be able to utilize JSR-236 "concurrency utils for JavaEE" to create a 'Managed Thread' which has at least the @RequestScoped and @ApplicationScoped contexts set up properly.
Still you can use the ContextControl to start a dummy @RequestScoped context even in this case.


There are of course a few restriction in jsr-236. You can read more about it in section "2.3.2.1 Tasks and Contexts and Dependency Injection (CDI)". In that case ContextControl could be an easy way to work around it.


hth.

LieGrue,
strub



----- Original Message -----
> From: John D. Ament <jo...@gmail.com>
> To: dev@deltaspike.apache.org
> Cc: 
> Sent: Monday, 14 October 2013, 0:59
> Subject: Re: CDI ContextControl - only available in SE mode?
> 
> Interesting.  I guess my big curiosity is that it was "shipped in 0.4"
> but it's not clear what was shipped.  Better handling if you're in EE
> so that it doesn't crash?
> 
> Clearly yes, you shouldn't be able to boot weld if you're already in
> EE, but I'm more interested in starting contexts.
> 
> 
> On Sun, Oct 13, 2013 at 4:17 PM, Karl Kildén <ka...@gmail.com> 
> wrote:
>>  Hi. It works for OWB.
>> 
>>  See: https://issues.apache.org/jira/browse/DELTASPIKE-284
>> 
>> 
>> 
>> 
>>  On 13 October 2013 21:29, John D. Ament <jo...@gmail.com> 
> wrote:
>> 
>>>  Hey guys,
>>> 
>>>  Just wanted to check with everyone.  Looking at the documentation
>>>  around context control, it seems a little puzzling and wanted to get
>>>  others opinions.
>>> 
>>>  I don't need to be in SE mode to start a context manually, right?
>>> 
>>>  The docs seem to imply this, but if I'm already in a CDI container
>>>  doing work, I should be able to inject ContextControl to my class and
>>>  start a new context right?  I'd need to look up the bean, e.g. 
> through
>>>  BeanManager but it should work in theory, right?
>>> 
>>>  If we agree it should work, I can update the docs to make it clearer,
>>>  as right now it looks like it should only work in SE mode.
>>> 
>>>  Thanks,
>>> 
>>>  John
>>> 
> 

Re: CDI ContextControl - only available in SE mode?

Posted by "John D. Ament" <jo...@gmail.com>.
Interesting.  I guess my big curiosity is that it was "shipped in 0.4"
but it's not clear what was shipped.  Better handling if you're in EE
so that it doesn't crash?

Clearly yes, you shouldn't be able to boot weld if you're already in
EE, but I'm more interested in starting contexts.

On Sun, Oct 13, 2013 at 4:17 PM, Karl Kildén <ka...@gmail.com> wrote:
> Hi. It works for OWB.
>
> See: https://issues.apache.org/jira/browse/DELTASPIKE-284
>
>
>
>
> On 13 October 2013 21:29, John D. Ament <jo...@gmail.com> wrote:
>
>> Hey guys,
>>
>> Just wanted to check with everyone.  Looking at the documentation
>> around context control, it seems a little puzzling and wanted to get
>> others opinions.
>>
>> I don't need to be in SE mode to start a context manually, right?
>>
>> The docs seem to imply this, but if I'm already in a CDI container
>> doing work, I should be able to inject ContextControl to my class and
>> start a new context right?  I'd need to look up the bean, e.g. through
>> BeanManager but it should work in theory, right?
>>
>> If we agree it should work, I can update the docs to make it clearer,
>> as right now it looks like it should only work in SE mode.
>>
>> Thanks,
>>
>> John
>>

Re: CDI ContextControl - only available in SE mode?

Posted by Karl Kildén <ka...@gmail.com>.
Hi. It works for OWB.

See: https://issues.apache.org/jira/browse/DELTASPIKE-284




On 13 October 2013 21:29, John D. Ament <jo...@gmail.com> wrote:

> Hey guys,
>
> Just wanted to check with everyone.  Looking at the documentation
> around context control, it seems a little puzzling and wanted to get
> others opinions.
>
> I don't need to be in SE mode to start a context manually, right?
>
> The docs seem to imply this, but if I'm already in a CDI container
> doing work, I should be able to inject ContextControl to my class and
> start a new context right?  I'd need to look up the bean, e.g. through
> BeanManager but it should work in theory, right?
>
> If we agree it should work, I can update the docs to make it clearer,
> as right now it looks like it should only work in SE mode.
>
> Thanks,
>
> John
>