use of org.apache.cxf.transport.ConduitInitiator in project cxf by apache.
the class ContextUtils method createDecoupledDestination.
public static Destination createDecoupledDestination(Exchange exchange, final EndpointReferenceType reference) {
final EndpointInfo ei = exchange.getEndpoint().getEndpointInfo();
return new Destination() {
public EndpointReferenceType getAddress() {
return reference;
}
public Conduit getBackChannel(Message inMessage) throws IOException {
Bus bus = inMessage.getExchange().getBus();
// this is a response targeting a decoupled endpoint. Treat it as a oneway so
// we don't wait for a response.
inMessage.getExchange().setOneWay(true);
ConduitInitiator conduitInitiator = bus.getExtension(ConduitInitiatorManager.class).getConduitInitiatorForUri(reference.getAddress().getValue());
if (conduitInitiator != null) {
Conduit c = conduitInitiator.getConduit(ei, reference, bus);
// ensure decoupled back channel input stream is closed
c.setMessageObserver(new MessageObserver() {
public void onMessage(Message m) {
InputStream is = m.getContent(InputStream.class);
if (is != null) {
try {
is.close();
} catch (Exception e) {
// ignore
}
}
}
});
return c;
}
return null;
}
public MessageObserver getMessageObserver() {
return null;
}
public void shutdown() {
}
public void setMessageObserver(MessageObserver observer) {
}
};
}
use of org.apache.cxf.transport.ConduitInitiator in project cxf by apache.
the class SoapTransportFactory method getConduit.
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));
}
}
use of org.apache.cxf.transport.ConduitInitiator in project cxf by apache.
the class ClientFactoryBean method detectTransportIdFromAddress.
@Override
protected String detectTransportIdFromAddress(String ad) {
ConduitInitiatorManager cim = getBus().getExtension(ConduitInitiatorManager.class);
ConduitInitiator ci = cim.getConduitInitiatorForUri(getAddress());
if (ci != null) {
return ci.getTransportIds().get(0);
}
return null;
}
use of org.apache.cxf.transport.ConduitInitiator 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 NettyHttpDestination);
NettyHttpDestination jd = (NettyHttpDestination) d;
assertEquals("foobar", jd.getServer().getContentEncoding());
NettyHttpServerEngine engine = (NettyHttpServerEngine) jd.getEngine();
assertEquals(120, engine.getThreadingParameters().getThreadPoolSize());
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());
NettyHttpDestination jd2 = (NettyHttpDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
engine = (NettyHttpServerEngine) jd2.getEngine();
assertEquals(40000, engine.getReadIdleTime());
assertEquals(10000, engine.getMaxChunkContentSize());
assertTrue("The engine should support session manager", engine.isSessionSupport());
NettyHttpDestination jd3 = (NettyHttpDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
engine = (NettyHttpServerEngine) jd3.getEngine();
assertTrue(engine.getTlsServerParameters().getClientAuthentication().isWant());
assertTrue(engine.getTlsServerParameters().getClientAuthentication().isRequired());
NettyHttpDestination jd4 = (NettyHttpDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
engine = (NettyHttpServerEngine) jd4.getEngine();
assertFalse(engine.getTlsServerParameters().getClientAuthentication().isWant());
assertFalse(engine.getTlsServerParameters().getClientAuthentication().isRequired());
/*NettyHttpDestination jd5 =
(NettyHttpDestination)factory.getDestination(
getEndpointInfo("sna", "foo", "http://localhost:9100"));*/
/*engine = (NettyHttpServerEngine)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());*/
}
use of org.apache.cxf.transport.ConduitInitiator 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 JettyHTTPDestination);
JettyHTTPDestination jd = (JettyHTTPDestination) d;
assertEquals("foobar", jd.getServer().getContentEncoding());
JettyHTTPServerEngine engine = (JettyHTTPServerEngine) jd.getEngine();
assertEquals(111, engine.getThreadingParameters().getMinThreads());
assertEquals(120, engine.getThreadingParameters().getMaxThreads());
assertEquals("TestPrefix", engine.getThreadingParameters().getThreadNamePrefix());
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());
JettyHTTPDestination jd2 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
engine = (JettyHTTPServerEngine) jd2.getEngine();
assertEquals(40000, engine.getMaxIdleTime());
assertFalse(engine.getSendServerVersion());
assertEquals(99, engine.getThreadingParameters().getMinThreads());
assertEquals(777, engine.getThreadingParameters().getMaxThreads());
assertEquals("AnotherPrefix", engine.getThreadingParameters().getThreadNamePrefix());
assertEquals("session timeout should be 600 secs", 600, engine.getSessionTimeout());
assertTrue("The engine should support session manager", engine.isSessionSupport());
assertNotNull("The handlers should not be null", engine.getHandlers());
assertEquals(1, engine.getHandlers().size());
JettyHTTPDestination jd3 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
engine = (JettyHTTPServerEngine) jd3.getEngine();
assertEquals(111, engine.getThreadingParameters().getMinThreads());
assertEquals(120, engine.getThreadingParameters().getMaxThreads());
assertEquals("TestPrefix", engine.getThreadingParameters().getThreadNamePrefix());
assertTrue(engine.getTlsServerParameters().getClientAuthentication().isWant());
assertTrue(engine.getTlsServerParameters().getClientAuthentication().isRequired());
JettyHTTPDestination jd4 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
engine = (JettyHTTPServerEngine) jd4.getEngine();
assertFalse(engine.getTlsServerParameters().getClientAuthentication().isWant());
assertFalse(engine.getTlsServerParameters().getClientAuthentication().isRequired());
JettyHTTPDestination jd5 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "http://localhost:9100"), bus);
engine = (JettyHTTPServerEngine) 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