Java Code Examples for org.apache.cxf.transport.Destination#setMessageObserver()
The following examples show how to use
org.apache.cxf.transport.Destination#setMessageObserver() .
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: HolderTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testClient() throws Exception { EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http"); ei.setAddress(ADDRESS); Destination d = localTransport.getDestination(ei, bus); d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/holder/echoResponse.xml")); JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getClientFactoryBean().setServiceClass(HolderService.class); factory.getClientFactoryBean().setBus(getBus()); factory.getClientFactoryBean().setAddress(ADDRESS); HolderService h = (HolderService)factory.create(); Holder<String> holder = new Holder<>(); assertEquals("one", h.echo("one", "two", holder)); assertEquals("two", holder.value); }
Example 2
Source File: MAPAggregatorImpl.java From cxf with Apache License 2.0 | 6 votes |
/** * @param address the address * @return a Destination for the address */ private Destination getDestination(Bus bus, String address, Message message) throws IOException { Destination destination = null; DestinationFactoryManager factoryManager = bus.getExtension(DestinationFactoryManager.class); DestinationFactory factory = factoryManager.getDestinationFactoryForUri(address); if (factory != null) { Endpoint ep = message.getExchange().getEndpoint(); EndpointInfo ei = new EndpointInfo(); ei.setName(new QName(ep.getEndpointInfo().getName().getNamespaceURI(), ep.getEndpointInfo().getName().getLocalPart() + ".decoupled")); ei.setAddress(address); destination = factory.getDestination(ei, bus); Conduit conduit = ContextUtils.getConduit(null, message); if (conduit != null) { MessageObserver ob = conduit.getMessageObserver(); ob = new InterposedMessageObserver(bus, ob); destination.setMessageObserver(ob); } } return destination; }
Example 3
Source File: MtomServerTest.java From cxf with Apache License 2.0 | 5 votes |
private void unregisterServStatic(String add) throws Exception { Bus bus = getStaticBus(); DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); DestinationFactory df = dfm .getDestinationFactory("http://cxf.apache.org/transports/http/configuration"); EndpointInfo ei = new EndpointInfo(); ei.setAddress(add); Destination d = df.getDestination(ei, bus); d.setMessageObserver(null); }
Example 4
Source File: MAPAggregatorImpl.java From cxf with Apache License 2.0 | 5 votes |
public void clientDestroyed(Client client) { Destination dest = client.getEndpoint().getEndpointInfo() .getProperty(DECOUPLED_DESTINATION, Destination.class); if (dest != null) { dest.setMessageObserver(null); dest.shutdown(); } }
Example 5
Source File: MtomServerTest.java From cxf with Apache License 2.0 | 4 votes |
/** * Serve static file */ private void servStatic(final URL resource, final String add) throws Exception { Bus bus = getStaticBus(); DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); DestinationFactory df = dfm .getDestinationFactory("http://cxf.apache.org/transports/http/configuration"); EndpointInfo ei = new EndpointInfo(); ei.setAddress(add); Destination d = df.getDestination(ei, bus); d.setMessageObserver(new MessageObserver() { public void onMessage(Message message) { try { // HTTP seems to need this right now... ExchangeImpl ex = new ExchangeImpl(); ex.setInMessage(message); Conduit backChannel = message.getDestination().getBackChannel(message); MessageImpl res = new MessageImpl(); ex.setOutMessage(res); res.put(Message.CONTENT_TYPE, "text/xml"); backChannel.prepare(res); OutputStream out = res.getContent(OutputStream.class); InputStream is = resource.openStream(); IOUtils.copy(is, out, 2048); out.flush(); out.close(); is.close(); backChannel.close(res); } catch (Exception e) { e.printStackTrace(); } } }); }
Example 6
Source File: SoapBindingFactory.java From cxf with Apache License 2.0 | 4 votes |
@Override public synchronized void addListener(Destination d, Endpoint e) { synchronized (d) { MessageObserver mo = d.getMessageObserver(); if (d.getAddress() != null && d.getAddress().getAddress() != null && d.getAddress().getAddress().getValue() != null && d.getAddress().getAddress().getValue().startsWith("soap.udp")) { //soap.udp REQUIRES usage of WS-Addressing... we need to turn this on setupUDP(e, e.getEndpointInfo()); } if (mo == null) { super.addListener(d, e); return; } if (mo instanceof ChainInitiationObserver) { ChainInitiationObserver cio = (ChainInitiationObserver) mo; Binding b = e.getBinding(); Binding b2 = cio.getEndpoint().getBinding(); if (b == b2) { //re-registering the same endpoint? return; } Object o = cio.getEndpoint().get("allow-multiplex-endpoint"); if (o instanceof String) { o = Boolean.parseBoolean((String)o); } else if (o == null) { o = Boolean.FALSE; } if (b instanceof org.apache.cxf.binding.soap.SoapBinding && b2 instanceof org.apache.cxf.binding.soap.SoapBinding && ((org.apache.cxf.binding.soap.SoapBinding)b).getSoapVersion() .equals(((org.apache.cxf.binding.soap.SoapBinding)b2).getSoapVersion()) && Boolean.FALSE.equals(o)) { throw new RuntimeException("Soap " + ((org.apache.cxf.binding.soap.SoapBinding)b) .getSoapVersion().getVersion() + " endpoint already registered on address " + e.getEndpointInfo().getAddress()); } MultipleEndpointObserver newMO = new MultipleEndpointObserver(getBus()) { @Override protected Message createMessage(Message message) { return new SoapMessage(message); } }; newMO.getBindingInterceptors().add(new AttachmentInInterceptor()); newMO.getBindingInterceptors().add(new StaxInInterceptor()); // This will not work if one of the endpoints disables message // processing. But, if you've disabled message processing, you // probably aren't going to use this feature. newMO.getBindingInterceptors().add(new ReadHeadersInterceptor(getBus(), (SoapVersion)null)); newMO.getBindingInterceptors().add(new StartBodyInterceptor()); newMO.getBindingInterceptors().add(new CheckFaultInterceptor()); // Add in a default selection interceptor newMO.getRoutingInterceptors().add(new EndpointSelectionInterceptor()); newMO.getEndpoints().add(cio.getEndpoint()); mo = newMO; } if (mo instanceof MultipleEndpointObserver) { MultipleEndpointObserver meo = (MultipleEndpointObserver) mo; meo.getEndpoints().add(e); } d.setMessageObserver(mo); } }
Example 7
Source File: AbstractBindingFactory.java From cxf with Apache License 2.0 | 4 votes |
public void addListener(Destination d, Endpoint e) { ChainInitiationObserver observer = new ChainInitiationObserver(e, bus); d.setMessageObserver(observer); }