Search in sources :

Example 11 with AbstractHTTPDestination

use of org.apache.cxf.transport.http.AbstractHTTPDestination in project BIMserver by opensourceBIM.

the class GenericWebServiceServlet method destroy.

public void destroy() {
    for (String path : destinationRegistry.getDestinationsPaths()) {
        // clean up the destination in case the destination itself can no
        // longer access the registry later
        AbstractHTTPDestination dest = destinationRegistry.getDestinationForPath(path);
        synchronized (dest) {
            destinationRegistry.removeDestination(path);
            dest.releaseRegistry();
        }
    }
    destinationRegistry = null;
    destroyBus();
}
Also used : AbstractHTTPDestination(org.apache.cxf.transport.http.AbstractHTTPDestination)

Example 12 with AbstractHTTPDestination

use of org.apache.cxf.transport.http.AbstractHTTPDestination in project jbossws-cxf by jbossws.

the class RequestHandlerImpl method findDestination.

/**
 * Finds destination based on request URI
 * @param requestURI to be recognized
 * @return destination associated with the request URI
 * @throws ServletException when destination wasn't found
 */
private AbstractHTTPDestination findDestination(HttpServletRequest req, Bus bus) throws ServletException {
    // Find destination based on request URI
    String requestURI = req.getRequestURI();
    DestinationRegistry destRegistry = getDestinationRegistryFromBus(bus);
    if (destRegistry == null) {
        throw Messages.MESSAGES.cannotObtainRegistry(DestinationRegistry.class.getName());
    }
    requestURI = pathPattern.matcher(requestURI).replaceAll("/");
    // first try looking up the destination in the registry map
    final AbstractHTTPDestination dest = destRegistry.getDestinationForPath(requestURI, true);
    if (dest != null) {
        return dest;
    }
    // if there's no direct match, iterate on the destinations to see if there's valid "catch-all" destination
    // (servlet-based endpoints, with "/*" url-pattern in web.xml)
    Collection<AbstractHTTPDestination> destinations = destRegistry.getDestinations();
    AbstractHTTPDestination returnValue = null;
    for (AbstractHTTPDestination destination : destinations) {
        String path = destination.getEndpointInfo().getAddress();
        try {
            path = new URL(path).getPath();
        } catch (MalformedURLException ex) {
            // ignore
            Logger.getLogger(RequestHandlerImpl.class).trace(ex);
        }
        if (path != null && requestURI.startsWith(path)) {
            returnValue = destination;
        }
    }
    if (returnValue == null)
        throw Messages.MESSAGES.cannotObtainDestinationFor(requestURI);
    return returnValue;
}
Also used : DestinationRegistry(org.apache.cxf.transport.http.DestinationRegistry) MalformedURLException(java.net.MalformedURLException) AbstractHTTPDestination(org.apache.cxf.transport.http.AbstractHTTPDestination) URL(java.net.URL)

Aggregations

AbstractHTTPDestination (org.apache.cxf.transport.http.AbstractHTTPDestination)12 IOException (java.io.IOException)4 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)3 ServletException (javax.servlet.ServletException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Bus (org.apache.cxf.Bus)2 Destination (org.apache.cxf.transport.Destination)2 Writer (java.io.Writer)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ServletConfig (javax.servlet.ServletConfig)1 HttpServletResponseWrapper (javax.servlet.http.HttpServletResponseWrapper)1 ClassLoaderHolder (org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder)1 ResourceManager (org.apache.cxf.resource.ResourceManager)1 DestinationRegistry (org.apache.cxf.transport.http.DestinationRegistry)1 Deployment (org.jboss.wsf.spi.deployment.Deployment)1 SOAPAddressRewriteMetadata (org.jboss.wsf.spi.metadata.config.SOAPAddressRewriteMetadata)1 Test (org.junit.Test)1