Search in sources :

Example 11 with ConfiguredBeanLocator

use of org.apache.cxf.configuration.ConfiguredBeanLocator in project cxf by apache.

the class GreeterImplWithTransaction method greetMeOneWay.

@Override
public void greetMeOneWay(String name) {
    ConfiguredBeanLocator locator = BusFactory.getDefaultBus().getExtension(ConfiguredBeanLocator.class);
    TransactionManager tm = locator.getBeansOfType(TransactionManager.class).iterator().next();
    try {
        Assert.assertNotNull("We should run inside a transaction", tm.getTransaction());
    } catch (SystemException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    if (BAD_GUY.equals(name)) {
        throw new RuntimeException("Got a bad guy call for greetMe");
    }
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager)

Example 12 with ConfiguredBeanLocator

use of org.apache.cxf.configuration.ConfiguredBeanLocator in project cxf by apache.

the class ExtensionManagerBus method getExtension.

public final <T> T getExtension(Class<T> extensionType) {
    Object obj = extensions.get(extensionType);
    if (obj == null) {
        if (missingExtensions.contains(extensionType)) {
            // already know we cannot find it
            return null;
        }
        ConfiguredBeanLocator loc = (ConfiguredBeanLocator) extensions.get(ConfiguredBeanLocator.class);
        if (loc == null) {
            loc = createConfiguredBeanLocator();
        }
        if (loc != null) {
            obj = loc.getBeanOfType(extensionType.getName(), extensionType);
            if (obj != null) {
                extensions.put(extensionType, obj);
            } else {
                // force loading
                Collection<?> objs = loc.getBeansOfType(extensionType);
                if (objs != null && objs.size() != 0) {
                    extensions.put(extensionType, objs.iterator().next());
                }
                obj = extensions.get(extensionType);
            }
        }
    }
    if (null != obj) {
        return extensionType.cast(obj);
    }
    // record that it couldn't be found to avoid expensive searches again in the future
    missingExtensions.add(extensionType);
    return null;
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator)

Example 13 with ConfiguredBeanLocator

use of org.apache.cxf.configuration.ConfiguredBeanLocator in project cxf by apache.

the class JMSConfigFactory method getTransactionManager.

private static TransactionManager getTransactionManager(Bus bus, JMSEndpoint endpoint) {
    String tmName = endpoint.getJndiTransactionManagerName();
    TransactionManager tm = null;
    ConfiguredBeanLocator locator = bus.getExtension(ConfiguredBeanLocator.class);
    if (tmName != null) {
        if (locator != null) {
            tm = locator.getBeanOfType(tmName, TransactionManager.class);
        }
        if (tm == null) {
            tm = getTransactionManagerFromJndi(tmName);
        }
    }
    if (tm == null && locator != null) {
        Collection<? extends TransactionManager> tms = locator.getBeansOfType(TransactionManager.class);
        if (tms.size() == 1) {
            tm = tms.iterator().next();
        }
    }
    return tm;
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) TransactionManager(javax.transaction.TransactionManager)

Example 14 with ConfiguredBeanLocator

use of org.apache.cxf.configuration.ConfiguredBeanLocator in project cxf by apache.

the class WSDLManagerImpl method setBus.

@Resource
public final void setBus(Bus b) {
    bus = b;
    if (null != bus) {
        bus.setExtension(this, WSDLManager.class);
        ConfiguredBeanLocator loc = bus.getExtension(ConfiguredBeanLocator.class);
        if (loc != null) {
            loc.getBeansOfType(WSDLExtensionLoader.class);
        }
    }
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) Resource(javax.annotation.Resource)

Example 15 with ConfiguredBeanLocator

use of org.apache.cxf.configuration.ConfiguredBeanLocator in project cxf by apache.

the class PolicyEngineImpl method getPolicyProviders.

public synchronized Collection<PolicyProvider> getPolicyProviders() {
    if (policyProviders == null) {
        policyProviders = new CopyOnWriteArrayList<PolicyProvider>();
        if (bus != null) {
            ConfiguredBeanLocator loc = bus.getExtension(ConfiguredBeanLocator.class);
            if (loc != null) {
                loc.getBeansOfType(PolicyProvider.class);
            }
        }
        policyProviders.addAll(preSetPolicyProviders);
        preSetPolicyProviders = null;
    }
    return policyProviders;
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator)

Aggregations

ConfiguredBeanLocator (org.apache.cxf.configuration.ConfiguredBeanLocator)17 TransactionManager (javax.transaction.TransactionManager)4 Resource (javax.annotation.Resource)3 ConnectionFactory (javax.jms.ConnectionFactory)1 JMException (javax.management.JMException)1 SystemException (javax.transaction.SystemException)1 QName (javax.xml.namespace.QName)1 Bus (org.apache.cxf.Bus)1 BusException (org.apache.cxf.BusException)1 AbstractBindingFactory (org.apache.cxf.binding.AbstractBindingFactory)1 BindingFactory (org.apache.cxf.binding.BindingFactory)1 BusLifeCycleManager (org.apache.cxf.buslifecycle.BusLifeCycleManager)1 ConfigurerImpl (org.apache.cxf.configuration.spring.ConfigurerImpl)1 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)1 ResourceManager (org.apache.cxf.resource.ResourceManager)1 JMSEndpoint (org.apache.cxf.transport.jms.uri.JMSEndpoint)1 MyBeanLocator (org.apache.cxf.transport.jms.uri.MyBeanLocator)1 JMSDestinationResolver (org.apache.cxf.transport.jms.util.JMSDestinationResolver)1 JndiHelper (org.apache.cxf.transport.jms.util.JndiHelper)1 AutomaticWorkQueue (org.apache.cxf.workqueue.AutomaticWorkQueue)1