Hi Romain!
Please look at the code what it did prior to my refactoring. It basically duplicated all the generic injection logic we had already. I now switched it to a stateless function and yes, you can _now_ easily clone it as it's now pretty straight forward: AnnotatedType annotatedType = beanManager.createAnnotatedType(instanceUnderInjection.getClass()); beanManager.createInjectionTarget(annotatedType).inject(instanceUnderInjection, ownerCreationalContext); That's really all which is needed. I have a patch for OpenEJB already, but I cannot run the tests as they are broken since a few weeks. See my mail on the openejb-dev list. LieGrue, strub >________________________________ > From: Romain Manni-Bucau <[email protected]> >To: [email protected]; Mark Struberg <[email protected]> >Sent: Monday, July 30, 2012 10:01 AM >Subject: Re: is OWBInjector too complex and really needed? > > >Hi Mark, > >we use it in openejb/tomee for the stateful side. > >if you refactor it...we'll fork it :p (more or less) > >- Romain > > > >2012/7/28 Mark Struberg <[email protected]> > >While cleaning up non-Serializable fields I stumbled across OWBInjector. I hit >this class pretty often and always get a cold shower. But finally we have to >clean it up somehow. >> >> >>It seems that the whole class was introduced to allow injection of CDI beans >>into EJBs. I'm not even sure if we still need this or if it's done completely >>different already. >> >>Fact is that it's poorly designed as it's not stateless but stores >>information about the 'wrapped' ee instance: >> >> /**Creational context to hold dependent instances*/ >> private CreationalContextImpl<?> ownerCreationalContext = null; >> >> /**Underlying javaee instance*/ >> private Object javaEEInstance; >> >> >> >>calling the method >> >>public OWBInjector inject(Object javaEeComponentInstance, >>CreationalContext<?> creationalContext) >>twice would overwrite the state information from the first call. That's >>certainly not perfect. >> >>This seems to get used in EjbInterceptorContext which in turn seems to be >>used when applying a @Interceptors annotation to a CDI bean. >> >> >>LieGrue, >>strub >> >> > > >
