use of org.apache.cxf.transport.DestinationFactory 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.transport.DestinationFactory in project cxf by apache.
the class ServiceImpl method createEndpointInfo.
private EndpointInfo createEndpointInfo(AbstractServiceFactoryBean serviceFactory, QName portName, PortInfoImpl portInfo) throws BusException {
EndpointInfo ei = null;
String address = portInfo.getAddress();
String bindingID = BindingID.getBindingID(portInfo.getBindingID());
DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
try {
// the bindingId might be the transportId, just attempt to
// load it to force the factory to load
dfm.getDestinationFactory(bindingID);
} catch (BusException ex) {
// ignore
}
DestinationFactory df = dfm.getDestinationFactoryForUri(address);
String transportId = null;
if (df != null && df.getTransportIds() != null && !df.getTransportIds().isEmpty()) {
transportId = df.getTransportIds().get(0);
} else {
transportId = bindingID;
}
Object config = null;
if (serviceFactory instanceof JaxWsServiceFactoryBean) {
config = new JaxWsSoapBindingConfiguration((JaxWsServiceFactoryBean) serviceFactory);
}
BindingInfo bindingInfo = bus.getExtension(BindingFactoryManager.class).getBindingFactory(bindingID).createBindingInfo(serviceFactory.getService(), bindingID, config);
Service service = serviceFactory.getService();
service.getServiceInfos().get(0).addBinding(bindingInfo);
ei = new EndpointInfo(service.getServiceInfos().get(0), transportId);
ei.setName(portName);
ei.setAddress(address);
ei.setBinding(bindingInfo);
service.getServiceInfos().get(0).addEndpoint(ei);
return ei;
}
use of org.apache.cxf.transport.DestinationFactory in project cxf by apache.
the class MAPAggregatorImpl method getDestination.
/**
* @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 = ((Observable) conduit).getMessageObserver();
ob = new InterposedMessageObserver(bus, ob);
destination.setMessageObserver(ob);
}
}
return destination;
}
use of org.apache.cxf.transport.DestinationFactory in project cxf by apache.
the class NettyHttpServerEngineFactoryTest method testTransportFactoryHasEngineFactory.
@Test
public void testTransportFactoryHasEngineFactory() throws Exception {
bus = BusFactory.getDefaultBus(true);
assertNotNull("Cannot get bus", bus);
// Make sure we got the Transport Factory.
DestinationFactoryManager destFM = bus.getExtension(DestinationFactoryManager.class);
assertNotNull("Cannot get DestinationFactoryManager", destFM);
DestinationFactory destF = destFM.getDestinationFactory("http://cxf.apache.org/transports/http");
assertNotNull("No DestinationFactory", destF);
assertTrue(HTTPTransportFactory.class.isInstance(destF));
NettyHttpServerEngineFactory factory = bus.getExtension(NettyHttpServerEngineFactory.class);
assertNotNull("EngineFactory is not configured.", factory);
}
use of org.apache.cxf.transport.DestinationFactory in project cxf by apache.
the class ApplicationContextTest method checkContext.
private void checkContext(TestApplicationContext ctx) throws Exception {
ConfigurerImpl cfg = new ConfigurerImpl(ctx);
EndpointInfo info = getEndpointInfo("bla", "Foo", "http://localhost:9000");
Bus bus = (Bus) ctx.getBean(Bus.DEFAULT_BUS_ID);
bus.setExtension(cfg, Configurer.class);
DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
DestinationFactory factory = dfm.getDestinationFactory("http://cxf.apache.org/transports/http");
Destination d = factory.getDestination(info, bus);
assertTrue(d instanceof UndertowHTTPDestination);
UndertowHTTPDestination jd = (UndertowHTTPDestination) d;
assertEquals("foobar", jd.getServer().getContentEncoding());
UndertowHTTPServerEngine engine = (UndertowHTTPServerEngine) jd.getEngine();
assertEquals(111, engine.getThreadingParameters().getMinThreads());
assertEquals(120, engine.getThreadingParameters().getMaxThreads());
ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
ConduitInitiator ci = cim.getConduitInitiator("http://cxf.apache.org/transports/http");
HTTPConduit conduit = (HTTPConduit) ci.getConduit(info, bus);
assertEquals(97, conduit.getClient().getConnectionTimeout());
info.setName(new QName("urn:test:ns", "Bar"));
conduit = (HTTPConduit) ci.getConduit(info, bus);
assertEquals(79, conduit.getClient().getConnectionTimeout());
UndertowHTTPDestination jd2 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
engine = (UndertowHTTPServerEngine) jd2.getEngine();
assertEquals(40000, engine.getMaxIdleTime());
assertEquals(99, engine.getThreadingParameters().getMinThreads());
assertEquals(777, engine.getThreadingParameters().getMaxThreads());
assertNotNull("The handlers should not be null", engine.getHandlers());
assertEquals(1, engine.getHandlers().size());
UndertowHTTPDestination jd3 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
engine = (UndertowHTTPServerEngine) jd3.getEngine();
assertEquals(111, engine.getThreadingParameters().getMinThreads());
assertEquals(120, engine.getThreadingParameters().getMaxThreads());
assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), true);
assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), true);
UndertowHTTPDestination jd4 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
engine = (UndertowHTTPServerEngine) jd4.getEngine();
assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), false);
assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), false);
UndertowHTTPDestination jd5 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "http://localhost:9100"), bus);
engine = (UndertowHTTPServerEngine) jd5.getEngine();
String r = "expected fallback thread parameters configured for port 0";
assertNotNull(r, engine.getThreadingParameters());
assertEquals(r, 21, engine.getThreadingParameters().getMinThreads());
assertEquals(r, 389, engine.getThreadingParameters().getMaxThreads());
}
Aggregations