cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: some thoughts that I wanted to post, in regards to RP, CRI, Exceptions, and a class scanner
Date Wed, 25 May 2011 13:04:03 GMT
Well, may be you need to have an EJB factory injected into that
provider, as shown here:
http://websvn.ow2.org/filedetails.php?repname=jonas&path=%2Fjonas%2Ftrunk%2Fjonas%2Fmodules%2Fservices%2Fwebservices%2Fcxf%2Fsrc%2Fmain%2Fjava%2Forg%2Fow2%2Fjonas%2Fws%2Fcxf%2Feasybeans%2FEasyBeansInvokerFactory.java

Or may be your provider (but only your provider, in the constructor),
can check a resourceClass's annotations and then do something similar
to what you prototyped but not delegating to CXF but to
container-specific EJB utility code/factories. I think you do need to
try CXF JAX-WS as suggested earlier, in order to understand how to
integrate (as far as the creation of instances is concerned) or at
least to peruse the relevant code, ask questions there, etc

Cheers, Sergey

On Wed, May 25, 2011 at 1:32 PM, Sergey Beryozkin <sberyozkin@gmail.com> wrote:
> 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 <ryanzoerner@gmail.com> 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
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Mime
View raw message