Search in sources :

Example 6 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class EndpointImpl method createBinding.

final void createBinding(BindingInfo bi) throws EndpointException {
    if (null != bi) {
        String namespace = bi.getBindingId();
        BindingFactory bf = null;
        try {
            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);
        }
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) BusException(org.apache.cxf.BusException) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 7 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class SpringBusFactoryTest method testDefault.

@Test
public void testDefault() {
    Bus bus = new SpringBusFactory().createBus();
    assertNotNull(bus);
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    assertNotNull("No binding factory manager", bfm);
    assertNotNull("No configurer", bus.getExtension(Configurer.class));
    assertNotNull("No resource manager", bus.getExtension(ResourceManager.class));
    assertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.class));
    assertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.class));
    assertNotNull("No phase manager", bus.getExtension(PhaseManager.class));
    assertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.class));
    assertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.class));
    assertNotNull("No service registry", bus.getExtension(ServerRegistry.class));
    try {
        bfm.getBindingFactory("http://cxf.apache.org/unknown");
    } catch (BusException ex) {
    // expected
    }
    assertEquals("Unexpected interceptors", 0, bus.getInInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) PhaseManager(org.apache.cxf.phase.PhaseManager) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) ResourceManager(org.apache.cxf.resource.ResourceManager) Configurer(org.apache.cxf.configuration.Configurer) WorkQueueManager(org.apache.cxf.workqueue.WorkQueueManager) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 8 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class SoapTransportFactory method getDestination.

public Destination getDestination(EndpointInfo ei, Bus bus) throws IOException {
    String address = ei.getAddress();
    BindingInfo bi = ei.getBinding();
    String transId = ei.getTransportId();
    if (bi instanceof SoapBindingInfo) {
        transId = ((SoapBindingInfo) bi).getTransportURI();
        if (transId == null) {
            transId = ei.getTransportId();
        }
    }
    DestinationFactory destinationFactory;
    try {
        DestinationFactoryManager mgr = bus.getExtension(DestinationFactoryManager.class);
        if (StringUtils.isEmpty(address) || address.startsWith("http") || address.startsWith("jms") || address.startsWith("soap.udp") || address.startsWith("/")) {
            destinationFactory = mgr.getDestinationFactory(mapTransportURI(transId, address));
        } else {
            destinationFactory = mgr.getDestinationFactoryForUri(address);
        }
        if (destinationFactory == null) {
            throw new IOException("Could not find destination factory for transport " + transId);
        }
        return destinationFactory.getDestination(ei, bus);
    } catch (BusException e) {
        IOException ex = new IOException("Could not find destination factory for transport " + transId);
        ex.initCause(e);
        throw ex;
    }
}
Also used : DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) IOException(java.io.IOException) BusException(org.apache.cxf.BusException)

Example 9 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class ReflectionServiceFactoryBean method createEndpoints.

protected void createEndpoints() {
    Service service = getService();
    BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
    for (ServiceInfo inf : service.getServiceInfos()) {
        for (EndpointInfo ei : inf.getEndpoints()) {
            for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
                updateBindingOperation(boi);
            }
            try {
                bfm.getBindingFactory(ei.getBinding().getBindingId());
            } catch (BusException e1) {
                continue;
            }
            try {
                Endpoint ep = createEndpoint(ei);
                service.getEndpoints().put(ei.getName(), ep);
            } catch (EndpointException e) {
                throw new ServiceConstructionException(e);
            }
        }
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointException(org.apache.cxf.endpoint.EndpointException) Service(org.apache.cxf.service.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) BusException(org.apache.cxf.BusException)

Example 10 with BusException

use of org.apache.cxf.BusException in project cxf by apache.

the class EndpointImplTest method testEndpointServiceConstructor.

@Test
public void testEndpointServiceConstructor() throws Exception {
    GreeterImpl greeter = new GreeterImpl();
    JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setInvoker(new BeanInvoker(greeter));
    serviceFactory.setServiceClass(GreeterImpl.class);
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, new JaxWsServerFactoryBean(serviceFactory))) {
        WebServiceContext ctx = greeter.getContext();
        assertNull(ctx);
        try {
            String address = "http://localhost:8080/test";
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
        ctx = greeter.getContext();
        assertNotNull(ctx);
    }
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceContext(javax.xml.ws.WebServiceContext) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

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