Hi Ryan Don't worry about those typos, it happens all the time, I can confirm that :-)
On Wed, May 25, 2011 at 3:04 AM, Ryan Zoerner <[email protected]> wrote: > This is what I had in mind for an RP constructor: Incidentally, EJB > annotations show up in the cri. under > ClassResourceInfo.elementData[i].resourceClass.declaredAnnotations.table[j]. > h.type.name and > ClassResourceInfo.elementData[i].resourceClass.declaredAnnotations.table[j].h.memberValues.table[k].key > and > ClassResourceInfo.elementData[i].resourceClass.declaredAnnotations.table[j].h.memberValues.table[k].value > > > as an example, I annotated Customer.java with @EJB and find: > interface javax.ejb.EJB > @javax.ejb.EJB(beanName=, mappedName=, beanInterface=class java.lang.Object, > description=, name=) > > within the cri associated with serverF.serviceF.classResourceInfos... > They show up because those annotations are retained at runtime, but we don't have to deal with them. It's the job of EJB factories/proxies/etc to deal with them. The only thing we need to do is to have a provider that will ask a container-specific EJB factory/etc to create and release the instance. > ---------------------------------------------------------------------------------------------------------------------------------------------------- > public class JAXRS_EJBResourceProvider implements ResourceProvider > { > enum EjbLifecycle > { > STATELESS, > STATEFUL, > SINGLETON > } > > private Object resourceInstance; > > public JAXRS_EJBResourceProvider(Object o, JAXRSServerFactoryBean sfb) > { > if( isEJB(o, sfb) ) > { > EjbLifecycle ejbLifecycle = getLifecycleFromAnnotation( o, sfb > ); > if( ejbLifecycle == EjbLifecycle.STATELESS ) > { > resourceInstance = delegateTo( STATELESS_delegatee ); > } > else if( ejbLifecycle == EjbLifecycle.STATEFUL ) > { > resourceInstance = delegateTo( STATEFUL_delegatee ); > } > else if( ejbLifecycle == EjbLifecycle.SINGLETON ) > { > resourceInstance = delegateTo( SINGLETON_delegatee ); > } > else > { > throw new impossibleThingHappenedException(); > } > } > else > { > return; > } > return; > } > } I can see how it may work in principle, but please accept that CXF itself can not manage instantiating EJB resource classes itself. It has to delegate to EJB factories because they may be keeping pools of EJB beans and do whatever EJB factories do for adding additional pre or post processing handlers around EJB beans. Thus you don't need a reference to JAXRSServerFactoryBean, and in fact you don't need Object reference because it your EJBProvider that will create Objects. Check CXF JAX-RS singleton or per-request ResourceProvider impls. It is only a reference to an (EJB) resource class that needs to be passed to a constructor. And you definitely do not need to cache create objects. That was the reason I thought writing a custom provider for your initial CustomerService project and debugging it would help you Cheers, Sergey
