@Override public String getWithDefault(String key, String defaultValue) { String value = get(key); if (value != null) { return value; } else { return defaultValue; } }
@Override public String getOrDie(String key) { String value = get(key); if (value == null) { logger.error(String.format(ERROR_KEY_NOT_FOUND, key)); throw new RuntimeException(String.format(ERROR_KEY_NOT_FOUND, key)); } else { return value; } }
public Bootstrap(NinjaPropertiesImpl ninjaProperties) { Preconditions.checkNotNull(ninjaProperties); this.ninjaProperties = ninjaProperties; this.modulesToLoad = new ArrayList<>(); // custom base package for application modules (e.g. com.example.conf.Routes) this.applicationModulesBasePackage = Optional.ofNullable(ninjaProperties.get( NinjaConstant.APPLICATION_MODULES_BASE_PACKAGE)); this.ninjaBaseDirectoryResolver = new NinjaBaseDirectoryResolver(ninjaProperties); }
@Override protected void doPostConfigure() throws Exception { // build configured urls this.serverUrls = createServerUrls(); this.baseUrls = createBaseUrls(); // is there at least one url? if (this.serverUrls == null || this.serverUrls.isEmpty()) { throw new IllegalStateException("All server ports were disabled." + " Check the 'ninja.port' property and possibly others depending your standalone."); } // save generated server name as ninja property if its not yet set String serverName = this.ninjaProperties.get(NinjaConstant.serverName); if (StringUtils.isEmpty(serverName)) { // grab the first one this.ninjaProperties.setProperty(NinjaConstant.serverName, getServerUrls().get(0)); } }