use of org.apache.cxf.BusException in project cxf by apache.
the class WSDLServiceUtils method getBindingFactory.
public static BindingFactory getBindingFactory(Binding binding, Bus bus, StringBuilder sb) {
BindingFactory factory = null;
for (Object obj : binding.getExtensibilityElements()) {
if (obj instanceof ExtensibilityElement) {
ExtensibilityElement ext = (ExtensibilityElement) obj;
sb.delete(0, sb.length());
sb.append(ext.getElementType().getNamespaceURI());
try {
BindingFactoryManager manager = bus.getExtension(BindingFactoryManager.class);
if (manager != null) {
factory = manager.getBindingFactory(sb.toString());
}
} catch (BusException e) {
// ignore, we'll use a generic BindingInfo
}
if (factory != null) {
break;
}
}
}
return factory;
}
use of org.apache.cxf.BusException in project cxf by apache.
the class JAXRSServerFactoryBean method create.
/**
* Creates the JAX-RS Server instance
* @return the server
*/
public Server create() {
ClassLoaderHolder origLoader = null;
try {
Bus bus = getBus();
ClassLoader loader = bus.getExtension(ClassLoader.class);
if (loader != null) {
origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
}
serviceFactory.setBus(bus);
checkResources(true);
if (serviceFactory.getService() == null) {
serviceFactory.create();
}
Endpoint ep = createEndpoint();
getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_SERVER_CREATE, server);
server = new ServerImpl(getBus(), ep, getDestinationFactory(), getBindingFactory());
Invoker invoker = serviceFactory.getInvoker();
if (invoker == null) {
ep.getService().setInvoker(createInvoker());
} else {
ep.getService().setInvoker(invoker);
}
ServerProviderFactory factory = setupFactory(ep);
ep.put(Application.class.getName(), appProvider);
factory.setRequestPreprocessor(new RequestPreprocessor(languageMappings, extensionMappings));
ep.put(Bus.class.getName(), getBus());
if (documentLocation != null) {
ep.put(JAXRSUtils.DOC_LOCATION, documentLocation);
}
if (rc != null) {
ep.put("org.apache.cxf.jaxrs.comparator", rc);
}
checkPrivateEndpoint(ep);
applyBusFeatures(getBus());
applyFeatures();
updateClassResourceProviders(ep);
injectContexts(factory);
factory.applyDynamicFeatures(getServiceFactory().getClassResourceInfo());
getServiceFactory().sendEvent(FactoryBeanListener.Event.SERVER_CREATED, server, null, null);
if (start) {
try {
server.start();
} catch (RuntimeException re) {
// prevent resource leak
server.destroy();
throw re;
}
}
} catch (EndpointException e) {
throw new ServiceConstructionException(e);
} catch (BusException e) {
throw new ServiceConstructionException(e);
} catch (IOException e) {
throw new ServiceConstructionException(e);
} catch (Exception e) {
throw new ServiceConstructionException(e);
} finally {
if (origLoader != null) {
origLoader.reset();
}
}
return server;
}
use of org.apache.cxf.BusException in project cxf by apache.
the class SoapTransportFactory method getConduit.
public Conduit getConduit(EndpointInfo ei, EndpointReferenceType target, Bus bus) throws IOException {
String address = target == null ? ei.getAddress() : target.getAddress().getValue();
BindingInfo bi = ei.getBinding();
String transId = ei.getTransportId();
if (bi instanceof SoapBindingInfo) {
transId = ((SoapBindingInfo) bi).getTransportURI();
if (transId == null) {
transId = ei.getTransportId();
}
}
ConduitInitiator conduitInit;
try {
ConduitInitiatorManager mgr = bus.getExtension(ConduitInitiatorManager.class);
if (StringUtils.isEmpty(address) || address.startsWith("http") || address.startsWith("jms") || address.startsWith("soap.udp")) {
conduitInit = mgr.getConduitInitiator(mapTransportURI(transId, address));
} else {
conduitInit = mgr.getConduitInitiatorForUri(address);
}
if (conduitInit == null) {
throw new RuntimeException(String.format(CANNOT_GET_CONDUIT_ERROR, address, transId));
}
return conduitInit.getConduit(ei, target, bus);
} catch (BusException e) {
throw new RuntimeException(String.format(CANNOT_GET_CONDUIT_ERROR, address, transId));
}
}
use of org.apache.cxf.BusException in project cxf by apache.
the class AbstractJAXRSFactoryBean method createBindingInfo.
protected BindingInfo createBindingInfo() {
BindingFactoryManager mgr = getBus().getExtension(BindingFactoryManager.class);
String binding = getBindingId();
BindingConfiguration bindingConfig = getBindingConfig();
if (binding == null && bindingConfig != null) {
binding = bindingConfig.getBindingId();
}
if (binding == null) {
binding = JAXRSBindingFactory.JAXRS_BINDING_ID;
}
try {
BindingFactory bindingFactory = mgr.getBindingFactory(binding);
setBindingFactory(bindingFactory);
BindingInfo bi = bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
for (BindingOperationInfo boi : bi.getOperations()) {
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, bi, boi, null);
}
serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, bi);
return bi;
} catch (BusException ex) {
ex.printStackTrace();
// do nothing
}
return null;
}
use of org.apache.cxf.BusException in project cxf by apache.
the class DummyBus method init.
public static Bus init(String[] args) throws BusException {
initializeCount++;
correctThreadContextClassLoader = Thread.currentThread().getContextClassLoader() == org.apache.cxf.jca.cxf.ManagedConnectionFactoryImpl.class.getClassLoader();
if (throwException) {
throw new BusException(new Message("tested bus exception!", (ResourceBundle) null, new Object[] {}));
}
return bus;
}
Aggregations