use of org.apache.cxf.transport.ConduitInitiator in project cxf by apache.
the class UndertowHTTPDestinationTest method setUpDestination.
private UndertowHTTPDestination setUpDestination(boolean contextMatchOnStem, boolean mockedBus) throws Exception {
policy = new HTTPServerPolicy();
address = getEPR("bar/foo");
transportFactory = new HTTPTransportFactory();
final ConduitInitiator ci = new ConduitInitiator() {
public Conduit getConduit(EndpointInfo targetInfo, Bus b) throws IOException {
return decoupledBackChannel;
}
public Conduit getConduit(EndpointInfo localInfo, EndpointReferenceType target, Bus b) throws IOException {
return decoupledBackChannel;
}
public List<String> getTransportIds() {
return null;
}
public Set<String> getUriPrefixes() {
return new HashSet<>(Collections.singletonList("http"));
}
};
ConduitInitiatorManager mgr = new ConduitInitiatorManager() {
public void deregisterConduitInitiator(String name) {
}
public ConduitInitiator getConduitInitiator(String name) throws BusException {
return null;
}
public ConduitInitiator getConduitInitiatorForUri(String uri) {
return ci;
}
public void registerConduitInitiator(String name, ConduitInitiator factory) {
}
};
if (!mockedBus) {
bus = new ExtensionManagerBus();
bus.setExtension(mgr, ConduitInitiatorManager.class);
} else {
bus = EasyMock.createMock(Bus.class);
bus.getExtension(EndpointResolverRegistry.class);
EasyMock.expectLastCall().andReturn(null);
bus.getExtension(ContinuationProviderFactory.class);
EasyMock.expectLastCall().andReturn(null).anyTimes();
bus.getExtension(PolicyDataEngine.class);
EasyMock.expectLastCall().andReturn(null).anyTimes();
bus.hasExtensionByName("org.apache.cxf.ws.policy.PolicyEngine");
EasyMock.expectLastCall().andReturn(false);
bus.getExtension(ClassLoader.class);
EasyMock.expectLastCall().andReturn(this.getClass().getClassLoader());
EasyMock.replay(bus);
}
engine = EasyMock.createNiceMock(UndertowHTTPServerEngine.class);
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setName(new QName("bla", "Service"));
endpointInfo = new EndpointInfo(serviceInfo, "");
endpointInfo.setName(new QName("bla", "Port"));
endpointInfo.setAddress(NOWHERE + "bar/foo");
endpointInfo.addExtensor(policy);
engine.addServant(EasyMock.eq(new URL(NOWHERE + "bar/foo")), EasyMock.isA(UndertowHTTPHandler.class));
EasyMock.expectLastCall();
engine.getContinuationsEnabled();
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(engine);
UndertowHTTPDestination dest = new EasyMockUndertowHTTPDestination(bus, transportFactory.getRegistry(), endpointInfo, null, engine);
dest.retrieveEngine();
policy = dest.getServer();
observer = new MessageObserver() {
public void onMessage(Message m) {
inMessage = m;
threadDefaultBus = BusFactory.getThreadDefaultBus();
}
};
dest.setMessageObserver(observer);
return dest;
}
use of org.apache.cxf.transport.ConduitInitiator in project cxf by apache.
the class TestUtilities method invokeBytes.
public byte[] invokeBytes(String address, String transport, String message) throws Exception {
EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
ei.setAddress(address);
ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport);
Conduit conduit = conduitInit.getConduit(ei, getBus());
TestMessageObserver obs = new TestMessageObserver();
conduit.setMessageObserver(obs);
Message m = new MessageImpl();
conduit.prepare(m);
OutputStream os = m.getContent(OutputStream.class);
InputStream is = getResourceAsStream(message);
if (is == null) {
throw new RuntimeException("Could not find resource " + message);
}
IOUtils.copy(is, os);
// TODO: shouldn't have to do this. IO caching needs cleaning
// up or possibly removal...
os.flush();
is.close();
os.close();
return obs.getResponseStream().toByteArray();
}
use of org.apache.cxf.transport.ConduitInitiator in project jbossws-cxf by jbossws.
the class SOAPConnectionImpl method getConduitInitiator.
private ConduitInitiator getConduitInitiator(String address) throws SOAPException {
ConduitInitiator ci = null;
try {
// do not use getThreadDefaultBus(true) in order to avoid getting the default bus
Bus bus = BusFactory.getThreadDefaultBus(false);
if (bus == null) {
bus = BusFactory.newInstance().createBus();
}
ConduitInitiatorManager mgr = bus.getExtension(ConduitInitiatorManager.class);
if (address.startsWith("http")) {
ci = mgr.getConduitInitiator("http://cxf.apache.org/transports/http");
}
if (ci == null) {
ci = mgr.getConduitInitiatorForUri(address);
}
} catch (Exception ex) {
throw MESSAGES.noConduitInitiatorAvailableFor2(address, ex);
}
if (ci == null) {
throw MESSAGES.noConduitInitiatorAvailableFor(address);
}
return ci;
}
use of org.apache.cxf.transport.ConduitInitiator in project jbossws-cxf by jbossws.
the class SOAPConnectionImpl method get.
@Override
public SOAPMessage get(Object addressObject) throws SOAPException {
checkClosed();
String address = getAddress(addressObject);
ConduitInitiator ci = getConduitInitiator(address);
// create a new Message and Exchange
EndpointInfo info = new EndpointInfo();
info.setAddress(address);
Message outMessage = new MessageImpl();
Exchange exch = new ExchangeImpl();
outMessage.setExchange(exch);
// sent GET request
try {
// TODO verify bus
final Conduit c = ci.getConduit(info, BusFactory.getThreadDefaultBus(false));
if (c instanceof HTTPConduit) {
((HTTPConduit) c).getClient().setAutoRedirect(true);
}
outMessage.put(Message.HTTP_REQUEST_METHOD, "GET");
c.prepare(outMessage);
c.setMessageObserver(createMessageObserver(c));
c.close(outMessage);
} catch (Exception ex) {
throw MESSAGES.getRequestCouldNotBeSent(ex);
}
// read SOAPMessage
return readSoapMessage(exch);
}
use of org.apache.cxf.transport.ConduitInitiator in project tomee by apache.
the class AbstractConduitSelector method getSelectedConduit.
/**
* 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;
}
Aggregations