private void preLoad(Runtime runtime) { int serverPort = app.config().getIntProperty("server.port", 8080); runtime.setServerUrl("http://localhost:" + serverPort + app.getContextPath()); }
@Override public void preAppStart(App app) throws Throwable { if (app.config().getBooleanProperty(Config.PROP_START, true)) { Engine engine = app.factory().getBean(Engine.class); engine.start(); } }
public void configure() { if(!endpoints.isEmpty()) { endpoints.forEach(r -> app.routes().remove(r)); } Map<String, Object> map = ConfigUtils.extractMap(app.config(), CONF_PREFIX); if(null == map || map.isEmpty()) { return; } config = Converts.convert(map, OAuth2ServerConfig.class); if(!config.isEnabled()) { return; } //clients config.getClients().forEach((id, c) -> { c.setId(id); validator.validate(CONF_PREFIX + ".clients." + id, c); }); //url int port = app.config().getIntProperty("server.port", 8080); String contextPath = app.config().getProperty("server.context-path", ""); this.url = (config.isSsl() ? "https:" : "http") + "://localhost:" + port + contextPath; //gen key pair if(null == keyPair) { keyPair = RSA.generateKeyPair(); signer = new RsaSigner(keyPair.getPrivateKey()); verifier = new RsaVerifier(keyPair.getPublicKey()); } //create endpoint createEndpoints(app.routes()); }
@Override public void onAppBooting(App app, ServletContext sc) throws Exception { if(!Classes.isPresent("org.h2.server.web.WebApp")) { log.info("H2 jar not found, db console disabled"); return; } H2ConsoleServlet.config = app.config(); ServletRegistration.Dynamic dynamic; try { dynamic = sc.addServlet("h2-console-servlet", H2ConsoleServlet.class); }catch (IllegalStateException e) { log.warn("Can't add h2-console-servlet, " + e.getMessage(), e); return; } app.ignoredPaths().add(path); dynamic.addMapping(path + "/*"); dynamic.setLoadOnStartup(1); SecurityConfigurator sec = app.factory().getBean(SecurityConfigurator.class); sec.ignore(path); sec.ignore(path + "/**/*"); }