@Override public void start() { pippoServlet = new PippoServlet(); pippoServlet.setApplication(getApplication()); Map<String, Object> arguments = new HashMap<>(); arguments.put(Serve.ARG_BINDADDRESS, getSettings().getHost()); arguments.put(Serve.ARG_PORT, getSettings().getPort()); String version = ""; URL pomUrl = Serve.class.getResource("/META-INF/maven/org.jboss.resteasy/tjws/pom.properties"); try (InputStream is = pomUrl.openStream()) { Properties props = new Properties(); props.load(is); version = props.getProperty("version"); } catch (IOException e) { log.error("Failed to read RESTEasy TJWS pom.properties!", e); } log.info("Starting RESTEasy TJWS Server {} on port {}", version, getSettings().getPort()); server = new Serve(arguments, System.err); server.addServlet("/", pippoServlet); server.runInBackground(); }
@Override public void stop() { if (server != null) { try { server.stopBackground(); // We must manually destroy PippoServlet because // TJWS does not destroy the root servlet. :( pippoServlet.destroy(); } catch (Exception e) { throw new PippoRuntimeException(e, "Cannot stop RESTEasy TJWS Server"); } } }
@Override public void init(ServletConfig servletConfig) { if (System.getProperty("pippo.hideLogo") == null) { log.info(PippoUtils.getPippoLogo()); } // check for runtime mode in filter init parameter String mode = servletConfig.getInitParameter(MODE_PARAM); if (!StringUtils.isNullOrEmpty(mode)) { System.setProperty(PippoConstants.SYSTEM_PROPERTY_PIPPO_MODE, mode); } if (application == null) { createApplication(servletConfig); log.debug("Created application '{}'", application); } ServletContext servletContext = servletConfig.getServletContext(); // save the servlet context object in application application.setServletContext(servletContext); // set the application as an attribute of the servlet container if (servletContext.getAttribute(WebServer.PIPPO_APPLICATION) == null) { servletContext.setAttribute(WebServer.PIPPO_APPLICATION, application); } String contextPath = StringUtils.addStart(servletContext.getContextPath(), "/"); application.getRouter().setContextPath(contextPath); log.debug("Serving application on context path '{}'", contextPath); log.debug("Initializing Route Dispatcher"); routeDispatcher = new RouteDispatcher(application); routeDispatcher.init(); String runtimeMode = application.getRuntimeMode().toString().toUpperCase(); log.info("Pippo started ({})", runtimeMode); }
Context context = tomcat.addContext(getSettings().getContextPath(), docBase.getAbsolutePath()); context.setAllowCasualMultipartParsing(true); PippoServlet pippoServlet = new PippoServlet(); pippoServlet.setApplication(getApplication());