@Override public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort()); dispatcher.service(request, response); } }
protected HttpRequest createHttpRequest(String httpMethod, HttpServletRequest request, ResteasyHttpHeaders headers, ResteasyUriInfo uriInfo, HttpResponse theResponse, HttpServletResponse response) { return new HttpServletInputMessage(request, response, getServletContext(), theResponse, headers, uriInfo, httpMethod.toUpperCase(), (SynchronousDispatcher) getDispatcher()); }
@Override protected void doStart(URL url) { // TODO jetty will by default enable keepAlive so the xml config has no effect now httpServer = httpBinder.bind(url, new RestHandler()); ServletContext servletContext = ServletManager.getInstance().getServletContext(url.getPort()); if (servletContext == null) { servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT); } if (servletContext == null) { throw new RpcException("No servlet context found. If you are using server='servlet', " + "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml"); } servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment); try { dispatcher.init(new SimpleServletConfig(servletContext)); } catch (ServletException e) { throw new RpcException(e); } }
protected HttpResponse createServletResponse(HttpServletResponse response) { return new HttpServletResponseWrapper(response, getDispatcher().getProviderFactory()); }
public void run() throws Exception { final Server server = new Server(port); // Setup the basic Application "context" at "/". // This is also known as the handler tree (in Jetty speak). final ServletContextHandler context = new ServletContextHandler(server, CONTEXT_ROOT); // Setup RESTEasy's HttpServletDispatcher at "/api/*". final ServletHolder restEasyServlet = new ServletHolder(new HttpServletDispatcher()); restEasyServlet.setInitParameter("resteasy.servlet.mapping.prefix", "/"); restEasyServlet.setInitParameter("javax.ws.rs.Application", "com.colobu.rest.jaxrs.MyApplication"); context.addServlet(restEasyServlet, "/rest/*"); // Setup the DefaultServlet at "/". final ServletHolder defaultServlet = new ServletHolder(new DefaultServlet()); context.addServlet(defaultServlet, CONTEXT_ROOT); server.setHandler(context); server.start(); server.join(); }
public HttpResponse createResteasyHttpResponse(HttpServletResponse response) { return createServletResponse(response); }
public HttpRequest createResteasyHttpRequest(String httpMethod, HttpServletRequest request, ResteasyHttpHeaders headers, ResteasyUriInfo uriInfo, HttpResponse theResponse, HttpServletResponse response) { return createHttpRequest(httpMethod, request, headers, uriInfo, theResponse, response); }
protected HttpRequest createHttpRequest(String httpMethod, HttpServletRequest request, HttpHeaders headers, UriInfoImpl uriInfo, HttpResponse theResponse, HttpServletResponse response) { return new HttpServletInputMessage(request, theResponse, headers, uriInfo, httpMethod.toUpperCase(), (SynchronousDispatcher) getDispatcher()); }
public static void main(String[] args) throws IOException { PcapServiceCli cli = new PcapServiceCli(args); cli.parse(); Server server = new Server(cli.getPort()); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); ServletHolder h = new ServletHolder(new HttpServletDispatcher()); h.setInitParameter("javax.ws.rs.Application", "com.opensoc.pcapservice.rest.JettyServiceRunner"); context.addServlet(h, "/*"); server.setHandler(context); try { server.start(); server.join(); } catch (Exception e) { e.printStackTrace(); } } }
public HttpResponse createResteasyHttpResponse(HttpServletResponse response) { return createServletResponse(response); }
public HttpRequest createResteasyHttpRequest(String httpMethod, HttpServletRequest request, ResteasyHttpHeaders headers, ResteasyUriInfo uriInfo, HttpResponse theResponse, HttpServletResponse response) { return createHttpRequest(httpMethod, request, headers, uriInfo, theResponse, response); }
@Override public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort()); dispatcher.service(request, response); } }
protected HttpResponse createServletResponse(HttpServletResponse response) { return new HttpServletResponseWrapper(response, getDispatcher().getProviderFactory()); }
Server server = new Server(); ServerConnector pContext = new ServerConnector(server); pContext.setPort(8080); pContext.setName("Public"); ServerConnector localConn = new ServerConnector(server); localConn.setPort(9090); localConn.setName("Local"); ServletContextHandler publicContext = new ServletContextHandler(ServletContextHandler.SESSIONS); publicContext.setContextPath("/"); ServletHolder sh = new ServletHolder(new HttpServletDispatcher()); sh.setInitParameter("javax.ws.rs.Application", "ServiceListPublic"); publicContext.addServlet(sh, "/*"); publicContext.setVirtualHosts(new String[]{"@Public"}); ServletContextHandler localContext = new ServletContextHandler(ServletContextHandler.SESSIONS); localContext .setContextPath("/"); ServletHolder shl = new ServletHolder(new HttpServletDispatcher()); shl.setInitParameter("javax.ws.rs.Application", "ServiceListLocal"); localContext.addServlet(shl, "/*"); localContext.setVirtualHosts(new String[]{"@Local"}); //see localConn.SetName HandlerCollection collection = new HandlerCollection(); collection.addHandler(publicContext); collection.addHandler(localContext); server.setHandler(collection); server.addConnector(pContext); server.addConnector(localContext);
@Override protected void doStart(URL url) { // TODO jetty will by default enable keepAlive so the xml config has no effect now httpServer = httpBinder.bind(url, new RestHandler()); ServletContext servletContext = ServletManager.getInstance().getServletContext(url.getPort()); if (servletContext == null) { servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT); } if (servletContext == null) { throw new RpcException("No servlet context found. If you are using server='servlet', " + "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml"); } servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment); try { dispatcher.init(new SimpleServletConfig(servletContext)); } catch (ServletException e) { throw new RpcException(e); } }
protected HttpRequest createHttpRequest(String httpMethod, HttpServletRequest request, ResteasyHttpHeaders headers, ResteasyUriInfo uriInfo, HttpResponse theResponse, HttpServletResponse response) { return new HttpServletInputMessage(request, response, getServletContext(), theResponse, headers, uriInfo, httpMethod.toUpperCase(), (SynchronousDispatcher) getDispatcher()); }
public HttpResponse createResteasyHttpResponse(HttpServletResponse response) { return createServletResponse(response); }
public HttpRequest createResteasyHttpRequest(String httpMethod, HttpServletRequest request, HttpHeaders headers, UriInfoImpl uriInfo, HttpResponse theResponse, HttpServletResponse response) { return createHttpRequest(httpMethod, request, headers, uriInfo, theResponse, response); }
@Override protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { service(httpServletRequest.getMethod(), httpServletRequest, httpServletResponse); }
protected HttpResponse createServletResponse(HttpServletResponse response) { return new HttpServletResponseWrapper(response, getDispatcher().getProviderFactory()); }