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