/** * Bound to the {@link WebAppContext} so that they can be used when bootstrapping. * * @param context */ @SuppressWarnings("unchecked") private void copyConfigurationPrimersIntoServletContext(final WebAppContext context) { final List<IsisConfigurationBuilderPrimer> isisConfigurationBuilderPrimers = (List<IsisConfigurationBuilderPrimer>) (List<?>) runner.getOptionHandlers(); context.setAttribute( WebAppConstants.CONFIGURATION_PRIMERS_KEY, isisConfigurationBuilderPrimers); }
/** ignores the arguments and just bootstraps JettyViewer, come what may. */ @Override public void bootstrap(final Injector injector) { final IsisConfigurationBuilder isisConfigurationBuilder = runner.getStartupConfiguration(); // we don't actually bootstrap the system here; instead we expect it to // be bootstrapped // from the ServletContextInitializer in the web.xml final IsisConfiguration configuration = isisConfigurationBuilder.getConfiguration(); final int port = configuration.getInteger(EMBEDDED_WEB_SERVER_PORT_KEY, EMBEDDED_WEB_SERVER_PORT_DEFAULT); final String webappContextPath = configuration.getString( EMBEDDED_WEB_SERVER_RESOURCE_BASE_KEY, EMBEDDED_WEB_SERVER_RESOURCE_BASE_DEFAULT); final StartupMode startupMode = StartupMode.lookup( configuration.getString( EMBEDDED_WEB_SERVER_STARTUP_MODE_KEY, EMBEDDED_WEB_SERVER_STARTUP_MODE_DEFAULT)); // TODO get and use the address jettyServer = new Server(port); Connector[] connectors = jettyServer.getConnectors(); Connector connector = connectors[0]; connector.setHeaderBufferSize(8192); final WebAppContext context = new WebAppContext(SRC_MAIN_WEBAPP, webappContextPath); copyConfigurationPrimersIntoServletContext(context); jettyServer.setHandler(context); LOG.info("starting Jetty on port " + port + " to serve webapp"); try { jettyServer.start(); if (startupMode.isForeground()) { jettyServer.join(); } } catch (final Exception ex) { throw new IsisException("Unable to start Jetty server", ex); } }