Search in sources :

Example 1 with ServletRequestAdapter

use of org.apache.openejb.server.httpd.ServletRequestAdapter in project tomee by apache.

the class CXFJAXRSFilter method doFilter.

@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
    if (!HttpServletRequest.class.isInstance(request)) {
        chain.doFilter(request, response);
        return;
    }
    final HttpServletRequest httpServletRequest = HttpServletRequest.class.cast(request);
    final HttpServletResponse httpServletResponse = HttpServletResponse.class.cast(response);
    if (CxfRsHttpListener.TRY_STATIC_RESOURCES) {
        // else 100% JAXRS
        if (servletMappingIsUnderRestPath(httpServletRequest)) {
            chain.doFilter(request, response);
            return;
        }
        final InputStream staticContent = delegate.findStaticContent(httpServletRequest, welcomeFiles);
        if (staticContent != null) {
            chain.doFilter(request, response);
            return;
        }
    }
    try {
        delegate.doInvoke(new ServletRequestAdapter(httpServletRequest, httpServletResponse, request.getServletContext()), new ServletResponseAdapter(httpServletResponse));
    } catch (final Exception e) {
        throw new ServletException("Error processing webservice request", e);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletException(javax.servlet.ServletException) InputStream(java.io.InputStream) ServletRequestAdapter(org.apache.openejb.server.httpd.ServletRequestAdapter) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ServletResponseAdapter(org.apache.openejb.server.httpd.ServletResponseAdapter)

Example 2 with ServletRequestAdapter

use of org.apache.openejb.server.httpd.ServletRequestAdapter in project tomee by apache.

the class WsServlet method service.

public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
    HttpListener service = getService();
    if (service == null)
        throw new ServletException("WebServiceContainer has not been set");
    ServletEndpointContext context = getContext();
    endpointContext.set(new InvocationContext((HttpServletRequest) req));
    try {
        res.setContentType("text/xml");
        HttpRequest httpRequest = new ServletRequestAdapter((HttpServletRequest) req, (HttpServletResponse) res, config.getServletContext());
        HttpResponse httpResponse = new ServletResponseAdapter((HttpServletResponse) res);
        if (pojo != null) {
            req.setAttribute(WsConstants.POJO_INSTANCE, pojo);
        }
        try {
            service.onMessage(httpRequest, httpResponse);
        } catch (IOException | ServletException e) {
            throw e;
        } catch (Exception e) {
            throw new ServletException("Error processing webservice request", e);
        }
    } finally {
        endpointContext.set(context);
    }
}
Also used : ServletException(javax.servlet.ServletException) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpRequest(org.apache.openejb.server.httpd.HttpRequest) ServletEndpointContext(javax.xml.rpc.server.ServletEndpointContext) ServletRequestAdapter(org.apache.openejb.server.httpd.ServletRequestAdapter) HttpResponse(org.apache.openejb.server.httpd.HttpResponse) HttpListener(org.apache.openejb.server.httpd.HttpListener) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ServiceException(javax.xml.rpc.ServiceException) ServletResponseAdapter(org.apache.openejb.server.httpd.ServletResponseAdapter)

Example 3 with ServletRequestAdapter

use of org.apache.openejb.server.httpd.ServletRequestAdapter in project tomee by apache.

the class RsServlet method service.

public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    if (listener == null) {
        throw new ServletException("RESTServiceContainer has not been set");
    }
    HttpRequest httpRequest = new ServletRequestAdapter(req, res, servletConfig.getServletContext());
    HttpResponse httpResponse = new ServletResponseAdapter(res);
    try {
        listener.onMessage(httpRequest, httpResponse);
    } catch (IOException | ServletException e) {
        throw e;
    } catch (Exception e) {
        throw new ServletException("Error processing webservice request", e);
    }
}
Also used : ServletException(javax.servlet.ServletException) HttpRequest(org.apache.openejb.server.httpd.HttpRequest) ServletRequestAdapter(org.apache.openejb.server.httpd.ServletRequestAdapter) HttpResponse(org.apache.openejb.server.httpd.HttpResponse) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ServletResponseAdapter(org.apache.openejb.server.httpd.ServletResponseAdapter)

Aggregations

IOException (java.io.IOException)3 ServletException (javax.servlet.ServletException)3 ServletRequestAdapter (org.apache.openejb.server.httpd.ServletRequestAdapter)3 ServletResponseAdapter (org.apache.openejb.server.httpd.ServletResponseAdapter)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpRequest (org.apache.openejb.server.httpd.HttpRequest)2 HttpResponse (org.apache.openejb.server.httpd.HttpResponse)2 InputStream (java.io.InputStream)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ServiceException (javax.xml.rpc.ServiceException)1 ServletEndpointContext (javax.xml.rpc.server.ServletEndpointContext)1 HttpListener (org.apache.openejb.server.httpd.HttpListener)1