org.apache.cxf.BusException Java Examples
The following examples show how to use
org.apache.cxf.BusException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLServiceUtils.java From cxf with Apache License 2.0 | 6 votes |
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; }
Example #2
Source File: ClientFactoryBean.java From cxf with Apache License 2.0 | 6 votes |
public Client create() { getServiceFactory().reset(); if (getServiceFactory().getProperties() == null) { getServiceFactory().setProperties(properties); } else if (properties != null) { getServiceFactory().getProperties().putAll(properties); } Client client = null; Endpoint ep = null; try { ep = createEndpoint(); this.getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_CLIENT_CREATE, ep); applyProperties(ep); client = createClient(ep); initializeAnnotationInterceptors(ep, getServiceClass()); } catch (EndpointException | BusException e) { throw new ServiceConstructionException(e); } applyFeatures(client); this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep); return client; }
Example #3
Source File: CXFBusImplTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testConstructionWithExtensions() throws BusException { IMocksControl control; BindingFactoryManager bindingFactoryManager; InstrumentationManager instrumentationManager; PhaseManager phaseManager; control = EasyMock.createNiceControl(); Map<Class<?>, Object> extensions = new HashMap<>(); bindingFactoryManager = control.createMock(BindingFactoryManager.class); instrumentationManager = control.createMock(InstrumentationManager.class); phaseManager = control.createMock(PhaseManager.class); extensions.put(BindingFactoryManager.class, bindingFactoryManager); extensions.put(InstrumentationManager.class, instrumentationManager); extensions.put(PhaseManager.class, phaseManager); Bus bus = new ExtensionManagerBus(extensions); assertSame(bindingFactoryManager, bus.getExtension(BindingFactoryManager.class)); assertSame(instrumentationManager, bus.getExtension(InstrumentationManager.class)); assertSame(phaseManager, bus.getExtension(PhaseManager.class)); }
Example #4
Source File: SpringBusFactoryTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testKnownExtensions() throws BusException { Bus bus = new SpringBusFactory().createBus(); assertNotNull(bus); checkBindingExtensions(bus); DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); assertNotNull("No destination factory manager", dfm); ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class); assertNotNull("No conduit initiator manager", cim); checkTransportFactories(bus); checkOtherCoreExtensions(bus); //you should include instumentation extenstion to get the instrumentation manager assertNotNull("No instrumentation manager", bus.getExtension(InstrumentationManager.class)); bus.shutdown(true); }
Example #5
Source File: EndpointImplTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testJaxWsaFeature() throws Exception { HelloWsa greeter = new HelloWsa(); JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean(); serviceFactory.setBus(getBus()); serviceFactory.setInvoker(new BeanInvoker(greeter)); serviceFactory.setServiceClass(HelloWsa.class); try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, new JaxWsServerFactoryBean(serviceFactory))) { 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()); } assertEquals(1, serviceFactory.getFeatures().size()); assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature); } }
Example #6
Source File: EndpointImplTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testAddWSAFeature() 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))) { endpoint.getFeatures().add(new WSAddressingFeature()); 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()); } assertTrue(serviceFactory.getFeatures().size() == 1); assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature); } }
Example #7
Source File: EndpointImplTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testWSAnnoWithoutWSDLLocationInSEI() throws Exception { HelloImpl hello = new HelloImpl(); JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean(); serviceFactory.setBus(getBus()); serviceFactory.setInvoker(new BeanInvoker(hello)); serviceFactory.setServiceClass(HelloImpl.class); try (EndpointImpl endpoint = new EndpointImpl(getBus(), hello, new JaxWsServerFactoryBean(serviceFactory))) { 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()); } } }
Example #8
Source File: SpringBusFactoryTest.java From cxf with Apache License 2.0 | 6 votes |
private void checkHTTPTransportFactories(Bus bus) throws BusException { ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class); assertNotNull("No conduit initiator manager", cim); assertNotNull("conduit initiator not available", cim.getConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http")); assertNotNull("conduit initiator not available", cim.getConduitInitiator("http://schemas.xmlsoap.org/wsdl/http/")); assertNotNull("conduit initiator not available", cim.getConduitInitiator("http://cxf.apache.org/transports/http/configuration")); DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); assertNotNull("No destination factory manager", dfm); assertNotNull("destination factory not available", dfm.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/")); assertNotNull("destination factory not available", dfm.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http")); assertNotNull("destination factory not available", dfm.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/http/")); assertNotNull("destination factory not available", dfm.getDestinationFactory("http://cxf.apache.org/transports/http/configuration")); }
Example #9
Source File: EndpointImplTest.java From cxf with Apache License 2.0 | 6 votes |
@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); } }
Example #10
Source File: ConduitInitiatorManagerImpl.java From cxf with Apache License 2.0 | 6 votes |
/** * Returns the conduit initiator for the given namespace, constructing it * (and storing in the cache for future reference) if necessary, using its * list of factory classname to namespace mappings. * * @param namespace the namespace. */ public ConduitInitiator getConduitInitiator(String namespace) throws BusException { ConduitInitiator factory = conduitInitiators.get(namespace); if (factory == null && !failed.contains(namespace)) { factory = new TransportFinder<>(bus, conduitInitiators, loaded, ConduitInitiator.class) .findTransportForNamespace(namespace); } if (factory == null) { failed.add(namespace); throw new BusException(new Message("NO_CONDUIT_INITIATOR", BUNDLE, namespace)); } return factory; }
Example #11
Source File: BindingFactoryManagerImpl.java From cxf with Apache License 2.0 | 6 votes |
public BindingFactory getBindingFactory(final String namespace) throws BusException { BindingFactory factory = bindingFactories.get(namespace); if (null == factory) { if (!failed.contains(namespace)) { factory = loadActivationNamespace(namespace); if (factory == null) { factory = loadDefaultNamespace(namespace); } if (factory == null) { factory = loadAll(namespace); } } if (factory == null) { failed.add(namespace); throw new BusException(new Message("NO_BINDING_FACTORY_EXC", BUNDLE, namespace)); } } return factory; }
Example #12
Source File: DestinationFactoryManagerImpl.java From cxf with Apache License 2.0 | 6 votes |
/** * Returns the conduit initiator for the given namespace, constructing it * (and storing in the cache for future reference) if necessary, using its * list of factory classname to namespace mappings. * * @param namespace the namespace. */ @Override public DestinationFactory getDestinationFactory(String namespace) throws BusException { DestinationFactory factory = destinationFactories.get(namespace); if (factory == null && !failed.contains(namespace)) { factory = new TransportFinder<>(bus, destinationFactories, loaded, DestinationFactory.class) .findTransportForNamespace(namespace); } if (factory == null) { failed.add(namespace); throw new BusException(new Message("NO_DEST_FACTORY", BUNDLE, namespace)); } return factory; }
Example #13
Source File: EndpointImpl.java From cxf with Apache License 2.0 | 6 votes |
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); } } }
Example #14
Source File: STSUtils.java From cxf with Apache License 2.0 | 5 votes |
public static Endpoint createSTSEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy, QName epName) throws BusException, EndpointException { return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, epName, false); }
Example #15
Source File: STSUtils.java From steady with Apache License 2.0 | 5 votes |
public static Endpoint createSTSEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy, QName epName) throws BusException, EndpointException { return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, epName, false); }
Example #16
Source File: SchemaFirstXmlConfigTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected Bus createBus() throws BusException { ctx = new ClassPathXmlApplicationContext(new String[] { "classpath:org/apache/cxf/jaxws/schemaFirst.xml"}); return (Bus) ctx.getBean("cxf"); }
Example #17
Source File: SpringBusFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testLoadBusWithApplicationContext() throws BusException { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/systest/bus/basic.xml"}); Bus bus = ctx.getBean("cxf", Bus.class); ctx.refresh(); bus = ctx.getBean("cxf", Bus.class); checkBindingExtensions(bus); checkHTTPTransportFactories(bus); checkOtherCoreExtensions(bus); ctx.close(); }
Example #18
Source File: STSUtils.java From steady with Apache License 2.0 | 5 votes |
public static Endpoint createSCEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy) throws BusException, EndpointException { return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, null, true); }
Example #19
Source File: AbstractJAXRSFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
protected EndpointInfo createEndpointInfo(Service service) throws BusException { String transportId = getTransportId(); if (transportId == null && getAddress() != null) { DestinationFactory df = getDestinationFactory(); if (df == null) { DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class); df = dfm.getDestinationFactoryForUri(getAddress()); super.setDestinationFactory(df); } if (df != null) { transportId = df.getTransportIds().get(0); } } //default to http transport if (transportId == null) { transportId = "http://cxf.apache.org/transports/http"; } setTransportId(transportId); //EndpointInfo ei = new EndpointInfo(service.getServiceInfos().get(0), transportId); EndpointInfo ei = new EndpointInfo(); ei.setTransportId(transportId); ei.setName(serviceFactory.getService().getName()); ei.setAddress(getAddress()); BindingInfo bindingInfo = createBindingInfo(); ei.setBinding(bindingInfo); if (!StringUtils.isEmpty(publishedEndpointUrl)) { ei.setProperty("publishedEndpointUrl", publishedEndpointUrl); } ei.setName(service.getName()); serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei); return ei; }
Example #20
Source File: AbstractJAXRSFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
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; }
Example #21
Source File: EndpointImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testEndpointStop() throws Exception { String address = "http://localhost:8080/test"; GreeterImpl greeter = new GreeterImpl(); try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null)) { WebServiceContext ctx = greeter.getContext(); assertNull(ctx); try { 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); // Test that calling stop on the Endpoint works assertTrue(endpoint.isPublished()); endpoint.stop(); assertFalse(endpoint.isPublished()); // Test that the Endpoint cannot be restarted. try { endpoint.publish(address); fail("stopped endpoint restarted."); } catch (IllegalStateException e) { // expected. } } }
Example #22
Source File: STSUtils.java From cxf with Apache License 2.0 | 5 votes |
public static Endpoint createSCEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy) throws BusException, EndpointException { return createSTSEndpoint(bus, namespace, transportId, location, soapVersion, policy, null, true); }
Example #23
Source File: TestUtils.java From cxf with Apache License 2.0 | 5 votes |
public TestUtils() { bus = BusFactory.getDefaultBus(); BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class); try { factory = (CorbaBindingFactory)bfm.getBindingFactory( "http://cxf.apache.org/bindings/corba"); bfm.registerBindingFactory(CorbaConstants.NU_WSDL_CORBA, factory); } catch (BusException ex) { ex.printStackTrace(); } }
Example #24
Source File: SoapTransportFactory.java From cxf with Apache License 2.0 | 5 votes |
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; } }
Example #25
Source File: SoapTransportFactory.java From cxf with Apache License 2.0 | 5 votes |
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)); } }
Example #26
Source File: CXFBusImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testThreadBus() throws BusException { BusFactory.setDefaultBus(null); BusFactory.setThreadDefaultBus(null); Bus bus = BusFactory.newInstance().createBus(); Bus b2 = BusFactory.getThreadDefaultBus(false); assertSame(bus, b2); bus.shutdown(true); }
Example #27
Source File: ReflectionServiceFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
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); } } } }
Example #28
Source File: ServerImpl.java From cxf with Apache License 2.0 | 5 votes |
public ServerImpl(Bus bus, Endpoint endpoint, DestinationFactory destinationFactory, BindingFactory bindingFactory) throws BusException, IOException { this.endpoint = endpoint; this.bus = bus; this.bindingFactory = bindingFactory; initDestination(destinationFactory); }
Example #29
Source File: AbstractConduitSelector.java From cxf with Apache License 2.0 | 5 votes |
/** * Mechanics to actually get the Conduit from the ConduitInitiator * if necessary. * * @param message the current Message */ protected Conduit getSelectedConduit(Message message) { Conduit c = findCompatibleConduit(message); if (c == null) { Exchange exchange = message.getExchange(); EndpointInfo ei = endpoint.getEndpointInfo(); String transportID = ei.getTransportId(); try { ConduitInitiatorManager conduitInitiatorMgr = exchange.getBus() .getExtension(ConduitInitiatorManager.class); if (conduitInitiatorMgr != null) { ConduitInitiator conduitInitiator = conduitInitiatorMgr.getConduitInitiator(transportID); if (conduitInitiator != null) { c = createConduit(message, exchange, conduitInitiator); } else { getLogger().warning("ConduitInitiator not found: " + ei.getAddress()); } } else { getLogger().warning("ConduitInitiatorManager not found"); } } catch (BusException | IOException ex) { throw new Fault(ex); } } if (c != null && c.getTarget() != null && c.getTarget().getAddress() != null) { replaceEndpointAddressPropertyIfNeeded(message, c.getTarget().getAddress().getValue(), c); } //the search for the conduit could cause extra properties to be reset/loaded. message.resetContextCache(); message.put(Conduit.class, c); return c; }
Example #30
Source File: SpringBusFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@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()); }