Search in sources :

Example 1 with ResourceContextProvider

use of org.apache.cxf.jaxrs.ext.ResourceContextProvider in project tomee by apache.

the class ResourceContextImpl method getResource.

@Override
public <T> T getResource(Class<T> cls) {
    final ResourceProvider rp;
    Object propValue = m.getContextualProperty(CONTEXT_PROVIDER_PROP);
    if (propValue instanceof ResourceContextProvider) {
        rp = ((ResourceContextProvider) propValue).getResourceProvider(cls);
    } else {
        rp = new PerRequestResourceProvider(cls);
    }
    T resource = cls.cast(rp.getInstance(m));
    return doInitResource(cls, resource);
}
Also used : PerRequestResourceProvider(org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider) ResourceProvider(org.apache.cxf.jaxrs.lifecycle.ResourceProvider) ResourceContextProvider(org.apache.cxf.jaxrs.ext.ResourceContextProvider) PerRequestResourceProvider(org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider)

Example 2 with ResourceContextProvider

use of org.apache.cxf.jaxrs.ext.ResourceContextProvider in project cxf by apache.

the class ResourceContextImpl method getResource.

@Override
public <T> T getResource(Class<T> cls) {
    ResourceProvider rp = null;
    Object propValue = m.getContextualProperty(CONTEXT_PROVIDER_PROP);
    if (propValue instanceof ResourceContextProvider) {
        rp = ((ResourceContextProvider) propValue).getResourceProvider(cls);
    } else {
        rp = new PerRequestResourceProvider(cls);
    }
    T resource = cls.cast(rp.getInstance(m));
    return doInitResource(cls, resource);
}
Also used : PerRequestResourceProvider(org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider) ResourceProvider(org.apache.cxf.jaxrs.lifecycle.ResourceProvider) ResourceContextProvider(org.apache.cxf.jaxrs.ext.ResourceContextProvider) PerRequestResourceProvider(org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider)

Aggregations

ResourceContextProvider (org.apache.cxf.jaxrs.ext.ResourceContextProvider)2 PerRequestResourceProvider (org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider)2 ResourceProvider (org.apache.cxf.jaxrs.lifecycle.ResourceProvider)2