You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by Mark Struberg <st...@yahoo.de> on 2009/01/27 11:35:02 UTC

level of resource injection

Gurkan,
another question about resources: where should I actually inject the resources finally?

This is the stack trace so far:

InjectionResolver.implResolveByType(Class<?>, Type[], Annotation...) line: 94	
InjectableField(AbstractInjectable).inject(Class<T>, Type[], Annotation...) line: 83	
InjectableField.doInjection() line: 92	


My thoughts: 
Resources can be handled in a very high layer, since the 'accessors' already hide all the underlying complexity of having classloader hierarchies etc, isn't?

So in the 
AbstractInjectable#inject
I'd like to add something like:

            if (isResource(annotations))
            {
                return injectResource(type, annotations);
            }

LieGrü,
strub


      

Re: level of resource injection

Posted by Gurkan Erdogdu <gu...@yahoo.com>.
Hi Mark, I have committed your changes. 

Thanks;

/Gurkan




________________________________
From: Mark Struberg <st...@yahoo.de>
To: openwebbeans-dev@incubator.apache.org
Sent: Wednesday, January 28, 2009 3:36:06 PM
Subject: Re: level of resource injection

it's done.

please review the patch in 
https://issues.apache.org/jira/browse/OWB-71

Regarding JPAUtil#getPersistenceUnit

I'm in favour to implement those functions for the basic systems directly in our code for now and think about what to implement via an SPI later in a 2nd round. This will give us more time to learn what we really need first.

LieGrue,
strub


--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Di, 27.1.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Dienstag, 27. Januar 2009, 15:55
> Ok, Mark.
> 

> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: openwebbeans-dev@incubator.apache.org
> Sent: Tuesday, January 27, 2009 4:04:26 PM
> Subject: Re: level of resource injection
> 
> Hi Gurkan!
> 
> Thanks for the tips!
> 
> Currently I'm only looking at the injection of
> resources which do not need any XML. So I started with
> implementing @PersistenceUnit and looking forward to wrap
> all the necessary PersistenceManagerFactory stuff in
> JPAUtil.java (currently empty, but I think that's what
> you've intended it for, isn't it?).
> 
> I'll post a patch for review in the afternoon
> (hopefully) and commit it after you've checked it.
> 
> @PersistenceContext will be a bit trickier, since it is not
> thread save and we have to do kind of 'scoping'
> ourself.
> 
> The @CustomerDataservice with the whole XML stuff will be
> the next step after we've solved this problem.
> 
> 
> LieGrue,
> strub
> 
> 
> --- Gurkan Erdogdu <gu...@yahoo.com> schrieb
> am Di, 27.1.2009:
> 
> > Von: Gurkan Erdogdu <gu...@yahoo.com>
> > Betreff: Re: level of resource injection
> > An: openwebbeans-dev@incubator.apache.org
> > Datum: Dienstag, 27. Januar 2009, 12:47
> > Hi Mark;
> > 
> > Do you try to implement resource injections via XML
> > definitions, right? Below sketch is the summary of how
> you
> > can proceed with the current implementation.
> > 
> > For XML defined webbeans, the main entry point is the
> > *WebBeansXMLConfigurator* class. Java EE Resources are
> only
> > defined in the xml file, according to the *9.5.2
> Type-Level
> > metadata for a bean*. This part is handled in the
> > *WebBeansXMLConfigurator#configureTypeLevelMetaData*
> method.
> > 
> > 
> > For injectable resources, you can create another class
> like
> > *XMLResourceInjectableField* in the *inject/xml*
> package and
> > add the *Map<Field,XMLInjectionPointModel> 
> > injectedResources* instance variable into the
> > *XMLComponentImpl.java* to hold the injectable
> resource
> > fields.
> > 
> > After that you will have to add the resource injection
> > fields that are declared in the XML into the resource
> > injection map in the *XMLComponentImpl* class. You can
> > create another method for this in the
> > *WebBeansXMLConfigurator* class, for example
> > *configureInjectableResources()*, and call this method
> from
> > *configureTypeLevelMetaData()* method.
> > 
> > Skeletons of the codes may like the followings;
> > 
> > WebBeansXMLConfigurator.java
> > ----------------------------------------------
> > ........
> > 
> > //Update this method
> >  public <T> void configureTypeLevelMetaData()
> > {
> >    //Add this method call
> >    configureInjectableResources(); 
> > 
> > }
> > //This is the new method that is responsible for
> adding
> > resource injection fields to the component
> > public <T> void configureInjectableResources()
> > {
> >     //Find fields from resource decleration in XML
> >     //Create XMLInjectionPointModel for each field
> >     //Add field and related model into the
> >
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> > }
> > 
> > XMLComponentImpl.java
> > ---------------------------------
> > After that in XMLComponentImpl class, update
> injectFields
> > method to inject resources,
> >    
> > //Update this method for adding resource injection
> support
> > 
> >  protected void injectFields(T instance)
> > {
> >    ......
> >    //For each resource injection map entry  
> >    //Create new *XMLResourceInjectableField* instance
> >    //Set field with calling the
> > AbstractInjectable#inject(....)
> > }
> > AbstractInjectable class
> > ---------------------------------
> > public Object inject()
> > {
> >     //If resource, create injection object with method
> > injectResource
> >     if (isResource(annotations))
> >             {
> >                 return injectResource(type,
> annotations);
> >             }
> > }
> > 
> > WDYT?
> > 
> > /Gurkan
> > 
> > 
> > 
> > ________________________________
> > From: Mark Struberg <st...@yahoo.de>
> > To: openwebbeans-dev@incubator.apache.org
> > Sent: Tuesday, January 27, 2009 12:35:02 PM
> > Subject: level of resource injection
> > 
> > Gurkan,
> > another question about resources: where should I
> actually
> > inject the resources finally?
> > 
> > This is the stack trace so far:
> > 
> > InjectionResolver.implResolveByType(Class<?>,
> Type[],
> > Annotation...) line: 94    
> >
> InjectableField(AbstractInjectable).inject(Class<T>,
> > Type[], Annotation...) line: 83    
> > InjectableField.doInjection() line: 92    
> > 
> > 
> > My thoughts: 
> > Resources can be handled in a very high layer, since
> the
> > 'accessors' already hide all the underlying
> > complexity of having classloader hierarchies etc,
> isn't?
> > 
> > So in the 
> > AbstractInjectable#inject
> > I'd like to add something like:
> > 
> >             if (isResource(annotations))
> >             {
> >                 return injectResource(type,
> annotations);
> >             }
> > 
> > LieGrü,
> > strub


      

Re: level of resource injection

Posted by Mark Struberg <st...@yahoo.de>.
Yup, they should have been in the patch.
Wait I'll commit them now, just pull your changes.

LieGrue,
strub


--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Mi, 28.1.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Mittwoch, 28. Januar 2009, 21:21
> Mark, did you write test cases  for this?
> 
> Thanks;
> 
> /Gurkan
> 
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: openwebbeans-dev@incubator.apache.org
> Sent: Wednesday, January 28, 2009 3:36:06 PM
> Subject: Re: level of resource injection
> 
> it's done.
> 
> please review the patch in 
> https://issues.apache.org/jira/browse/OWB-71
> 
> Regarding JPAUtil#getPersistenceUnit
> 
> I'm in favour to implement those functions for the
> basic systems directly in our code for now and think about
> what to implement via an SPI later in a 2nd round. This will
> give us more time to learn what we really need first.
> 
> LieGrue,
> strub
> 
> 
> --- Gurkan Erdogdu <gu...@yahoo.com> schrieb
> am Di, 27.1.2009:
> 
> > Von: Gurkan Erdogdu <gu...@yahoo.com>
> > Betreff: Re: level of resource injection
> > An: openwebbeans-dev@incubator.apache.org
> > Datum: Dienstag, 27. Januar 2009, 15:55
> > Ok, Mark.
> > 
> 
> > ________________________________
> > From: Mark Struberg <st...@yahoo.de>
> > To: openwebbeans-dev@incubator.apache.org
> > Sent: Tuesday, January 27, 2009 4:04:26 PM
> > Subject: Re: level of resource injection
> > 
> > Hi Gurkan!
> > 
> > Thanks for the tips!
> > 
> > Currently I'm only looking at the injection of
> > resources which do not need any XML. So I started with
> > implementing @PersistenceUnit and looking forward to
> wrap
> > all the necessary PersistenceManagerFactory stuff in
> > JPAUtil.java (currently empty, but I think that's
> what
> > you've intended it for, isn't it?).
> > 
> > I'll post a patch for review in the afternoon
> > (hopefully) and commit it after you've checked it.
> > 
> > @PersistenceContext will be a bit trickier, since it
> is not
> > thread save and we have to do kind of
> 'scoping'
> > ourself.
> > 
> > The @CustomerDataservice with the whole XML stuff will
> be
> > the next step after we've solved this problem.
> > 
> > 
> > LieGrue,
> > strub
> > 
> > 
> > --- Gurkan Erdogdu <gu...@yahoo.com>
> schrieb
> > am Di, 27.1.2009:
> > 
> > > Von: Gurkan Erdogdu
> <gu...@yahoo.com>
> > > Betreff: Re: level of resource injection
> > > An: openwebbeans-dev@incubator.apache.org
> > > Datum: Dienstag, 27. Januar 2009, 12:47
> > > Hi Mark;
> > > 
> > > Do you try to implement resource injections via
> XML
> > > definitions, right? Below sketch is the summary
> of how
> > you
> > > can proceed with the current implementation.
> > > 
> > > For XML defined webbeans, the main entry point is
> the
> > > *WebBeansXMLConfigurator* class. Java EE
> Resources are
> > only
> > > defined in the xml file, according to the *9.5.2
> > Type-Level
> > > metadata for a bean*. This part is handled in the
> > >
> *WebBeansXMLConfigurator#configureTypeLevelMetaData*
> > method.
> > > 
> > > 
> > > For injectable resources, you can create another
> class
> > like
> > > *XMLResourceInjectableField* in the *inject/xml*
> > package and
> > > add the *Map<Field,XMLInjectionPointModel> 
> > > injectedResources* instance variable into the
> > > *XMLComponentImpl.java* to hold the injectable
> > resource
> > > fields.
> > > 
> > > After that you will have to add the resource
> injection
> > > fields that are declared in the XML into the
> resource
> > > injection map in the *XMLComponentImpl* class.
> You can
> > > create another method for this in the
> > > *WebBeansXMLConfigurator* class, for example
> > > *configureInjectableResources()*, and call this
> method
> > from
> > > *configureTypeLevelMetaData()* method.
> > > 
> > > Skeletons of the codes may like the followings;
> > > 
> > > WebBeansXMLConfigurator.java
> > > ----------------------------------------------
> > > ........
> > > 
> > > //Update this method
> > >  public <T> void
> configureTypeLevelMetaData()
> > > {
> > >    //Add this method call
> > >    configureInjectableResources(); 
> > > 
> > > }
> > > //This is the new method that is responsible for
> > adding
> > > resource injection fields to the component
> > > public <T> void
> configureInjectableResources()
> > > {
> > >     //Find fields from resource decleration in
> XML
> > >     //Create XMLInjectionPointModel for each
> field
> > >     //Add field and related model into the
> > >
> >
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> > > }
> > > 
> > > XMLComponentImpl.java
> > > ---------------------------------
> > > After that in XMLComponentImpl class, update
> > injectFields
> > > method to inject resources,
> > >    
> > > //Update this method for adding resource
> injection
> > support
> > > 
> > >  protected void injectFields(T instance)
> > > {
> > >    ......
> > >    //For each resource injection map entry  
> > >    //Create new *XMLResourceInjectableField*
> instance
> > >    //Set field with calling the
> > > AbstractInjectable#inject(....)
> > > }
> > > AbstractInjectable class
> > > ---------------------------------
> > > public Object inject()
> > > {
> > >     //If resource, create injection object with
> method
> > > injectResource
> > >     if (isResource(annotations))
> > >             {
> > >                 return injectResource(type,
> > annotations);
> > >             }
> > > }
> > > 
> > > WDYT?
> > > 
> > > /Gurkan
> > > 
> > > 
> > > 
> > > ________________________________
> > > From: Mark Struberg <st...@yahoo.de>
> > > To: openwebbeans-dev@incubator.apache.org
> > > Sent: Tuesday, January 27, 2009 12:35:02 PM
> > > Subject: level of resource injection
> > > 
> > > Gurkan,
> > > another question about resources: where should I
> > actually
> > > inject the resources finally?
> > > 
> > > This is the stack trace so far:
> > > 
> > >
> InjectionResolver.implResolveByType(Class<?>,
> > Type[],
> > > Annotation...) line: 94    
> > >
> >
> InjectableField(AbstractInjectable).inject(Class<T>,
> > > Type[], Annotation...) line: 83    
> > > InjectableField.doInjection() line: 92    
> > > 
> > > 
> > > My thoughts: 
> > > Resources can be handled in a very high layer,
> since
> > the
> > > 'accessors' already hide all the
> underlying
> > > complexity of having classloader hierarchies etc,
> > isn't?
> > > 
> > > So in the 
> > > AbstractInjectable#inject
> > > I'd like to add something like:
> > > 
> > >             if (isResource(annotations))
> > >             {
> > >                 return injectResource(type,
> > annotations);
> > >             }
> > > 
> > > LieGrü,
> > > strub


      

Re: level of resource injection

Posted by Gurkan Erdogdu <gu...@yahoo.com>.
Mark, did you write test cases  for this?

Thanks;

/Gurkan




________________________________
From: Mark Struberg <st...@yahoo.de>
To: openwebbeans-dev@incubator.apache.org
Sent: Wednesday, January 28, 2009 3:36:06 PM
Subject: Re: level of resource injection

it's done.

please review the patch in 
https://issues.apache.org/jira/browse/OWB-71

Regarding JPAUtil#getPersistenceUnit

I'm in favour to implement those functions for the basic systems directly in our code for now and think about what to implement via an SPI later in a 2nd round. This will give us more time to learn what we really need first.

LieGrue,
strub


--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Di, 27.1.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Dienstag, 27. Januar 2009, 15:55
> Ok, Mark.
> 

> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: openwebbeans-dev@incubator.apache.org
> Sent: Tuesday, January 27, 2009 4:04:26 PM
> Subject: Re: level of resource injection
> 
> Hi Gurkan!
> 
> Thanks for the tips!
> 
> Currently I'm only looking at the injection of
> resources which do not need any XML. So I started with
> implementing @PersistenceUnit and looking forward to wrap
> all the necessary PersistenceManagerFactory stuff in
> JPAUtil.java (currently empty, but I think that's what
> you've intended it for, isn't it?).
> 
> I'll post a patch for review in the afternoon
> (hopefully) and commit it after you've checked it.
> 
> @PersistenceContext will be a bit trickier, since it is not
> thread save and we have to do kind of 'scoping'
> ourself.
> 
> The @CustomerDataservice with the whole XML stuff will be
> the next step after we've solved this problem.
> 
> 
> LieGrue,
> strub
> 
> 
> --- Gurkan Erdogdu <gu...@yahoo.com> schrieb
> am Di, 27.1.2009:
> 
> > Von: Gurkan Erdogdu <gu...@yahoo.com>
> > Betreff: Re: level of resource injection
> > An: openwebbeans-dev@incubator.apache.org
> > Datum: Dienstag, 27. Januar 2009, 12:47
> > Hi Mark;
> > 
> > Do you try to implement resource injections via XML
> > definitions, right? Below sketch is the summary of how
> you
> > can proceed with the current implementation.
> > 
> > For XML defined webbeans, the main entry point is the
> > *WebBeansXMLConfigurator* class. Java EE Resources are
> only
> > defined in the xml file, according to the *9.5.2
> Type-Level
> > metadata for a bean*. This part is handled in the
> > *WebBeansXMLConfigurator#configureTypeLevelMetaData*
> method.
> > 
> > 
> > For injectable resources, you can create another class
> like
> > *XMLResourceInjectableField* in the *inject/xml*
> package and
> > add the *Map<Field,XMLInjectionPointModel> 
> > injectedResources* instance variable into the
> > *XMLComponentImpl.java* to hold the injectable
> resource
> > fields.
> > 
> > After that you will have to add the resource injection
> > fields that are declared in the XML into the resource
> > injection map in the *XMLComponentImpl* class. You can
> > create another method for this in the
> > *WebBeansXMLConfigurator* class, for example
> > *configureInjectableResources()*, and call this method
> from
> > *configureTypeLevelMetaData()* method.
> > 
> > Skeletons of the codes may like the followings;
> > 
> > WebBeansXMLConfigurator.java
> > ----------------------------------------------
> > ........
> > 
> > //Update this method
> >  public <T> void configureTypeLevelMetaData()
> > {
> >    //Add this method call
> >    configureInjectableResources(); 
> > 
> > }
> > //This is the new method that is responsible for
> adding
> > resource injection fields to the component
> > public <T> void configureInjectableResources()
> > {
> >     //Find fields from resource decleration in XML
> >     //Create XMLInjectionPointModel for each field
> >     //Add field and related model into the
> >
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> > }
> > 
> > XMLComponentImpl.java
> > ---------------------------------
> > After that in XMLComponentImpl class, update
> injectFields
> > method to inject resources,
> >    
> > //Update this method for adding resource injection
> support
> > 
> >  protected void injectFields(T instance)
> > {
> >    ......
> >    //For each resource injection map entry  
> >    //Create new *XMLResourceInjectableField* instance
> >    //Set field with calling the
> > AbstractInjectable#inject(....)
> > }
> > AbstractInjectable class
> > ---------------------------------
> > public Object inject()
> > {
> >     //If resource, create injection object with method
> > injectResource
> >     if (isResource(annotations))
> >             {
> >                 return injectResource(type,
> annotations);
> >             }
> > }
> > 
> > WDYT?
> > 
> > /Gurkan
> > 
> > 
> > 
> > ________________________________
> > From: Mark Struberg <st...@yahoo.de>
> > To: openwebbeans-dev@incubator.apache.org
> > Sent: Tuesday, January 27, 2009 12:35:02 PM
> > Subject: level of resource injection
> > 
> > Gurkan,
> > another question about resources: where should I
> actually
> > inject the resources finally?
> > 
> > This is the stack trace so far:
> > 
> > InjectionResolver.implResolveByType(Class<?>,
> Type[],
> > Annotation...) line: 94    
> >
> InjectableField(AbstractInjectable).inject(Class<T>,
> > Type[], Annotation...) line: 83    
> > InjectableField.doInjection() line: 92    
> > 
> > 
> > My thoughts: 
> > Resources can be handled in a very high layer, since
> the
> > 'accessors' already hide all the underlying
> > complexity of having classloader hierarchies etc,
> isn't?
> > 
> > So in the 
> > AbstractInjectable#inject
> > I'd like to add something like:
> > 
> >             if (isResource(annotations))
> >             {
> >                 return injectResource(type,
> annotations);
> >             }
> > 
> > LieGrü,
> > strub


      

Re: level of resource injection

Posted by Gurkan Erdogdu <gu...@yahoo.com>.
I will look into detail about the Resource injection after M1-Release.

Thanks;

/Gurkan




________________________________
From: Mark Struberg <st...@yahoo.de>
To: openwebbeans-dev@incubator.apache.org
Sent: Wednesday, January 28, 2009 6:05:59 PM
Subject: Re: level of resource injection

Another thing:


> 3.10. Support for Common Annotations
> @PersistenceContext(type=EXTENDED)is not supported for simple beans.

But in an SE environment there are only extended EntityManagers available? What to do?

Otoh the Spec only says that the attribute type=EXTENDED is not supported, but it does not say that all injected EntityManagers has to be of type TRANSACTION ;)

LieGrue,
strub

--- Mark Struberg <st...@yahoo.de> schrieb am Mi, 28.1.2009:

> Von: Mark Struberg <st...@yahoo.de>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Mittwoch, 28. Januar 2009, 17:01
> I'm a bit confused:
> 
> Section 3.6 states that:
> > A resource always has scope @Dependent.
> 
> What does this mean for @PersistenceUnit?
> 
> Another open issue: if JNDI is involved, we have to take
> the EntityManagerFactory from there instead of getting it
> from the Persistence Factory.
> 
> What do you suggest for this scenario?
> 
> LieGrue,
> strub
> 
> --- Mark Struberg <st...@yahoo.de> schrieb am Mi,
> 28.1.2009:
> 
> > Von: Mark Struberg <st...@yahoo.de>
> > Betreff: Re: level of resource injection
> > An: openwebbeans-dev@incubator.apache.org
> > Datum: Mittwoch, 28. Januar 2009, 14:36
> > it's done.
> > 
> > please review the patch in 
> > https://issues.apache.org/jira/browse/OWB-71
> > 
> > Regarding JPAUtil#getPersistenceUnit
> > 
> > I'm in favour to implement those functions for the
> > basic systems directly in our code for now and think
> about
> > what to implement via an SPI later in a 2nd round.
> This will
> > give us more time to learn what we really need first.
> > 
> > LieGrue,
> > strub
> > 
> > 
> > --- Gurkan Erdogdu <gu...@yahoo.com>
> schrieb
> > am Di, 27.1.2009:
> > 
> > > Von: Gurkan Erdogdu
> <gu...@yahoo.com>
> > > Betreff: Re: level of resource injection
> > > An: openwebbeans-dev@incubator.apache.org
> > > Datum: Dienstag, 27. Januar 2009, 15:55
> > > Ok, Mark.
> > > 
> > 
> > > ________________________________
> > > From: Mark Struberg <st...@yahoo.de>
> > > To: openwebbeans-dev@incubator.apache.org
> > > Sent: Tuesday, January 27, 2009 4:04:26 PM
> > > Subject: Re: level of resource injection
> > > 
> > > Hi Gurkan!
> > > 
> > > Thanks for the tips!
> > > 
> > > Currently I'm only looking at the injection
> of
> > > resources which do not need any XML. So I started
> with
> > > implementing @PersistenceUnit and looking forward
> to
> > wrap
> > > all the necessary PersistenceManagerFactory stuff
> in
> > > JPAUtil.java (currently empty, but I think
> that's
> > what
> > > you've intended it for, isn't it?).
> > > 
> > > I'll post a patch for review in the afternoon
> > > (hopefully) and commit it after you've
> checked it.
> > > 
> > > @PersistenceContext will be a bit trickier, since
> it
> > is not
> > > thread save and we have to do kind of
> > 'scoping'
> > > ourself.
> > > 
> > > The @CustomerDataservice with the whole XML stuff
> will
> > be
> > > the next step after we've solved this
> problem.
> > > 
> > > 
> > > LieGrue,
> > > strub
> > > 
> > > 
> > > --- Gurkan Erdogdu
> <gu...@yahoo.com>
> > schrieb
> > > am Di, 27.1.2009:
> > > 
> > > > Von: Gurkan Erdogdu
> > <gu...@yahoo.com>
> > > > Betreff: Re: level of resource injection
> > > > An: openwebbeans-dev@incubator.apache.org
> > > > Datum: Dienstag, 27. Januar 2009, 12:47
> > > > Hi Mark;
> > > > 
> > > > Do you try to implement resource injections
> via
> > XML
> > > > definitions, right? Below sketch is the
> summary
> > of how
> > > you
> > > > can proceed with the current implementation.
> > > > 
> > > > For XML defined webbeans, the main entry
> point is
> > the
> > > > *WebBeansXMLConfigurator* class. Java EE
> > Resources are
> > > only
> > > > defined in the xml file, according to the
> *9.5.2
> > > Type-Level
> > > > metadata for a bean*. This part is handled
> in the
> > > >
> > *WebBeansXMLConfigurator#configureTypeLevelMetaData*
> > > method.
> > > > 
> > > > 
> > > > For injectable resources, you can create
> another
> > class
> > > like
> > > > *XMLResourceInjectableField* in the
> *inject/xml*
> > > package and
> > > > add the
> *Map<Field,XMLInjectionPointModel> 
> > > > injectedResources* instance variable into
> the
> > > > *XMLComponentImpl.java* to hold the
> injectable
> > > resource
> > > > fields.
> > > > 
> > > > After that you will have to add the resource
> > injection
> > > > fields that are declared in the XML into the
> > resource
> > > > injection map in the *XMLComponentImpl*
> class.
> > You can
> > > > create another method for this in the
> > > > *WebBeansXMLConfigurator* class, for example
> > > > *configureInjectableResources()*, and call
> this
> > method
> > > from
> > > > *configureTypeLevelMetaData()* method.
> > > > 
> > > > Skeletons of the codes may like the
> followings;
> > > > 
> > > > WebBeansXMLConfigurator.java
> > > >
> ----------------------------------------------
> > > > ........
> > > > 
> > > > //Update this method
> > > >  public <T> void
> > configureTypeLevelMetaData()
> > > > {
> > > >    //Add this method call
> > > >    configureInjectableResources(); 
> > > > 
> > > > }
> > > > //This is the new method that is responsible
> for
> > > adding
> > > > resource injection fields to the component
> > > > public <T> void
> > configureInjectableResources()
> > > > {
> > > >     //Find fields from resource decleration
> in
> > XML
> > > >     //Create XMLInjectionPointModel for each
> > field
> > > >     //Add field and related model into the
> > > >
> > >
> >
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> > > > }
> > > > 
> > > > XMLComponentImpl.java
> > > > ---------------------------------
> > > > After that in XMLComponentImpl class, update
> > > injectFields
> > > > method to inject resources,
> > > >    
> > > > //Update this method for adding resource
> > injection
> > > support
> > > > 
> > > >  protected void injectFields(T instance)
> > > > {
> > > >    ......
> > > >    //For each resource injection map entry  
> > > >    //Create new *XMLResourceInjectableField*
> > instance
> > > >    //Set field with calling the
> > > > AbstractInjectable#inject(....)
> > > > }
> > > > AbstractInjectable class
> > > > ---------------------------------
> > > > public Object inject()
> > > > {
> > > >     //If resource, create injection object
> with
> > method
> > > > injectResource
> > > >     if (isResource(annotations))
> > > >             {
> > > >                 return injectResource(type,
> > > annotations);
> > > >             }
> > > > }
> > > > 
> > > > WDYT?
> > > > 
> > > > /Gurkan
> > > > 
> > > > 
> > > > 
> > > > ________________________________
> > > > From: Mark Struberg
> <st...@yahoo.de>
> > > > To: openwebbeans-dev@incubator.apache.org
> > > > Sent: Tuesday, January 27, 2009 12:35:02 PM
> > > > Subject: level of resource injection
> > > > 
> > > > Gurkan,
> > > > another question about resources: where
> should I
> > > actually
> > > > inject the resources finally?
> > > > 
> > > > This is the stack trace so far:
> > > > 
> > > >
> > InjectionResolver.implResolveByType(Class<?>,
> > > Type[],
> > > > Annotation...) line: 94    
> > > >
> > >
> >
> InjectableField(AbstractInjectable).inject(Class<T>,
> > > > Type[], Annotation...) line: 83    
> > > > InjectableField.doInjection() line: 92    
> > > > 
> > > > 
> > > > My thoughts: 
> > > > Resources can be handled in a very high
> layer,
> > since
> > > the
> > > > 'accessors' already hide all the
> > underlying
> > > > complexity of having classloader hierarchies
> etc,
> > > isn't?
> > > > 
> > > > So in the 
> > > > AbstractInjectable#inject
> > > > I'd like to add something like:
> > > > 
> > > >             if (isResource(annotations))
> > > >             {
> > > >                 return injectResource(type,
> > > annotations);
> > > >             }
> > > > 
> > > > LieGrü,
> > > > strub


      

Re: level of resource injection

Posted by Mark Struberg <st...@yahoo.de>.
Another thing:


> 3.10. Support for Common Annotations
> @PersistenceContext(type=EXTENDED)is not supported for simple beans.

But in an SE environment there are only extended EntityManagers available? What to do?

Otoh the Spec only says that the attribute type=EXTENDED is not supported, but it does not say that all injected EntityManagers has to be of type TRANSACTION ;)

LieGrue,
strub

--- Mark Struberg <st...@yahoo.de> schrieb am Mi, 28.1.2009:

> Von: Mark Struberg <st...@yahoo.de>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Mittwoch, 28. Januar 2009, 17:01
> I'm a bit confused:
> 
> Section 3.6 states that:
> > A resource always has scope @Dependent.
> 
> What does this mean for @PersistenceUnit?
> 
> Another open issue: if JNDI is involved, we have to take
> the EntityManagerFactory from there instead of getting it
> from the Persistence Factory.
> 
> What do you suggest for this scenario?
> 
> LieGrue,
> strub
> 
> --- Mark Struberg <st...@yahoo.de> schrieb am Mi,
> 28.1.2009:
> 
> > Von: Mark Struberg <st...@yahoo.de>
> > Betreff: Re: level of resource injection
> > An: openwebbeans-dev@incubator.apache.org
> > Datum: Mittwoch, 28. Januar 2009, 14:36
> > it's done.
> > 
> > please review the patch in 
> > https://issues.apache.org/jira/browse/OWB-71
> > 
> > Regarding JPAUtil#getPersistenceUnit
> > 
> > I'm in favour to implement those functions for the
> > basic systems directly in our code for now and think
> about
> > what to implement via an SPI later in a 2nd round.
> This will
> > give us more time to learn what we really need first.
> > 
> > LieGrue,
> > strub
> > 
> > 
> > --- Gurkan Erdogdu <gu...@yahoo.com>
> schrieb
> > am Di, 27.1.2009:
> > 
> > > Von: Gurkan Erdogdu
> <gu...@yahoo.com>
> > > Betreff: Re: level of resource injection
> > > An: openwebbeans-dev@incubator.apache.org
> > > Datum: Dienstag, 27. Januar 2009, 15:55
> > > Ok, Mark.
> > > 
> > 
> > > ________________________________
> > > From: Mark Struberg <st...@yahoo.de>
> > > To: openwebbeans-dev@incubator.apache.org
> > > Sent: Tuesday, January 27, 2009 4:04:26 PM
> > > Subject: Re: level of resource injection
> > > 
> > > Hi Gurkan!
> > > 
> > > Thanks for the tips!
> > > 
> > > Currently I'm only looking at the injection
> of
> > > resources which do not need any XML. So I started
> with
> > > implementing @PersistenceUnit and looking forward
> to
> > wrap
> > > all the necessary PersistenceManagerFactory stuff
> in
> > > JPAUtil.java (currently empty, but I think
> that's
> > what
> > > you've intended it for, isn't it?).
> > > 
> > > I'll post a patch for review in the afternoon
> > > (hopefully) and commit it after you've
> checked it.
> > > 
> > > @PersistenceContext will be a bit trickier, since
> it
> > is not
> > > thread save and we have to do kind of
> > 'scoping'
> > > ourself.
> > > 
> > > The @CustomerDataservice with the whole XML stuff
> will
> > be
> > > the next step after we've solved this
> problem.
> > > 
> > > 
> > > LieGrue,
> > > strub
> > > 
> > > 
> > > --- Gurkan Erdogdu
> <gu...@yahoo.com>
> > schrieb
> > > am Di, 27.1.2009:
> > > 
> > > > Von: Gurkan Erdogdu
> > <gu...@yahoo.com>
> > > > Betreff: Re: level of resource injection
> > > > An: openwebbeans-dev@incubator.apache.org
> > > > Datum: Dienstag, 27. Januar 2009, 12:47
> > > > Hi Mark;
> > > > 
> > > > Do you try to implement resource injections
> via
> > XML
> > > > definitions, right? Below sketch is the
> summary
> > of how
> > > you
> > > > can proceed with the current implementation.
> > > > 
> > > > For XML defined webbeans, the main entry
> point is
> > the
> > > > *WebBeansXMLConfigurator* class. Java EE
> > Resources are
> > > only
> > > > defined in the xml file, according to the
> *9.5.2
> > > Type-Level
> > > > metadata for a bean*. This part is handled
> in the
> > > >
> > *WebBeansXMLConfigurator#configureTypeLevelMetaData*
> > > method.
> > > > 
> > > > 
> > > > For injectable resources, you can create
> another
> > class
> > > like
> > > > *XMLResourceInjectableField* in the
> *inject/xml*
> > > package and
> > > > add the
> *Map<Field,XMLInjectionPointModel> 
> > > > injectedResources* instance variable into
> the
> > > > *XMLComponentImpl.java* to hold the
> injectable
> > > resource
> > > > fields.
> > > > 
> > > > After that you will have to add the resource
> > injection
> > > > fields that are declared in the XML into the
> > resource
> > > > injection map in the *XMLComponentImpl*
> class.
> > You can
> > > > create another method for this in the
> > > > *WebBeansXMLConfigurator* class, for example
> > > > *configureInjectableResources()*, and call
> this
> > method
> > > from
> > > > *configureTypeLevelMetaData()* method.
> > > > 
> > > > Skeletons of the codes may like the
> followings;
> > > > 
> > > > WebBeansXMLConfigurator.java
> > > >
> ----------------------------------------------
> > > > ........
> > > > 
> > > > //Update this method
> > > >  public <T> void
> > configureTypeLevelMetaData()
> > > > {
> > > >    //Add this method call
> > > >    configureInjectableResources(); 
> > > > 
> > > > }
> > > > //This is the new method that is responsible
> for
> > > adding
> > > > resource injection fields to the component
> > > > public <T> void
> > configureInjectableResources()
> > > > {
> > > >     //Find fields from resource decleration
> in
> > XML
> > > >     //Create XMLInjectionPointModel for each
> > field
> > > >     //Add field and related model into the
> > > >
> > >
> >
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> > > > }
> > > > 
> > > > XMLComponentImpl.java
> > > > ---------------------------------
> > > > After that in XMLComponentImpl class, update
> > > injectFields
> > > > method to inject resources,
> > > >    
> > > > //Update this method for adding resource
> > injection
> > > support
> > > > 
> > > >  protected void injectFields(T instance)
> > > > {
> > > >    ......
> > > >    //For each resource injection map entry  
> > > >    //Create new *XMLResourceInjectableField*
> > instance
> > > >    //Set field with calling the
> > > > AbstractInjectable#inject(....)
> > > > }
> > > > AbstractInjectable class
> > > > ---------------------------------
> > > > public Object inject()
> > > > {
> > > >     //If resource, create injection object
> with
> > method
> > > > injectResource
> > > >     if (isResource(annotations))
> > > >             {
> > > >                 return injectResource(type,
> > > annotations);
> > > >             }
> > > > }
> > > > 
> > > > WDYT?
> > > > 
> > > > /Gurkan
> > > > 
> > > > 
> > > > 
> > > > ________________________________
> > > > From: Mark Struberg
> <st...@yahoo.de>
> > > > To: openwebbeans-dev@incubator.apache.org
> > > > Sent: Tuesday, January 27, 2009 12:35:02 PM
> > > > Subject: level of resource injection
> > > > 
> > > > Gurkan,
> > > > another question about resources: where
> should I
> > > actually
> > > > inject the resources finally?
> > > > 
> > > > This is the stack trace so far:
> > > > 
> > > >
> > InjectionResolver.implResolveByType(Class<?>,
> > > Type[],
> > > > Annotation...) line: 94    
> > > >
> > >
> >
> InjectableField(AbstractInjectable).inject(Class<T>,
> > > > Type[], Annotation...) line: 83    
> > > > InjectableField.doInjection() line: 92    
> > > > 
> > > > 
> > > > My thoughts: 
> > > > Resources can be handled in a very high
> layer,
> > since
> > > the
> > > > 'accessors' already hide all the
> > underlying
> > > > complexity of having classloader hierarchies
> etc,
> > > isn't?
> > > > 
> > > > So in the 
> > > > AbstractInjectable#inject
> > > > I'd like to add something like:
> > > > 
> > > >             if (isResource(annotations))
> > > >             {
> > > >                 return injectResource(type,
> > > annotations);
> > > >             }
> > > > 
> > > > LieGrü,
> > > > strub


      

Re: level of resource injection

Posted by Mark Struberg <st...@yahoo.de>.
I'm a bit confused:

Section 3.6 states that:
> A resource always has scope @Dependent.

What does this mean for @PersistenceUnit?

Another open issue: if JNDI is involved, we have to take the EntityManagerFactory from there instead of getting it from the Persistence Factory.

What do you suggest for this scenario?

LieGrue,
strub

--- Mark Struberg <st...@yahoo.de> schrieb am Mi, 28.1.2009:

> Von: Mark Struberg <st...@yahoo.de>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Mittwoch, 28. Januar 2009, 14:36
> it's done.
> 
> please review the patch in 
> https://issues.apache.org/jira/browse/OWB-71
> 
> Regarding JPAUtil#getPersistenceUnit
> 
> I'm in favour to implement those functions for the
> basic systems directly in our code for now and think about
> what to implement via an SPI later in a 2nd round. This will
> give us more time to learn what we really need first.
> 
> LieGrue,
> strub
> 
> 
> --- Gurkan Erdogdu <gu...@yahoo.com> schrieb
> am Di, 27.1.2009:
> 
> > Von: Gurkan Erdogdu <gu...@yahoo.com>
> > Betreff: Re: level of resource injection
> > An: openwebbeans-dev@incubator.apache.org
> > Datum: Dienstag, 27. Januar 2009, 15:55
> > Ok, Mark.
> > 
> 
> > ________________________________
> > From: Mark Struberg <st...@yahoo.de>
> > To: openwebbeans-dev@incubator.apache.org
> > Sent: Tuesday, January 27, 2009 4:04:26 PM
> > Subject: Re: level of resource injection
> > 
> > Hi Gurkan!
> > 
> > Thanks for the tips!
> > 
> > Currently I'm only looking at the injection of
> > resources which do not need any XML. So I started with
> > implementing @PersistenceUnit and looking forward to
> wrap
> > all the necessary PersistenceManagerFactory stuff in
> > JPAUtil.java (currently empty, but I think that's
> what
> > you've intended it for, isn't it?).
> > 
> > I'll post a patch for review in the afternoon
> > (hopefully) and commit it after you've checked it.
> > 
> > @PersistenceContext will be a bit trickier, since it
> is not
> > thread save and we have to do kind of
> 'scoping'
> > ourself.
> > 
> > The @CustomerDataservice with the whole XML stuff will
> be
> > the next step after we've solved this problem.
> > 
> > 
> > LieGrue,
> > strub
> > 
> > 
> > --- Gurkan Erdogdu <gu...@yahoo.com>
> schrieb
> > am Di, 27.1.2009:
> > 
> > > Von: Gurkan Erdogdu
> <gu...@yahoo.com>
> > > Betreff: Re: level of resource injection
> > > An: openwebbeans-dev@incubator.apache.org
> > > Datum: Dienstag, 27. Januar 2009, 12:47
> > > Hi Mark;
> > > 
> > > Do you try to implement resource injections via
> XML
> > > definitions, right? Below sketch is the summary
> of how
> > you
> > > can proceed with the current implementation.
> > > 
> > > For XML defined webbeans, the main entry point is
> the
> > > *WebBeansXMLConfigurator* class. Java EE
> Resources are
> > only
> > > defined in the xml file, according to the *9.5.2
> > Type-Level
> > > metadata for a bean*. This part is handled in the
> > >
> *WebBeansXMLConfigurator#configureTypeLevelMetaData*
> > method.
> > > 
> > > 
> > > For injectable resources, you can create another
> class
> > like
> > > *XMLResourceInjectableField* in the *inject/xml*
> > package and
> > > add the *Map<Field,XMLInjectionPointModel> 
> > > injectedResources* instance variable into the
> > > *XMLComponentImpl.java* to hold the injectable
> > resource
> > > fields.
> > > 
> > > After that you will have to add the resource
> injection
> > > fields that are declared in the XML into the
> resource
> > > injection map in the *XMLComponentImpl* class.
> You can
> > > create another method for this in the
> > > *WebBeansXMLConfigurator* class, for example
> > > *configureInjectableResources()*, and call this
> method
> > from
> > > *configureTypeLevelMetaData()* method.
> > > 
> > > Skeletons of the codes may like the followings;
> > > 
> > > WebBeansXMLConfigurator.java
> > > ----------------------------------------------
> > > ........
> > > 
> > > //Update this method
> > >  public <T> void
> configureTypeLevelMetaData()
> > > {
> > >    //Add this method call
> > >    configureInjectableResources(); 
> > > 
> > > }
> > > //This is the new method that is responsible for
> > adding
> > > resource injection fields to the component
> > > public <T> void
> configureInjectableResources()
> > > {
> > >     //Find fields from resource decleration in
> XML
> > >     //Create XMLInjectionPointModel for each
> field
> > >     //Add field and related model into the
> > >
> >
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> > > }
> > > 
> > > XMLComponentImpl.java
> > > ---------------------------------
> > > After that in XMLComponentImpl class, update
> > injectFields
> > > method to inject resources,
> > >    
> > > //Update this method for adding resource
> injection
> > support
> > > 
> > >  protected void injectFields(T instance)
> > > {
> > >    ......
> > >    //For each resource injection map entry  
> > >    //Create new *XMLResourceInjectableField*
> instance
> > >    //Set field with calling the
> > > AbstractInjectable#inject(....)
> > > }
> > > AbstractInjectable class
> > > ---------------------------------
> > > public Object inject()
> > > {
> > >     //If resource, create injection object with
> method
> > > injectResource
> > >     if (isResource(annotations))
> > >             {
> > >                 return injectResource(type,
> > annotations);
> > >             }
> > > }
> > > 
> > > WDYT?
> > > 
> > > /Gurkan
> > > 
> > > 
> > > 
> > > ________________________________
> > > From: Mark Struberg <st...@yahoo.de>
> > > To: openwebbeans-dev@incubator.apache.org
> > > Sent: Tuesday, January 27, 2009 12:35:02 PM
> > > Subject: level of resource injection
> > > 
> > > Gurkan,
> > > another question about resources: where should I
> > actually
> > > inject the resources finally?
> > > 
> > > This is the stack trace so far:
> > > 
> > >
> InjectionResolver.implResolveByType(Class<?>,
> > Type[],
> > > Annotation...) line: 94    
> > >
> >
> InjectableField(AbstractInjectable).inject(Class<T>,
> > > Type[], Annotation...) line: 83    
> > > InjectableField.doInjection() line: 92    
> > > 
> > > 
> > > My thoughts: 
> > > Resources can be handled in a very high layer,
> since
> > the
> > > 'accessors' already hide all the
> underlying
> > > complexity of having classloader hierarchies etc,
> > isn't?
> > > 
> > > So in the 
> > > AbstractInjectable#inject
> > > I'd like to add something like:
> > > 
> > >             if (isResource(annotations))
> > >             {
> > >                 return injectResource(type,
> > annotations);
> > >             }
> > > 
> > > LieGrü,
> > > strub


      

Re: level of resource injection

Posted by Mark Struberg <st...@yahoo.de>.
it's done.

please review the patch in 
https://issues.apache.org/jira/browse/OWB-71

Regarding JPAUtil#getPersistenceUnit

I'm in favour to implement those functions for the basic systems directly in our code for now and think about what to implement via an SPI later in a 2nd round. This will give us more time to learn what we really need first.

LieGrue,
strub


--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Di, 27.1.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Dienstag, 27. Januar 2009, 15:55
> Ok, Mark.
> 

> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: openwebbeans-dev@incubator.apache.org
> Sent: Tuesday, January 27, 2009 4:04:26 PM
> Subject: Re: level of resource injection
> 
> Hi Gurkan!
> 
> Thanks for the tips!
> 
> Currently I'm only looking at the injection of
> resources which do not need any XML. So I started with
> implementing @PersistenceUnit and looking forward to wrap
> all the necessary PersistenceManagerFactory stuff in
> JPAUtil.java (currently empty, but I think that's what
> you've intended it for, isn't it?).
> 
> I'll post a patch for review in the afternoon
> (hopefully) and commit it after you've checked it.
> 
> @PersistenceContext will be a bit trickier, since it is not
> thread save and we have to do kind of 'scoping'
> ourself.
> 
> The @CustomerDataservice with the whole XML stuff will be
> the next step after we've solved this problem.
> 
> 
> LieGrue,
> strub
> 
> 
> --- Gurkan Erdogdu <gu...@yahoo.com> schrieb
> am Di, 27.1.2009:
> 
> > Von: Gurkan Erdogdu <gu...@yahoo.com>
> > Betreff: Re: level of resource injection
> > An: openwebbeans-dev@incubator.apache.org
> > Datum: Dienstag, 27. Januar 2009, 12:47
> > Hi Mark;
> > 
> > Do you try to implement resource injections via XML
> > definitions, right? Below sketch is the summary of how
> you
> > can proceed with the current implementation.
> > 
> > For XML defined webbeans, the main entry point is the
> > *WebBeansXMLConfigurator* class. Java EE Resources are
> only
> > defined in the xml file, according to the *9.5.2
> Type-Level
> > metadata for a bean*. This part is handled in the
> > *WebBeansXMLConfigurator#configureTypeLevelMetaData*
> method.
> > 
> > 
> > For injectable resources, you can create another class
> like
> > *XMLResourceInjectableField* in the *inject/xml*
> package and
> > add the *Map<Field,XMLInjectionPointModel> 
> > injectedResources* instance variable into the
> > *XMLComponentImpl.java* to hold the injectable
> resource
> > fields.
> > 
> > After that you will have to add the resource injection
> > fields that are declared in the XML into the resource
> > injection map in the *XMLComponentImpl* class. You can
> > create another method for this in the
> > *WebBeansXMLConfigurator* class, for example
> > *configureInjectableResources()*, and call this method
> from
> > *configureTypeLevelMetaData()* method.
> > 
> > Skeletons of the codes may like the followings;
> > 
> > WebBeansXMLConfigurator.java
> > ----------------------------------------------
> > ........
> > 
> > //Update this method
> >  public <T> void configureTypeLevelMetaData()
> > {
> >    //Add this method call
> >    configureInjectableResources(); 
> > 
> > }
> > //This is the new method that is responsible for
> adding
> > resource injection fields to the component
> > public <T> void configureInjectableResources()
> > {
> >     //Find fields from resource decleration in XML
> >     //Create XMLInjectionPointModel for each field
> >     //Add field and related model into the
> >
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> > }
> > 
> > XMLComponentImpl.java
> > ---------------------------------
> > After that in XMLComponentImpl class, update
> injectFields
> > method to inject resources,
> >    
> > //Update this method for adding resource injection
> support
> > 
> >  protected void injectFields(T instance)
> > {
> >    ......
> >    //For each resource injection map entry  
> >    //Create new *XMLResourceInjectableField* instance
> >    //Set field with calling the
> > AbstractInjectable#inject(....)
> > }
> > AbstractInjectable class
> > ---------------------------------
> > public Object inject()
> > {
> >     //If resource, create injection object with method
> > injectResource
> >     if (isResource(annotations))
> >             {
> >                 return injectResource(type,
> annotations);
> >             }
> > }
> > 
> > WDYT?
> > 
> > /Gurkan
> > 
> > 
> > 
> > ________________________________
> > From: Mark Struberg <st...@yahoo.de>
> > To: openwebbeans-dev@incubator.apache.org
> > Sent: Tuesday, January 27, 2009 12:35:02 PM
> > Subject: level of resource injection
> > 
> > Gurkan,
> > another question about resources: where should I
> actually
> > inject the resources finally?
> > 
> > This is the stack trace so far:
> > 
> > InjectionResolver.implResolveByType(Class<?>,
> Type[],
> > Annotation...) line: 94    
> >
> InjectableField(AbstractInjectable).inject(Class<T>,
> > Type[], Annotation...) line: 83    
> > InjectableField.doInjection() line: 92    
> > 
> > 
> > My thoughts: 
> > Resources can be handled in a very high layer, since
> the
> > 'accessors' already hide all the underlying
> > complexity of having classloader hierarchies etc,
> isn't?
> > 
> > So in the 
> > AbstractInjectable#inject
> > I'd like to add something like:
> > 
> >             if (isResource(annotations))
> >             {
> >                 return injectResource(type,
> annotations);
> >             }
> > 
> > LieGrü,
> > strub


      

Re: level of resource injection

Posted by Gurkan Erdogdu <gu...@yahoo.com>.
Ok, Mark.




________________________________
From: Mark Struberg <st...@yahoo.de>
To: openwebbeans-dev@incubator.apache.org
Sent: Tuesday, January 27, 2009 4:04:26 PM
Subject: Re: level of resource injection

Hi Gurkan!

Thanks for the tips!

Currently I'm only looking at the injection of resources which do not need any XML. So I started with implementing @PersistenceUnit and looking forward to wrap all the necessary PersistenceManagerFactory stuff in JPAUtil.java (currently empty, but I think that's what you've intended it for, isn't it?).

I'll post a patch for review in the afternoon (hopefully) and commit it after you've checked it.

@PersistenceContext will be a bit trickier, since it is not thread save and we have to do kind of 'scoping' ourself.

The @CustomerDataservice with the whole XML stuff will be the next step after we've solved this problem.


LieGrue,
strub


--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Di, 27.1.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Dienstag, 27. Januar 2009, 12:47
> Hi Mark;
> 
> Do you try to implement resource injections via XML
> definitions, right? Below sketch is the summary of how you
> can proceed with the current implementation.
> 
> For XML defined webbeans, the main entry point is the
> *WebBeansXMLConfigurator* class. Java EE Resources are only
> defined in the xml file, according to the *9.5.2 Type-Level
> metadata for a bean*. This part is handled in the
> *WebBeansXMLConfigurator#configureTypeLevelMetaData* method.
> 
> 
> For injectable resources, you can create another class like
> *XMLResourceInjectableField* in the *inject/xml* package and
> add the *Map<Field,XMLInjectionPointModel> 
> injectedResources* instance variable into the
> *XMLComponentImpl.java* to hold the injectable resource
> fields.
> 
> After that you will have to add the resource injection
> fields that are declared in the XML into the resource
> injection map in the *XMLComponentImpl* class. You can
> create another method for this in the
> *WebBeansXMLConfigurator* class, for example
> *configureInjectableResources()*, and call this method from
> *configureTypeLevelMetaData()* method.
> 
> Skeletons of the codes may like the followings;
> 
> WebBeansXMLConfigurator.java
> ----------------------------------------------
> ........
> 
> //Update this method
>  public <T> void configureTypeLevelMetaData()
> {
>    //Add this method call
>    configureInjectableResources(); 
> 
> }
> //This is the new method that is responsible for adding
> resource injection fields to the component
> public <T> void configureInjectableResources()
> {
>     //Find fields from resource decleration in XML
>     //Create XMLInjectionPointModel for each field
>     //Add field and related model into the
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> }
> 
> XMLComponentImpl.java
> ---------------------------------
> After that in XMLComponentImpl class, update injectFields
> method to inject resources,
>    
> //Update this method for adding resource injection support
> 
>  protected void injectFields(T instance)
> {
>    ......
>    //For each resource injection map entry  
>    //Create new *XMLResourceInjectableField* instance
>    //Set field with calling the
> AbstractInjectable#inject(....)
> }
> AbstractInjectable class
> ---------------------------------
> public Object inject()
> {
>     //If resource, create injection object with method
> injectResource
>     if (isResource(annotations))
>             {
>                 return injectResource(type, annotations);
>             }
> }
> 
> WDYT?
> 
> /Gurkan
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: openwebbeans-dev@incubator.apache.org
> Sent: Tuesday, January 27, 2009 12:35:02 PM
> Subject: level of resource injection
> 
> Gurkan,
> another question about resources: where should I actually
> inject the resources finally?
> 
> This is the stack trace so far:
> 
> InjectionResolver.implResolveByType(Class<?>, Type[],
> Annotation...) line: 94    
> InjectableField(AbstractInjectable).inject(Class<T>,
> Type[], Annotation...) line: 83    
> InjectableField.doInjection() line: 92    
> 
> 
> My thoughts: 
> Resources can be handled in a very high layer, since the
> 'accessors' already hide all the underlying
> complexity of having classloader hierarchies etc, isn't?
> 
> So in the 
> AbstractInjectable#inject
> I'd like to add something like:
> 
>             if (isResource(annotations))
>             {
>                 return injectResource(type, annotations);
>             }
> 
> LieGrü,
> strub


      

Re: level of resource injection

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

Thanks for the tips!

Currently I'm only looking at the injection of resources which do not need any XML. So I started with implementing @PersistenceUnit and looking forward to wrap all the necessary PersistenceManagerFactory stuff in JPAUtil.java (currently empty, but I think that's what you've intended it for, isn't it?).

I'll post a patch for review in the afternoon (hopefully) and commit it after you've checked it.

@PersistenceContext will be a bit trickier, since it is not thread save and we have to do kind of 'scoping' ourself.

The @CustomerDataservice with the whole XML stuff will be the next step after we've solved this problem.


LieGrue,
strub


--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Di, 27.1.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: level of resource injection
> An: openwebbeans-dev@incubator.apache.org
> Datum: Dienstag, 27. Januar 2009, 12:47
> Hi Mark;
> 
> Do you try to implement resource injections via XML
> definitions, right? Below sketch is the summary of how you
> can proceed with the current implementation.
> 
> For XML defined webbeans, the main entry point is the
> *WebBeansXMLConfigurator* class. Java EE Resources are only
> defined in the xml file, according to the *9.5.2 Type-Level
> metadata for a bean*. This part is handled in the
> *WebBeansXMLConfigurator#configureTypeLevelMetaData* method.
> 
> 
> For injectable resources, you can create another class like
> *XMLResourceInjectableField* in the *inject/xml* package and
> add the *Map<Field,XMLInjectionPointModel> 
> injectedResources* instance variable into the
> *XMLComponentImpl.java* to hold the injectable resource
> fields.
> 
> After that you will have to add the resource injection
> fields that are declared in the XML into the resource
> injection map in the *XMLComponentImpl* class. You can
> create another method for this in the
> *WebBeansXMLConfigurator* class, for example
> *configureInjectableResources()*, and call this method from
> *configureTypeLevelMetaData()* method.
> 
> Skeletons of the codes may like the followings;
> 
> WebBeansXMLConfigurator.java
> ----------------------------------------------
> ........
> 
> //Update this method
>  public <T> void configureTypeLevelMetaData()
> {
>    //Add this method call
>    configureInjectableResources(); 
> 
> }
> //This is the new method that is responsible for adding
> resource injection fields to the component
> public <T> void configureInjectableResources()
> {
>     //Find fields from resource decleration in XML
>     //Create XMLInjectionPointModel for each field
>     //Add field and related model into the
> XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
> }
> 
> XMLComponentImpl.java
> ---------------------------------
> After that in XMLComponentImpl class, update injectFields
> method to inject resources,
>     
> //Update this method for adding resource injection support
> 
>  protected void injectFields(T instance)
> {
>    ......
>    //For each resource injection map entry   
>    //Create new *XMLResourceInjectableField* instance
>    //Set field with calling the
> AbstractInjectable#inject(....)
> }
> AbstractInjectable class
> ---------------------------------
> public Object inject()
> {
>     //If resource, create injection object with method
> injectResource
>     if (isResource(annotations))
>             {
>                 return injectResource(type, annotations);
>             }
> }
> 
> WDYT?
> 
> /Gurkan
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: openwebbeans-dev@incubator.apache.org
> Sent: Tuesday, January 27, 2009 12:35:02 PM
> Subject: level of resource injection
> 
> Gurkan,
> another question about resources: where should I actually
> inject the resources finally?
> 
> This is the stack trace so far:
> 
> InjectionResolver.implResolveByType(Class<?>, Type[],
> Annotation...) line: 94    
> InjectableField(AbstractInjectable).inject(Class<T>,
> Type[], Annotation...) line: 83    
> InjectableField.doInjection() line: 92    
> 
> 
> My thoughts: 
> Resources can be handled in a very high layer, since the
> 'accessors' already hide all the underlying
> complexity of having classloader hierarchies etc, isn't?
> 
> So in the 
> AbstractInjectable#inject
> I'd like to add something like:
> 
>             if (isResource(annotations))
>             {
>                 return injectResource(type, annotations);
>             }
> 
> LieGrü,
> strub


      

Re: level of resource injection

Posted by Gurkan Erdogdu <gu...@yahoo.com>.
Hi Mark;

Do you try to implement resource injections via XML definitions, right? Below sketch is the summary of how you can proceed with the current implementation.

For XML defined webbeans, the main entry point is the *WebBeansXMLConfigurator* class. Java EE Resources are only defined in the xml file, according to the *9.5.2 Type-Level metadata for a bean*. This part is handled in the *WebBeansXMLConfigurator#configureTypeLevelMetaData* method. 

For injectable resources, you can create another class like *XMLResourceInjectableField* in the *inject/xml* package and add the *Map<Field,XMLInjectionPointModel>  injectedResources* instance variable into the *XMLComponentImpl.java* to hold the injectable resource fields.

After that you will have to add the resource injection fields that are declared in the XML into the resource injection map in the *XMLComponentImpl* class. You can create another method for this in the *WebBeansXMLConfigurator* class, for example *configureInjectableResources()*, and call this method from *configureTypeLevelMetaData()* method.

Skeletons of the codes may like the followings;

WebBeansXMLConfigurator.java
----------------------------------------------
........

//Update this method
 public <T> void configureTypeLevelMetaData()
{
   //Add this method call
   configureInjectableResources(); 

}
//This is the new method that is responsible for adding resource injection fields to the component
public <T> void configureInjectableResources()
{
    //Find fields from resource decleration in XML
    //Create XMLInjectionPointModel for each field
    //Add field and related model into the XMLComponentImpl#Map<Field,XMLInjectionPointModel> 
}

XMLComponentImpl.java
---------------------------------
After that in XMLComponentImpl class, update injectFields method to inject resources,
    
//Update this method for adding resource injection support

 protected void injectFields(T instance)
{
   ......
   //For each resource injection map entry   
   //Create new *XMLResourceInjectableField* instance
   //Set field with calling the AbstractInjectable#inject(....)
}
AbstractInjectable class
---------------------------------
public Object inject()
{
    //If resource, create injection object with method injectResource
    if (isResource(annotations))
            {
                return injectResource(type, annotations);
            }
}

WDYT?

/Gurkan



________________________________
From: Mark Struberg <st...@yahoo.de>
To: openwebbeans-dev@incubator.apache.org
Sent: Tuesday, January 27, 2009 12:35:02 PM
Subject: level of resource injection

Gurkan,
another question about resources: where should I actually inject the resources finally?

This is the stack trace so far:

InjectionResolver.implResolveByType(Class<?>, Type[], Annotation...) line: 94    
InjectableField(AbstractInjectable).inject(Class<T>, Type[], Annotation...) line: 83    
InjectableField.doInjection() line: 92    


My thoughts: 
Resources can be handled in a very high layer, since the 'accessors' already hide all the underlying complexity of having classloader hierarchies etc, isn't?

So in the 
AbstractInjectable#inject
I'd like to add something like:

            if (isResource(annotations))
            {
                return injectResource(type, annotations);
            }

LieGrü,
strub