Java Code Examples for org.apache.cxf.transport.DestinationFactory#getDestination()
The following examples show how to use
org.apache.cxf.transport.DestinationFactory#getDestination() .
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: 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 2
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 3
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 4
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 5
Source File: ServerImpl.java From cxf with Apache License 2.0 | 4 votes |
private void initDestination(DestinationFactory destinationFactory) throws BusException, IOException { EndpointInfo ei = endpoint.getEndpointInfo(); //Treat local transport as a special case, transports loaded by transportId can be replaced //by local transport when the publishing address is a local transport protocol. //Of course its not an ideal situation here to use a hard-coded prefix. To be refactored. if (destinationFactory == null) { if (ei.getAddress() != null && ei.getAddress().indexOf("local://") != -1) { destinationFactory = bus.getExtension(DestinationFactoryManager.class) .getDestinationFactoryForUri(ei.getAddress()); } if (destinationFactory == null) { destinationFactory = bus.getExtension(DestinationFactoryManager.class) .getDestinationFactory(ei.getTransportId()); } } destination = destinationFactory.getDestination(ei, bus); String wantFilter = ei.getAddress(); if (wantFilter != null && wantFilter.startsWith("jms")) { RegexLoggingFilter filter = new RegexLoggingFilter(); filter.setPattern("jms(.*?)password=+([^ ]+)"); filter.setGroup(2); wantFilter = filter.filter(wantFilter).toString(); } LOG.info("Setting the server's publish address to be " + wantFilter); serverRegistry = bus.getExtension(ServerRegistry.class); mep = new ManagedEndpoint(bus, endpoint, this); slcMgr = bus.getExtension(ServerLifeCycleManager.class); if (slcMgr != null) { slcMgr.registerListener(mep); } iMgr = bus.getExtension(InstrumentationManager.class); if (iMgr != null) { try { iMgr.register(mep); } catch (JMException jmex) { LOG.log(Level.WARNING, "Registering ManagedEndpoint failed.", jmex); } } }