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 <[email protected]> schrieb am Di, 27.1.2009: > Von: Gurkan Erdogdu <[email protected]> > Betreff: Re: level of resource injection > An: [email protected] > 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 <[email protected]> > To: [email protected] > 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
