Search in sources :

Example 16 with BusException

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;
}
Also used : BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) BusException(org.apache.cxf.BusException) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 17 with BusException

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;
}
Also used : ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) Bus(org.apache.cxf.Bus) ClassLoaderHolder(org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) IOException(java.io.IOException) BusException(org.apache.cxf.BusException) IOException(java.io.IOException) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) EndpointException(org.apache.cxf.endpoint.EndpointException) RequestPreprocessor(org.apache.cxf.jaxrs.impl.RequestPreprocessor) Endpoint(org.apache.cxf.endpoint.Endpoint) ServerImpl(org.apache.cxf.endpoint.ServerImpl) Invoker(org.apache.cxf.service.invoker.Invoker) EndpointException(org.apache.cxf.endpoint.EndpointException) Application(javax.ws.rs.core.Application) BusException(org.apache.cxf.BusException)

Example 18 with BusException

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));
    }
}
Also used : BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) BusException(org.apache.cxf.BusException)

Example 19 with BusException

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;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) BusException(org.apache.cxf.BusException) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 20 with BusException

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;
}
Also used : Message(org.apache.cxf.common.i18n.Message) ResourceBundle(java.util.ResourceBundle) BusException(org.apache.cxf.BusException)

Aggregations

BusException (org.apache.cxf.BusException)28 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)7 Test (org.junit.Test)7 IOException (java.io.IOException)6 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)6 EndpointException (org.apache.cxf.endpoint.EndpointException)6 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)6 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)5 BindingInfo (org.apache.cxf.service.model.BindingInfo)5 Bus (org.apache.cxf.Bus)4 Message (org.apache.cxf.common.i18n.Message)4 ServiceConstructionException (org.apache.cxf.service.factory.ServiceConstructionException)4 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)4 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)4 DestinationFactory (org.apache.cxf.transport.DestinationFactory)4 WebServiceContext (javax.xml.ws.WebServiceContext)3 BindingFactory (org.apache.cxf.binding.BindingFactory)3 ClassLoaderHolder (org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder)3 Endpoint (org.apache.cxf.endpoint.Endpoint)3 GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)3