use of org.apache.cxf.transport.http.AbstractHTTPDestination in project tomee by apache.
the class HttpUtils method getEndpointAddress.
public static String getEndpointAddress(Message m) {
String address;
Destination d = m.getExchange().getDestination();
if (d != null) {
if (d instanceof AbstractHTTPDestination) {
EndpointInfo ei = ((AbstractHTTPDestination) d).getEndpointInfo();
HttpServletRequest request = (HttpServletRequest) m.get(AbstractHTTPDestination.HTTP_REQUEST);
Object property = request != null ? request.getAttribute("org.apache.cxf.transport.endpoint.address") : null;
address = property != null ? property.toString() : ei.getAddress();
} else {
address = m.containsKey(Message.BASE_PATH) ? (String) m.get(Message.BASE_PATH) : d.getAddress().getAddress().getValue();
}
} else {
address = (String) m.get(Message.ENDPOINT_ADDRESS);
}
if (address.startsWith("http") && address.endsWith("//")) {
address = address.substring(0, address.length() - 1);
}
return address;
}
use of org.apache.cxf.transport.http.AbstractHTTPDestination in project cxf by apache.
the class NettyHttpTransportFactory method getDestination.
public Destination getDestination(EndpointInfo endpointInfo, Bus bus) throws IOException {
if (endpointInfo == null) {
throw new IllegalArgumentException("EndpointInfo cannot be null");
}
synchronized (registry) {
AbstractHTTPDestination d = registry.getDestinationForPath(endpointInfo.getAddress());
if (d == null) {
d = factory.createDestination(endpointInfo, bus, registry);
registry.addDestination(d);
configure(bus, d);
d.finalizeConfig();
}
return d;
}
}
use of org.apache.cxf.transport.http.AbstractHTTPDestination in project cxf by apache.
the class ServletController method invoke.
public boolean invoke(HttpServletRequest request, HttpServletResponse res, boolean returnErrors) throws ServletException {
try {
String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
AbstractHTTPDestination d = destinationRegistry.getDestinationForPath(pathInfo, true);
if (d == null) {
if (!isHideServiceList && (request.getRequestURI().endsWith(serviceListRelativePath) || request.getRequestURI().endsWith(serviceListRelativePath + "/") || StringUtils.isEmpty(pathInfo) || "/".equals(pathInfo))) {
if (isAuthServiceListPage) {
setAuthServiceListPageAttribute(request);
}
setBaseURLAttribute(request);
serviceListGenerator.service(request, res);
} else {
d = destinationRegistry.checkRestfulRequest(pathInfo);
if (d == null || d.getMessageObserver() == null) {
if (returnErrors) {
LOG.warning("Can't find the request for " + request.getRequestURL() + "'s Observer ");
generateNotFound(request, res);
}
return false;
}
}
}
if (d != null && d.getMessageObserver() != null) {
Bus bus = d.getBus();
ClassLoaderHolder orig = null;
try {
if (bus != null) {
ClassLoader loader = bus.getExtension(ClassLoader.class);
if (loader == null) {
ResourceManager manager = bus.getExtension(ResourceManager.class);
if (manager != null) {
loader = manager.resolveResource("", ClassLoader.class);
}
}
if (loader != null) {
// need to set the context classloader to the loader of the bundle
orig = ClassLoaderUtils.setThreadContextClassloader(loader);
}
}
updateDestination(request, d);
invokeDestination(request, res, d);
} finally {
if (orig != null) {
orig.reset();
}
}
}
} catch (IOException e) {
throw new ServletException(e);
}
return true;
}
use of org.apache.cxf.transport.http.AbstractHTTPDestination in project cxf by apache.
the class HttpUtils method getEndpointAddress.
public static String getEndpointAddress(Message m) {
String address;
Destination d = m.getExchange().getDestination();
if (d != null) {
if (d instanceof AbstractHTTPDestination) {
EndpointInfo ei = ((AbstractHTTPDestination) d).getEndpointInfo();
HttpServletRequest request = (HttpServletRequest) m.get(AbstractHTTPDestination.HTTP_REQUEST);
Object property = request != null ? request.getAttribute("org.apache.cxf.transport.endpoint.address") : null;
address = property != null ? property.toString() : ei.getAddress();
} else {
address = m.containsKey(Message.BASE_PATH) ? (String) m.get(Message.BASE_PATH) : d.getAddress().getAddress().getValue();
}
} else {
address = (String) m.get(Message.ENDPOINT_ADDRESS);
}
if (address.startsWith("http") && address.endsWith("//")) {
address = address.substring(0, address.length() - 1);
}
return address;
}
use of org.apache.cxf.transport.http.AbstractHTTPDestination in project cxf by apache.
the class WebSocketTransportFactory method getDestination.
/**
* {@inheritDoc}
*/
public Destination getDestination(EndpointInfo endpointInfo, Bus bus) throws IOException {
if (endpointInfo == null) {
throw new IllegalArgumentException("EndpointInfo cannot be null");
}
synchronized (registry) {
AbstractHTTPDestination d = registry.getDestinationForPath(endpointInfo.getAddress());
if (d == null) {
d = factory.createDestination(endpointInfo, bus, registry);
if (d == null) {
String error = "No destination available. The CXF websocket transport needs either the " + "Jetty WebSocket or Atmosphere dependencies to be available";
throw new IOException(error);
}
registry.addDestination(d);
configure(bus, d);
d.finalizeConfig();
}
return d;
}
}
Aggregations