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");
}
}
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;
}
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;
}
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);
}
}
}
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;
}
Aggregations