You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Caroline Van den Hauwe <ca...@gmail.com> on 2013/04/21 18:43:50 UTC
Question regarding CDI: Injection needed in at runtime created
objects.
Hi,
Although I am using TomEE, my question this time is about CDI as I am not having any issues with TomEE. My sincerest apologies for those who dislike my posting this question here. My eternal gratitude for those who want to help me.
My Java EE app acts as a server to clients. When a client makes a certain request to the server, I want to make a Configuration object. This Configuration object should Inject 3 objects, based on XML data I received from the client. Additionally, I'm keeping Configuration objects in a HashMap.
The problem is, CDI only wants to do Injection in a Managed Bean, a.k.a. I would have to Inject this Configuration object and not create it through 'new Configuration()'.
How then, can I create a Configuration object whenever a client makes the certain request?
How then, can I pass the information in the XML my client sent me, to the Configuration object?
I have posted this question, phrased differently, including simplified code to Stack Overflow as well:
http://stackoverflow.com/questions/16114343/pass-runtime-arguments-to-object-containing-injections
Kind regards,
Caroline
Re: Question regarding CDI: Injection needed in at runtime created objects.
Posted by "John D. Ament" <jo...@gmail.com>.
Hi Caroline,
You may want to consider pinging questions like this on the cdi-dev list
from jboss.org or even posting the question on the CDI forums there.
Though I think SO may be the best for questions like this.
John
On Sun, Apr 21, 2013 at 12:43 PM, Caroline Van den Hauwe <
caroline.van.den.hauwe@gmail.com> wrote:
> Hi,
>
> Although I am using TomEE, my question this time is about CDI as I am not
> having any issues with TomEE. My sincerest apologies for those who dislike
> my posting this question here. My eternal gratitude for those who want to
> help me.
>
>
> My Java EE app acts as a server to clients. When a client makes a certain
> request to the server, I want to make a Configuration object. This
> Configuration object should Inject 3 objects, based on XML data I received
> from the client. Additionally, I'm keeping Configuration objects in a
> HashMap.
>
> The problem is, CDI only wants to do Injection in a Managed Bean, a.k.a. I
> would have to Inject this Configuration object and not create it through
> 'new Configuration()'.
>
> How then, can I create a Configuration object whenever a client makes the
> certain request?
> How then, can I pass the information in the XML my client sent me, to the
> Configuration object?
>
>
> I have posted this question, phrased differently, including simplified
> code to Stack Overflow as well:
>
> http://stackoverflow.com/questions/16114343/pass-runtime-arguments-to-object-containing-injections
>
>
> Kind regards,
>
> Caroline
>
>
Re: Question regarding CDI: Injection needed in at runtime created objects.
Posted by Mark Struberg <st...@yahoo.de>.
Hi!
You should be able to simply use @Inject in your @WebService.
If you need the parsed stuff elsewhere, then just create a producer method for it.
LieGrue,
strub
----- Original Message -----
> From: Caroline Van den Hauwe <ca...@gmail.com>
> To: users@tomee.apache.org
> Cc:
> Sent: Sunday, 21 April 2013, 18:43
> Subject: Question regarding CDI: Injection needed in at runtime created objects.
>
> Hi,
>
> Although I am using TomEE, my question this time is about CDI as I am not having
> any issues with TomEE. My sincerest apologies for those who dislike my posting
> this question here. My eternal gratitude for those who want to help me.
>
>
> My Java EE app acts as a server to clients. When a client makes a certain
> request to the server, I want to make a Configuration object. This Configuration
> object should Inject 3 objects, based on XML data I received from the client.
> Additionally, I'm keeping Configuration objects in a HashMap.
>
> The problem is, CDI only wants to do Injection in a Managed Bean, a.k.a. I would
> have to Inject this Configuration object and not create it through 'new
> Configuration()'.
>
> How then, can I create a Configuration object whenever a client makes the
> certain request?
> How then, can I pass the information in the XML my client sent me, to the
> Configuration object?
>
>
> I have posted this question, phrased differently, including simplified code to
> Stack Overflow as well:
> http://stackoverflow.com/questions/16114343/pass-runtime-arguments-to-object-containing-injections
>
>
> Kind regards,
>
> Caroline
>
Re: Question regarding CDI: Injection needed in at runtime created objects.
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Isnt a threadlocal what you need? Or a @New in a requestscoped wrapper
Le 21 avr. 2013 18:44, "Caroline Van den Hauwe" <
caroline.van.den.hauwe@gmail.com> a écrit :
> Hi,
>
> Although I am using TomEE, my question this time is about CDI as I am not
> having any issues with TomEE. My sincerest apologies for those who dislike
> my posting this question here. My eternal gratitude for those who want to
> help me.
>
>
> My Java EE app acts as a server to clients. When a client makes a certain
> request to the server, I want to make a Configuration object. This
> Configuration object should Inject 3 objects, based on XML data I received
> from the client. Additionally, I'm keeping Configuration objects in a
> HashMap.
>
> The problem is, CDI only wants to do Injection in a Managed Bean, a.k.a. I
> would have to Inject this Configuration object and not create it through
> 'new Configuration()'.
>
> How then, can I create a Configuration object whenever a client makes the
> certain request?
> How then, can I pass the information in the XML my client sent me, to the
> Configuration object?
>
>
> I have posted this question, phrased differently, including simplified
> code to Stack Overflow as well:
>
> http://stackoverflow.com/questions/16114343/pass-runtime-arguments-to-object-containing-injections
>
>
> Kind regards,
>
> Caroline
>
>