use of org.apache.cxf.binding.BindingFactory in project cxf by apache.
the class BindingFactoryManagerImpl method loadAll.
private BindingFactory loadAll(final String namespace) {
// Try old method of having activationNamespaces configured in.
// It activates all the factories in the list until one matches, thus
// it activates stuff that really aren't needed.
ConfiguredBeanLocator.BeanLoaderListener<BindingFactory> listener = new ConfiguredBeanLocator.BeanLoaderListener<BindingFactory>() {
public boolean beanLoaded(String name, BindingFactory bean) {
loaded.add(name);
if (!bindingFactories.containsKey(namespace)) {
if (bean instanceof AbstractBindingFactory) {
for (String ns : ((AbstractBindingFactory) bean).getActivationNamespaces()) {
registerBindingFactory(ns, bean);
}
} else {
try {
Method m = bean.getClass().getMethod("getActivationNamespace");
Collection<String> c = CastUtils.cast((Collection<?>) m.invoke(bean));
for (String s : c) {
registerBindingFactory(s, bean);
}
} catch (Exception ex) {
// ignore
}
}
}
return bindingFactories.containsKey(namespace);
}
public boolean loadBean(String name, Class<? extends BindingFactory> type) {
return !bindingFactories.containsKey(namespace) && !loaded.contains(name);
}
};
bus.getExtension(ConfiguredBeanLocator.class).loadBeansOfType(BindingFactory.class, listener);
return bindingFactories.get(namespace);
}
use of org.apache.cxf.binding.BindingFactory in project cxf by apache.
the class BindingFactoryManagerImpl method loadActivationNamespace.
private BindingFactory loadActivationNamespace(final String namespace) {
final ConfiguredBeanLocator locator = bus.getExtension(ConfiguredBeanLocator.class);
// Second attempt will be to examine the factory class
// for a DEFAULT_NAMESPACES field and if it doesn't exist, try
// using the older activation ns things. This will then load most
// of the "older" things
ConfiguredBeanLocator.BeanLoaderListener<BindingFactory> listener = new ConfiguredBeanLocator.BeanLoaderListener<BindingFactory>() {
public boolean beanLoaded(String name, BindingFactory bean) {
loaded.add(name);
return bindingFactories.containsKey(namespace);
}
public boolean loadBean(String name, Class<? extends BindingFactory> type) {
if (loaded.contains(name)) {
return false;
}
try {
type.getField("DEFAULT_NAMESPACES");
return false;
} catch (Exception ex) {
// ignore
}
return locator.hasConfiguredPropertyValue(name, "activationNamespaces", namespace);
}
};
locator.loadBeansOfType(BindingFactory.class, listener);
return bindingFactories.get(namespace);
}
use of org.apache.cxf.binding.BindingFactory in project cxf by apache.
the class BindingFactoryManagerImpl method loadDefaultNamespace.
private BindingFactory loadDefaultNamespace(final String namespace) {
// First attempt will be to examine the factory class
// for a DEFAULT_NAMESPACES field and use it
ConfiguredBeanLocator.BeanLoaderListener<BindingFactory> listener = new ConfiguredBeanLocator.BeanLoaderListener<BindingFactory>() {
public boolean beanLoaded(String name, BindingFactory bean) {
loaded.add(name);
return bindingFactories.containsKey(namespace);
}
public boolean loadBean(String name, Class<? extends BindingFactory> type) {
if (!loaded.contains(name)) {
try {
Field f = type.getField("DEFAULT_NAMESPACES");
Object o = f.get(null);
if (o instanceof Collection) {
Collection<String> c = CastUtils.cast((Collection<?>) o);
return c.contains(namespace);
}
} catch (Exception ex) {
// ignore
}
}
return false;
}
};
bus.getExtension(ConfiguredBeanLocator.class).loadBeansOfType(BindingFactory.class, listener);
return bindingFactories.get(namespace);
}
use of org.apache.cxf.binding.BindingFactory in project cxf by apache.
the class BareInInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
bus = BusFactory.newInstance().createBus();
BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
IMocksControl control = createNiceControl();
BindingFactory bf = control.createMock(BindingFactory.class);
Binding binding = control.createMock(Binding.class);
expect(bf.createBinding(null)).andStubReturn(binding);
expect(binding.getInFaultInterceptors()).andStubReturn(new ArrayList<Interceptor<? extends Message>>());
expect(binding.getOutFaultInterceptors()).andStubReturn(new ArrayList<Interceptor<? extends Message>>());
bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);
}
use of org.apache.cxf.binding.BindingFactory in project cxf by apache.
the class EndpointImpl method createBinding.
final void createBinding(BindingInfo bi) throws EndpointException {
if (null != bi) {
String namespace = bi.getBindingId();
try {
final BindingFactory bf = bus.getExtension(BindingFactoryManager.class).getBindingFactory(namespace);
if (null == bf) {
Message msg = new Message("NO_BINDING_FACTORY", BUNDLE, namespace);
throw new EndpointException(msg);
}
binding = bf.createBinding(bi);
} catch (BusException ex) {
throw new EndpointException(ex);
}
}
}
Aggregations