use of org.apache.cxf.transport.DestinationFactory in project cxf by apache.
the class AbstractWSDLBasedEndpointFactory method modifyTransportIdPerAddress.
private void modifyTransportIdPerAddress(EndpointInfo ei) {
// this is useful for local & camel transport
if (transportId == null && getAddress() != null) {
DestinationFactory df = getDestinationFactory();
if (df == null) {
DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
df = dfm.getDestinationFactoryForUri(getAddress());
}
if (df != null) {
transportId = df.getTransportIds().get(0);
} else {
// check conduits (the address could be supported on
// client only)
ConduitInitiatorManager cim = getBus().getExtension(ConduitInitiatorManager.class);
ConduitInitiator ci = cim.getConduitInitiatorForUri(getAddress());
if (ci != null) {
transportId = ci.getTransportIds().get(0);
}
}
}
if (transportId != null) {
ei.setTransportId(transportId);
}
}
use of org.apache.cxf.transport.DestinationFactory in project cxf by apache.
the class ServerFactoryBean method detectTransportIdFromAddress.
@Override
protected String detectTransportIdFromAddress(String ad) {
DestinationFactory df = getDestinationFactory();
if (df == null) {
DestinationFactoryManager dfm = getBus().getExtension(DestinationFactoryManager.class);
df = dfm.getDestinationFactoryForUri(getAddress());
if (df != null) {
return df.getTransportIds().get(0);
}
}
return null;
}
use of org.apache.cxf.transport.DestinationFactory in project cxf by apache.
the class MtomServerTest method servStatic.
/**
* 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();
}
}
});
}
use of org.apache.cxf.transport.DestinationFactory in project cxf by apache.
the class MtomServerTest method unregisterServStatic.
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);
}
use of org.apache.cxf.transport.DestinationFactory in project cxf by apache.
the class CXFNonSpringServlet method getDestinationRegistryFromBusOrDefault.
protected DestinationRegistry getDestinationRegistryFromBusOrDefault(final String transportId) {
DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
try {
String peferredTransportId = transportId;
// extension or customization).
if (StringUtils.isEmpty(peferredTransportId) && getBus() != null) {
peferredTransportId = (String) getBus().getProperty(AbstractTransportFactory.PREFERRED_TRANSPORT_ID);
}
if (StringUtils.isEmpty(peferredTransportId)) {
final Set<String> candidates = dfm.getRegisteredDestinationFactoryNames();
// consider other candidates
if (!candidates.contains(DEFAULT_TRANSPORT_ID)) {
peferredTransportId = candidates.stream().filter(name -> name.endsWith("/configuration")).findAny().orElse(DEFAULT_TRANSPORT_ID);
}
}
DestinationFactory df = StringUtils.isEmpty(peferredTransportId) ? dfm.getDestinationFactory(DEFAULT_TRANSPORT_ID) : dfm.getDestinationFactory(peferredTransportId);
if (df instanceof HTTPTransportFactory) {
HTTPTransportFactory transportFactory = (HTTPTransportFactory) df;
return transportFactory.getRegistry();
}
} catch (BusException e) {
// why are we throwing a busexception if the DF isn't found?
}
return null;
}
Aggregations