Search in sources :

Example 1 with SinglePropertyResolver

use of org.apache.cxf.resource.SinglePropertyResolver in project cxf by apache.

the class ExtensionManagerImpl method loadAndRegister.

final void loadAndRegister(Extension e) {
    Class<?> cls = null;
    if (null != e.getInterfaceName() && !"".equals(e.getInterfaceName())) {
        cls = e.loadInterface(loader);
    } else {
        cls = e.getClassObject(loader);
    }
    if (null != activated && null != cls && null != activated.get(cls)) {
        return;
    }
    synchronized (e) {
        Object obj = e.load(loader, bus);
        if (obj == null) {
            return;
        }
        if (null != activated) {
            Configurer configurer = (Configurer) (activated.get(Configurer.class));
            if (null != configurer) {
                configurer.configureBean(obj);
            }
        }
        // let the object know for which namespaces it has been activated
        ResourceResolver namespacesResolver = null;
        if (null != e.getNamespaces()) {
            namespacesResolver = new SinglePropertyResolver(ACTIVATION_NAMESPACES_PROPERTY_NAME, e.getNamespaces());
            resourceManager.addResourceResolver(namespacesResolver);
        }
        // Now we call the setActivationNamespaces method directly here
        if (e.getNamespaces() != null && !e.getNamespaces().isEmpty()) {
            invokeSetterActivationNSMethod(obj, e.getNamespaces());
        }
        ResourceInjector injector = new ResourceInjector(resourceManager);
        try {
            injector.inject(obj);
            injector.construct(obj);
        } finally {
            if (null != namespacesResolver) {
                resourceManager.removeResourceResolver(namespacesResolver);
            }
        }
        if (null != activated) {
            if (cls == null) {
                cls = obj.getClass();
            }
            activated.put(cls, obj);
        }
    }
}
Also used : SinglePropertyResolver(org.apache.cxf.resource.SinglePropertyResolver) ResourceResolver(org.apache.cxf.resource.ResourceResolver) Configurer(org.apache.cxf.configuration.Configurer) ResourceInjector(org.apache.cxf.common.injection.ResourceInjector)

Example 2 with SinglePropertyResolver

use of org.apache.cxf.resource.SinglePropertyResolver in project tomee by apache.

the class ExtensionManagerImpl method loadAndRegister.

final void loadAndRegister(Extension e) {
    Class<?> cls;
    if (null != e.getInterfaceName() && !"".equals(e.getInterfaceName())) {
        cls = e.loadInterface(loader);
    } else {
        cls = e.getClassObject(loader);
    }
    if (null != activated && null != cls && null != activated.get(cls)) {
        return;
    }
    synchronized (e) {
        Object obj = e.load(loader, bus);
        if (obj == null) {
            return;
        }
        if (null != activated) {
            Configurer configurer = (Configurer) (activated.get(Configurer.class));
            if (null != configurer) {
                configurer.configureBean(obj);
            }
        }
        // let the object know for which namespaces it has been activated
        ResourceResolver namespacesResolver = null;
        if (null != e.getNamespaces()) {
            namespacesResolver = new SinglePropertyResolver(ACTIVATION_NAMESPACES_PROPERTY_NAME, e.getNamespaces());
            resourceManager.addResourceResolver(namespacesResolver);
        }
        // Now we call the setActivationNamespaces method directly here
        if (e.getNamespaces() != null && !e.getNamespaces().isEmpty()) {
            invokeSetterActivationNSMethod(obj, e.getNamespaces());
        }
        ResourceInjector injector = new ResourceInjector(resourceManager);
        try {
            injector.inject(obj);
            injector.construct(obj);
        } finally {
            if (null != namespacesResolver) {
                resourceManager.removeResourceResolver(namespacesResolver);
            }
        }
        if (null != activated) {
            if (cls == null) {
                cls = obj.getClass();
            }
            activated.put(cls, obj);
        }
    }
}
Also used : SinglePropertyResolver(org.apache.cxf.resource.SinglePropertyResolver) ResourceResolver(org.apache.cxf.resource.ResourceResolver) Configurer(org.apache.cxf.configuration.Configurer) ResourceInjector(org.apache.cxf.common.injection.ResourceInjector)

Example 3 with SinglePropertyResolver

use of org.apache.cxf.resource.SinglePropertyResolver in project cxf by apache.

the class ExtensionManagerTest method setUp.

@Before
public void setUp() {
    ResourceResolver resolver = new SinglePropertyResolver(EXTENSIONMANAGER_TEST_RESOURECE_NAME, this);
    ResourceManager rm = new DefaultResourceManager(resolver);
    extensions = new HashMap<>();
    extensions.put(Integer.class, Integer.valueOf(0));
    manager = new ExtensionManagerImpl("test-extension.xml", Thread.currentThread().getContextClassLoader(), extensions, rm, null);
}
Also used : SinglePropertyResolver(org.apache.cxf.resource.SinglePropertyResolver) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceResolver(org.apache.cxf.resource.ResourceResolver) ResourceManager(org.apache.cxf.resource.ResourceManager) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) Before(org.junit.Before)

Aggregations

ResourceResolver (org.apache.cxf.resource.ResourceResolver)3 SinglePropertyResolver (org.apache.cxf.resource.SinglePropertyResolver)3 ResourceInjector (org.apache.cxf.common.injection.ResourceInjector)2 Configurer (org.apache.cxf.configuration.Configurer)2 DefaultResourceManager (org.apache.cxf.resource.DefaultResourceManager)1 ResourceManager (org.apache.cxf.resource.ResourceManager)1 Before (org.junit.Before)1