@Inject public TemplateEngineJsonP(ObjectMapper objectMapper, NinjaProperties properties) { this.objectMapper = objectMapper; this.callbackParameterName = properties.getWithDefault( NinjaConstant.NINJA_JSONP_CALLBACK_PARAMETER, DEFAULT_CALLBACK_PARAMETER_NAME); }
@Inject public BasicAuthFilter(Ninja ninja, NinjaProperties ninjaProperties, UsernamePasswordValidator validator) { this.ninja = ninja; this.credentialsValidator = validator; this.realm = ninjaProperties.getWithDefault( NinjaConstant.applicationName, "Ninja"); this.challenge = "Basic realm=\"" + realm + "\""; }
public String get(String key, String currentValue, String defaultValue) { // conf/application.conf OR fallback to default value String value = ninjaProperties.getWithDefault(key, defaultValue); // override with system property value = System.getProperty(key, value); // override with current value if (StringUtils.isNotEmpty(currentValue)) { value = currentValue; } return value; }
result.addHeader(HttpHeaderConstants.CACHE_CONTROL, "no-cache"); } else { String maxAge = ninjaProperties.getWithDefault(HTTP_CACHE_CONTROL, HTTP_CACHE_CONTROL_DEFAULT);
this.templateEngineFreemarkerAssetsAtMethod = templateEngineFreemarkerAssetsAtMethod; this.templateEngineFreemarkerWebJarsAtMethod = templateEngineFreemarkerWebJarsAtMethod; this.fileSuffix = ninjaProperties.getWithDefault(FREEMARKER_CONFIGURATION_FILE_SUFFIX, FILE_SUFFIX);
@Start(order = 90) public void startService() { if (ninjaProperties.getBooleanWithDefault("metrics.librato.enabled", false)) { final String hostname = metricsService.getHostname(); final String username = ninjaProperties .getOrDie("metrics.librato.username"); final String apiKey = ninjaProperties .getOrDie("metrics.librato.apikey"); final String period = ninjaProperties.getWithDefault( "metrics.librato.period", "60s"); final int delay = TimeUtil.parseDuration(period); LibratoReporter.enable(LibratoReporter.builder( metricsService.getMetricRegistry(), username, apiKey, hostname), delay, TimeUnit.SECONDS); log.info( "Started Librato Metrics reporter for '{}', updating every {}", hostname, period); } }
.render(message) .template( ninjaProperties.getWithDefault( NinjaConstant.LOCATION_VIEW_HTML_BAD_REQUEST_KEY, NinjaConstant.LOCATION_VIEW_FTL_HTML_BAD_REQUEST));
public void start() { String applicationName = ninjaProps.getWithDefault( NinjaConstant.applicationName, "Ninja");
.render(message) .template( ninjaProperties.getWithDefault( NinjaConstant.LOCATION_VIEW_HTML_FORBIDDEN_KEY, NinjaConstant.LOCATION_VIEW_FTL_HTML_FORBIDDEN));
.render(message) .template( ninjaProperties.getWithDefault( NinjaConstant.LOCATION_VIEW_HTML_NOT_FOUND_KEY, NinjaConstant.LOCATION_VIEW_FTL_HTML_NOT_FOUND));
.render(message) .template( ninjaProperties.getWithDefault( NinjaConstant.LOCATION_VIEW_HTML_UNAUTHORIZED_KEY, NinjaConstant.LOCATION_VIEW_FTL_HTML_UNAUTHORIZED));
.render(message) .template( ninjaProperties.getWithDefault( NinjaConstant.LOCATION_VIEW_HTML_INTERNAL_SERVER_ERROR_KEY, NinjaConstant.LOCATION_VIEW_FTL_HTML_INTERNAL_SERVER_ERROR));
@Start(order = 90) public void start() { if (ninjaProperties.getBooleanWithDefault("metrics.ganglia.enabled", false)) { final String hostname = metricsService.getHostname(); final String address = ninjaProperties .getOrDie("metrics.ganglia.address"); final int port = ninjaProperties.getIntegerWithDefault( "metrics.ganglia.port", 8649); final String period = ninjaProperties.getWithDefault( "metrics.ganglia.period", "60s"); final int delay = TimeUtil.parseDuration(period); try { GMetric ganglia = new GMetric(address, port, UDPAddressingMode.MULTICAST, 1); reporter = GangliaReporter .forRegistry(metricsService.getMetricRegistry()) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(ganglia); reporter.start(delay, TimeUnit.SECONDS); log.info( "Started Ganglia Metrics reporter for '{}', updating every {}", hostname, period); } catch (IOException e) { log.error("Failed to start Ganglia reporter!", e); } } }
final boolean isPickled = ninjaProperties.getBooleanWithDefault( "metrics.graphite.pickled", false); final String period = ninjaProperties.getWithDefault( "metrics.graphite.period", "60s"); final int delay = TimeUtil.parseDuration(period);
final String password = ninjaProperties .getOrDie("metrics.influxdb.password"); final String period = ninjaProperties.getWithDefault( "metrics.influxdb.period", "60s"); final int delay = TimeUtil.parseDuration(period);