javax.xml.ws.spi.http.HttpExchange Java Examples

The following examples show how to use javax.xml.ws.spi.http.HttpExchange. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PortableHttpHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void handleExchange(HttpExchange msg) throws IOException {
    WSHTTPConnection con = new PortableConnectionImpl(adapter,msg);
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        String method = msg.getRequestMethod();
        if(method.equals(GET_METHOD) || method.equals(POST_METHOD) || method.equals(HEAD_METHOD)
        || method.equals(PUT_METHOD) || method.equals(DELETE_METHOD)) {
            adapter.handle(con);
        } else {
            logger.warning(HttpserverMessages.UNEXPECTED_HTTP_METHOD(method));
        }
    } finally {
        msg.close();
    }
}
 
Example #2
Source File: PortableHttpHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by HttpServer when there is a matching request for the context
 */
@Override
public void handle(HttpExchange msg) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        if (executor != null) {
            // Use application's Executor to handle request. Application may
            // have set an executor using Endpoint.setExecutor().
            executor.execute(new HttpHandlerRunnable(msg));
        } else {
            handleExchange(msg);
        }
    } catch (Throwable e) {
        // Dont't propagate the exception otherwise it kills the httpserver
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example #3
Source File: PortableHttpHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void handleExchange(HttpExchange msg) throws IOException {
    WSHTTPConnection con = new PortableConnectionImpl(adapter,msg);
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        String method = msg.getRequestMethod();
        if(method.equals(GET_METHOD) || method.equals(POST_METHOD) || method.equals(HEAD_METHOD)
        || method.equals(PUT_METHOD) || method.equals(DELETE_METHOD)) {
            adapter.handle(con);
        } else {
            logger.warning(HttpserverMessages.UNEXPECTED_HTTP_METHOD(method));
        }
    } finally {
        msg.close();
    }
}
 
Example #4
Source File: PortableHttpHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by HttpServer when there is a matching request for the context
 */
@Override
public void handle(HttpExchange msg) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        if (executor != null) {
            // Use application's Executor to handle request. Application may
            // have set an executor using Endpoint.setExecutor().
            executor.execute(new HttpHandlerRunnable(msg));
        } else {
            handleExchange(msg);
        }
    } catch (Throwable e) {
        // Dont't propagate the exception otherwise it kills the httpserver
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example #5
Source File: PortableHttpHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void handleExchange(HttpExchange msg) throws IOException {
    WSHTTPConnection con = new PortableConnectionImpl(adapter,msg);
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        String method = msg.getRequestMethod();
        if(method.equals(GET_METHOD) || method.equals(POST_METHOD) || method.equals(HEAD_METHOD)
        || method.equals(PUT_METHOD) || method.equals(DELETE_METHOD)) {
            adapter.handle(con);
        } else {
            logger.warning(HttpserverMessages.UNEXPECTED_HTTP_METHOD(method));
        }
    } finally {
        msg.close();
    }
}
 
Example #6
Source File: PortableHttpHandler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by HttpServer when there is a matching request for the context
 */
@Override
public void handle(HttpExchange msg) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        if (executor != null) {
            // Use application's Executor to handle request. Application may
            // have set an executor using Endpoint.setExecutor().
            executor.execute(new HttpHandlerRunnable(msg));
        } else {
            handleExchange(msg);
        }
    } catch (Throwable e) {
        // Dont't propagate the exception otherwise it kills the httpserver
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example #7
Source File: PortableHttpHandler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void handleExchange(HttpExchange msg) throws IOException {
    WSHTTPConnection con = new PortableConnectionImpl(adapter,msg);
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        String method = msg.getRequestMethod();
        if(method.equals(GET_METHOD) || method.equals(POST_METHOD) || method.equals(HEAD_METHOD)
        || method.equals(PUT_METHOD) || method.equals(DELETE_METHOD)) {
            adapter.handle(con);
        } else {
            logger.warning(HttpserverMessages.UNEXPECTED_HTTP_METHOD(method));
        }
    } finally {
        msg.close();
    }
}
 
Example #8
Source File: PortableHttpHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void handleExchange(HttpExchange msg) throws IOException {
    WSHTTPConnection con = new PortableConnectionImpl(adapter,msg);
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        String method = msg.getRequestMethod();
        if(method.equals(GET_METHOD) || method.equals(POST_METHOD) || method.equals(HEAD_METHOD)
        || method.equals(PUT_METHOD) || method.equals(DELETE_METHOD)) {
            adapter.handle(con);
        } else {
            logger.warning(HttpserverMessages.UNEXPECTED_HTTP_METHOD(method));
        }
    } finally {
        msg.close();
    }
}
 
Example #9
Source File: PortableHttpHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by HttpServer when there is a matching request for the context
 */
@Override
public void handle(HttpExchange msg) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        if (executor != null) {
            // Use application's Executor to handle request. Application may
            // have set an executor using Endpoint.setExecutor().
            executor.execute(new HttpHandlerRunnable(msg));
        } else {
            handleExchange(msg);
        }
    } catch (Throwable e) {
        // Dont't propagate the exception otherwise it kills the httpserver
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example #10
Source File: PortableHttpHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by HttpServer when there is a matching request for the context
 */
@Override
public void handle(HttpExchange msg) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        if (executor != null) {
            // Use application's Executor to handle request. Application may
            // have set an executor using Endpoint.setExecutor().
            executor.execute(new HttpHandlerRunnable(msg));
        } else {
            handleExchange(msg);
        }
    } catch (Throwable e) {
        // Dont't propagate the exception otherwise it kills the httpserver
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example #11
Source File: PortableHttpHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by HttpServer when there is a matching request for the context
 */
@Override
public void handle(HttpExchange msg) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        if (executor != null) {
            // Use application's Executor to handle request. Application may
            // have set an executor using Endpoint.setExecutor().
            executor.execute(new HttpHandlerRunnable(msg));
        } else {
            handleExchange(msg);
        }
    } catch (Throwable e) {
        // Dont't propagate the exception otherwise it kills the httpserver
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example #12
Source File: PortableHttpHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void handleExchange(HttpExchange msg) throws IOException {
    WSHTTPConnection con = new PortableConnectionImpl(adapter,msg);
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        String method = msg.getRequestMethod();
        if(method.equals(GET_METHOD) || method.equals(POST_METHOD) || method.equals(HEAD_METHOD)
        || method.equals(PUT_METHOD) || method.equals(DELETE_METHOD)) {
            adapter.handle(con);
        } else {
            logger.warning(HttpserverMessages.UNEXPECTED_HTTP_METHOD(method));
        }
    } finally {
        msg.close();
    }
}
 
Example #13
Source File: PortableHttpHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by HttpServer when there is a matching request for the context
 */
@Override
public void handle(HttpExchange msg) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        if (executor != null) {
            // Use application's Executor to handle request. Application may
            // have set an executor using Endpoint.setExecutor().
            executor.execute(new HttpHandlerRunnable(msg));
        } else {
            handleExchange(msg);
        }
    } catch (Throwable e) {
        // Dont't propagate the exception otherwise it kills the httpserver
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example #14
Source File: PortableHttpHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void handleExchange(HttpExchange msg) throws IOException {
    WSHTTPConnection con = new PortableConnectionImpl(adapter,msg);
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        String method = msg.getRequestMethod();
        if(method.equals(GET_METHOD) || method.equals(POST_METHOD) || method.equals(HEAD_METHOD)
        || method.equals(PUT_METHOD) || method.equals(DELETE_METHOD)) {
            adapter.handle(con);
        } else {
            logger.warning(HttpserverMessages.UNEXPECTED_HTTP_METHOD(method));
        }
    } finally {
        msg.close();
    }
}
 
Example #15
Source File: PortableHttpHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void handleExchange(HttpExchange msg) throws IOException {
    WSHTTPConnection con = new PortableConnectionImpl(adapter,msg);
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        String method = msg.getRequestMethod();
        if(method.equals(GET_METHOD) || method.equals(POST_METHOD) || method.equals(HEAD_METHOD)
        || method.equals(PUT_METHOD) || method.equals(DELETE_METHOD)) {
            adapter.handle(con);
        } else {
            logger.warning(HttpserverMessages.UNEXPECTED_HTTP_METHOD(method));
        }
    } finally {
        msg.close();
    }
}
 
Example #16
Source File: PortableHttpHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by HttpServer when there is a matching request for the context
 */
@Override
public void handle(HttpExchange msg) {
    try {
        if (logger.isLoggable(Level.FINE)) {
            logger.log(Level.FINE, "Received HTTP request:{0}", msg.getRequestURI());
        }
        if (executor != null) {
            // Use application's Executor to handle request. Application may
            // have set an executor using Endpoint.setExecutor().
            executor.execute(new HttpHandlerRunnable(msg));
        } else {
            handleExchange(msg);
        }
    } catch (Throwable e) {
        // Dont't propagate the exception otherwise it kills the httpserver
        logger.log(Level.SEVERE, null, e);
    }
}
 
Example #17
Source File: JAXWSHttpSpiDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private HttpExchange setUpExchange() throws Exception {
    HttpExchange exchange = control.createMock(HttpExchange.class);
    expect(exchange.getHttpContext()).andReturn(context).anyTimes();
    expect(exchange.getQueryString()).andReturn(null);
    expect(exchange.getPathInfo()).andReturn(null);
    expect(exchange.getRequestURI()).andReturn(CONTEXT_PATH);
    expect(exchange.getContextPath()).andReturn(CONTEXT_PATH);
    Map<String, List<String>> reqHeaders = new HashMap<>();
    reqHeaders.put("Content-Type", Collections.singletonList("text/xml"));
    expect(exchange.getRequestHeaders()).andReturn(reqHeaders).anyTimes();
    OutputStream responseBody = control.createMock(OutputStream.class);
    responseBody.flush();
    EasyMock.expectLastCall();
    expect(exchange.getResponseBody()).andReturn(responseBody).anyTimes();
    observer.onMessage(isA(Message.class));
    EasyMock.expectLastCall();

    return exchange;
}
 
Example #18
Source File: HttpHandlerImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    destination = control.createMock(JAXWSHttpSpiDestination.class);
    handler = new HttpHandlerImpl(destination);
    exchange = control.createMock(HttpExchange.class);
}
 
Example #19
Source File: HttpHandlerImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(HttpExchange exchange) throws IOException {
    try {
        //Update address in EndpointInfo; this can only happen here,
        //as the contextPath is provided in the HttpExchange only
        EndpointInfo ei = destination.getEndpointInfo();
        if (ei != null) {
            String ad = ei.getAddress();
            String path = exchange.getHttpContext().getPath();
            if (ad != null && ad.equals(path)) {
                synchronized (ei) {
                    String contextPath = exchange.getContextPath();
                    ei.setAddress(contextPath + path);
                    if (ei.getExtensor(AddressType.class) != null) {
                        ei.getExtensor(AddressType.class).setLocation(contextPath + path);
                    } else if (ei.getExtensor(SoapAddress.class) != null) {
                        ei.getExtensor(SoapAddress.class).setLocationURI(contextPath + path);
                    }
                }
            }
        }
        //service request
        destination.doService(new HttpServletRequestAdapter(exchange),
                              new HttpServletResponseAdapter(exchange));
    } finally {
        exchange.close();
    }
}
 
Example #20
Source File: JAXWSHttpSpiDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testMessage() throws Exception {
    HttpExchange exchange = setUpExchange();
    control.replay();

    JAXWSHttpSpiDestination destination =
        new JAXWSHttpSpiDestination(bus, new DestinationRegistryImpl(), endpoint);
    destination.setMessageObserver(observer);

    destination.doService(new HttpServletRequestAdapter(exchange),
                          new HttpServletResponseAdapter(exchange));

    control.verify();
}
 
Example #21
Source File: PortableConnectionImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public PortableConnectionImpl(@NotNull HttpAdapter adapter, @NotNull HttpExchange httpExchange) {
    this.adapter = adapter;
    this.httpExchange = httpExchange;
}
 
Example #22
Source File: PortableConnectionImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public PortableConnectionImpl(@NotNull HttpAdapter adapter, @NotNull HttpExchange httpExchange) {
    this.adapter = adapter;
    this.httpExchange = httpExchange;
}
 
Example #23
Source File: PortableConnectionImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Property(JAXWSProperties.HTTP_EXCHANGE)
public HttpExchange getExchange() {
    return httpExchange;
}
 
Example #24
Source File: PortableHttpHandler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
HttpHandlerRunnable(HttpExchange msg) {
    this.msg = msg;
}
 
Example #25
Source File: HttpServletResponseAdapter.java    From cxf with Apache License 2.0 4 votes vote down vote up
HttpServletResponseAdapter(HttpExchange exchange) {
    this.exchange = exchange;
}
 
Example #26
Source File: HttpServletRequestAdapter.java    From cxf with Apache License 2.0 4 votes vote down vote up
HttpServletRequestAdapter(HttpExchange exchange) {
    this.exchange = exchange;
    this.context = exchange.getHttpContext();
}
 
Example #27
Source File: PortableConnectionImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public PortableConnectionImpl(@NotNull HttpAdapter adapter, @NotNull HttpExchange httpExchange) {
    this.adapter = adapter;
    this.httpExchange = httpExchange;
}
 
Example #28
Source File: PortableHttpHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
HttpHandlerRunnable(HttpExchange msg) {
    this.msg = msg;
}
 
Example #29
Source File: PortableConnectionImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Property(JAXWSProperties.HTTP_EXCHANGE)
public HttpExchange getExchange() {
    return httpExchange;
}
 
Example #30
Source File: PortableHttpHandler.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
HttpHandlerRunnable(HttpExchange msg) {
    this.msg = msg;
}