private static String _get(String key, Properties p) { String s = p.getProperty(key); E.invalidConfigurationIf(null == s, "cannot findBy '%s' setting in project layout properties", key); return s; } }
private static String _get(String key, Properties p) { String s = p.getProperty(key); E.invalidConfigurationIf(null == s, "cannot findBy '%s' setting in project layout properties", key); return s; } }
private void loadIntoPortMap(int port, App app) { App app0 = byPort.get(port); if (null != app0) { E.invalidConfigurationIf(!app.equals(app0), "Another application has already been deployed using port %s", port); } else { byPort.put(port, app); } }
private EbeanService getService(String dbId, DbServiceManager mgr) { DbService svc = mgr.dbService(dbId); E.invalidConfigurationIf(null == svc, "Cannot find db service by id: %s", dbId); E.invalidConfigurationIf(!(svc instanceof EbeanService), "The db service[%s|%s] is not ebean service", dbId, svc.getClass()); return $.cast(svc); }
private EbeanService getService(String dbId, DbServiceManager mgr) { DbService svc = mgr.dbService(dbId); E.invalidConfigurationIf(null == svc, "Cannot find db service by id: %s", dbId); E.invalidConfigurationIf(!(svc instanceof EbeanService), "The db service[%s|%s] is not ebean service", dbId, svc.getClass()); return $.cast(svc); }
private void loadIntoPortMap(int port, App app) { App app0 = byPort.get(port); if (null != app0) { E.invalidConfigurationIf(!app.equals(app0), "Another application has already been deployed using port %s", port); } else { byPort.put(port, app); } }
private static MorphiaService getService(String dbId, DbServiceManager mgr) { DbService svc = mgr.dbService(dbId); E.invalidConfigurationIf(null == svc, "Cannot find db service by id: %s", dbId); E.invalidConfigurationIf(!(svc instanceof MorphiaService), "The db service[%s|%s] is not morphia service", dbId, svc.getClass()); return $.cast(svc); } }
private EbeanService getService(String dbId, DbServiceManager mgr) { DbService svc = mgr.dbService(dbId); E.invalidConfigurationIf(null == svc, "Cannot find db service by id: %s", dbId); E.invalidConfigurationIf(!(svc instanceof EbeanService), "The db service[%s|%s] is not ebean service", dbId, svc.getClass()); return $.cast(svc); }
private boolean checkIgnoreRestParts(Node node, String nextPart) { boolean shouldIgnoreRests = S.eq(IGNORE_NOTATION, S.string(nextPart)); E.invalidConfigurationIf(node.ignoreRestParts() && !shouldIgnoreRests, "Bad route configuration: parts appended to route that ends with \"...\""); E.invalidConfigurationIf(shouldIgnoreRests && !node.children().isEmpty(), "Bad route configuration: \"...\" appended to node that has children"); node.ignoreRestParts(shouldIgnoreRests); return shouldIgnoreRests; }
private boolean checkIgnoreRestParts(Node node, String nextPart) { boolean shouldIgnoreRests = S.eq(IGNORE_NOTATION, S.string(nextPart)); E.invalidConfigurationIf(node.ignoreRestParts() && !shouldIgnoreRests, "Bad route configuration: parts appended to route that ends with \"...\""); E.invalidConfigurationIf(shouldIgnoreRests && !node.children().isEmpty(), "Bad route configuration: \"...\" appended to node that has children"); node.ignoreRestParts(shouldIgnoreRests); return shouldIgnoreRests; }
private void configureLoggingLevels(AppConfig config) { Map map = config.subSet("log.level"); map.putAll(config.subSet("act.log.level")); for (Object o : map.entrySet()) { Map.Entry<String, String> entry = $.cast(o); String key = entry.getKey(); if (key.startsWith("log.level")) { key = key.substring("log.level.".length()); } else { key = key.substring("act.log.level.".length()); } Logger.Level level = loggerLevelOf(entry.getValue()); E.invalidConfigurationIf(null == level, "Unknown log level: %s", entry.getValue()); Logger logger = LogManager.get(key); logger.setLevel(level); } }
private void configureLoggingLevels(AppConfig config) { Map map = config.subSet("log.level"); map.putAll(config.subSet("act.log.level")); for (Object o : map.entrySet()) { Map.Entry<String, String> entry = $.cast(o); String key = entry.getKey(); if (key.startsWith("log.level")) { key = key.substring("log.level.".length()); } else { key = key.substring("act.log.level.".length()); } Logger.Level level = loggerLevelOf(entry.getValue()); E.invalidConfigurationIf(null == level, "Unknown log level: %s", entry.getValue()); Logger logger = LogManager.get(key); logger.setLevel(level); } }
public JPADao() { DB db = modelType().getAnnotation(DB.class); String svcId = null == db ? DEFAULT : db.value(); DbServiceManager dbm = Act.app().dbServiceManager(); DbService dbService = dbm.dbService(svcId); E.invalidConfigurationIf(null == dbService, "cannot find db service by id: %s", svcId); E.unexpectedIfNot(dbService instanceof JPAService, "expected JPAService, found: " + dbService.getClass().getSimpleName()); setJPAService((JPAService) dbService); }
public void load(App app) { app.build(); app.refresh(); int port = app.config().httpPort(); E.invalidConfigurationIf(port < 0, "Invalid http.port configuration: %s", port); loadIntoPortMap(port, app); app.hook(); }
public void load(App app) { app.build(); app.refresh(); int port = app.config().httpPort(); E.invalidConfigurationIf(port < 0, "Invalid http.port configuration: %s", port); loadIntoPortMap(port, app); app.hook(); }
private static void registerSingleton(Class<?> cls) { E.invalidConfigurationIf(stopInheritedScope(cls), "@Stateful or @StopInheritedScope annotation cannot be apply on singleton or @Stateless annotated class"); Object instance = tryLoadAppService(cls); if (null != instance) { Act.app().registerSingleton(instance); } else if (null == cls.getAnnotation(Lazy.class)) { App.instance().registerSingletonClass(cls); if (LOGGER.isTraceEnabled()) { LOGGER.trace("register singleton: %s", cls); } } else if (LOGGER.isTraceEnabled()) { LOGGER.trace("skip lazy singleton registration for %s", cls); } }
public EbeanService(final String dbId, final App app, final Map<String, String> config) { super(dbId, app, config); String s = config.get("agentPackage"); String scanPackage = app().config().get(AppConfigKey.SCAN_PACKAGE, null); final String agentPackage = null == s ? scanPackage : S.string(s).trim(); E.invalidConfigurationIf(S.blank(agentPackage), "\"agentPackage\" not configured"); if (isTraceEnabled()) { trace("\"agentPackage\" configured: %s", agentPackage); } app.eventBus().bind(PRE_LOAD_CLASSES, new SysEventListenerBase(S.concat(dbId, "-ebean-pre-cl")) { @Override public void on(EventObject event) { String s = S.buffer("debug=").append(Act.isDev() ? "1" : "0") .append(";packages=") .append(agentPackage) .toString(); if (!EbeanAgentLoader.loadAgentFromClasspath("ebean-agent", s)) { warn("ebean-agent not found in classpath - not dynamically loaded"); } } }); }
public EbeanService(final String dbId, final App app, final Map<String, String> config) { super(dbId, app, config); String s = config.get("agentPackage"); String scanPackage = app().config().get(AppConfigKey.SCAN_PACKAGE, null); final String agentPackage = null == s ? scanPackage : S.string(s).trim(); E.invalidConfigurationIf(S.blank(agentPackage), "\"agentPackage\" not configured"); if (isTraceEnabled()) { trace("\"agentPackage\" configured: %s", agentPackage); } app.eventBus().bind(PRE_LOAD_CLASSES, new SysEventListenerBase(S.concat(dbId, "-ebean-pre-cl")) { @Override public void on(EventObject event) { String s = S.buffer("debug=").append(Act.isDev() ? "1" : "0") .append(";packages=") .append(agentPackage) .toString(); if (!EbeanAgentLoader.loadAgentFromClasspath("ebean-agent", s)) { warn("ebean-agent not found in classpath - not dynamically loaded"); } } }); }
public EbeanService(final String dbId, final App app, final Map<String, String> config) { super(dbId, app, config); String s = config.get("agentPackage"); final String agentPackage = null == s ? S.string(app().config().get(AppConfigKey.SCAN_PACKAGE, null)) : S.string(s).trim(); E.invalidConfigurationIf(S.blank(agentPackage), "\"agentPackage\" not configured"); if (isTraceEnabled()) { trace("\"agentPackage\" configured: %s", agentPackage); } app.eventBus().bind(PRE_LOAD_CLASSES, new SysEventListenerBase(S.concat(dbId, "-ebean-pre-cl")) { @Override public void on(EventObject event) { String s = S.buffer("debug=").append(Act.isDev() ? "1" : "0") .append(";packages=") .append(agentPackage) .toString(); if (!EbeanAgentLoader.loadAgentFromClasspath("ebean-agent", s)) { warn("ebean-agent not found in classpath - not dynamically loaded"); } } }); }
private static void registerSingleton(Class<?> cls) { E.invalidConfigurationIf(stopInheritedScope(cls), "@Stateful or @StopInheritedScope annotation cannot be apply on singleton or @Stateless annotated class"); Object instance = tryLoadAppService(cls); if (null != instance) { Act.app().registerSingleton(instance); } else if (null == cls.getAnnotation(Lazy.class)) { App.instance().registerSingletonClass(cls); if (LOGGER.isTraceEnabled()) { LOGGER.trace("register singleton: %s", cls); } } else if (LOGGER.isTraceEnabled()) { LOGGER.trace("skip lazy singleton registration for %s", cls); } }