@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); }
application.getRouter().setContextPath(contextPath);
@Override protected void setup() { String basePath = Strings.nullToEmpty(getSettings().getString(RestServlet.SETTING_URL, null)).trim(); serve(basePath + "/*").with(RestServlet.class); final PippoSettings pippoSettings = getPippoSettings(getSettings()); final Application application = new Application(pippoSettings); // must set context path before starting application application.getRouter().setContextPath(getSettings().getContextPath()); // must set application path before starting application String contextPath = application.getRouter().getContextPath(); String applicationPath = StringUtils.addEnd(contextPath, "/") + StringUtils.removeStart(basePath, "/"); application.getRouter().setApplicationPath(applicationPath); // start the application which sets up all initializers application.init(); bind(Application.class).toInstance(application); bind(Router.class).toInstance(application.getRouter()); bind(Messages.class).toInstance(application.getMessages()); bind(Languages.class).toInstance(application.getLanguages()); bind(MimeTypes.class).toInstance(application.getMimeTypes()); bind(ErrorHandler.class).toInstance(application.getErrorHandler()); bind(TemplateEngine.class).toInstance(application.getTemplateEngine()); bind(HttpCacheToolkit.class).toInstance(application.getHttpCacheToolkit()); bind(ContentTypeEngines.class).toInstance(application.getContentTypeEngines()); bind(RestService.class); }
@Override protected void setup() { String basePath = Strings.nullToEmpty(getSettings().getString(RestServlet.SETTING_URL, null)).trim(); serve(basePath + "/*").with(RestServlet.class); final PippoSettings pippoSettings = getPippoSettings(getSettings()); final Application application = new Application(pippoSettings); // must set context path before starting application application.getRouter().setContextPath(getSettings().getContextPath()); // must set application path before starting application String contextPath = application.getRouter().getContextPath(); String applicationPath = StringUtils.addEnd(contextPath, "/") + StringUtils.removeStart(basePath, "/"); application.getRouter().setApplicationPath(applicationPath); // start the application which sets up all initializers application.init(); bind(Application.class).toInstance(application); bind(Router.class).toInstance(application.getRouter()); bind(Messages.class).toInstance(application.getMessages()); bind(Languages.class).toInstance(application.getLanguages()); bind(MimeTypes.class).toInstance(application.getMimeTypes()); bind(ErrorHandler.class).toInstance(application.getErrorHandler()); bind(TemplateEngine.class).toInstance(application.getTemplateEngine()); bind(HttpCacheToolkit.class).toInstance(application.getHttpCacheToolkit()); bind(ContentTypeEngines.class).toInstance(application.getContentTypeEngines()); bind(RestService.class); }