@Test public void buildsAVersionResource() throws Exception { application.run(config, environment); verify(jersey).register(isA(VersionResource.class)); }
@Override public void run(final SnowizardConfiguration config, final Environment environment) throws Exception { environment.jersey().register(new SnowizardExceptionMapper()); environment.jersey().register(new ProtocolBufferMessageBodyProvider()); if (config.isCORSEnabled()) { final FilterRegistration.Dynamic filter = environment.servlets() .addFilter("CrossOriginFilter", CrossOriginFilter.class); filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET"); } final IdWorker worker = new IdWorker(config.getWorkerId(), config.getDatacenterId(), 0L, config.validateUserAgent(), environment.metrics()); environment.metrics().register( MetricRegistry.name(SnowizardApplication.class, "worker_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getWorkerId(); } }); environment.metrics() .register( MetricRegistry.name(SnowizardApplication.class, "datacenter_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getDatacenterId(); } }); environment.healthChecks().register("empty", new EmptyHealthCheck()); environment.jersey().register(new IdResource(worker)); environment.jersey().register(new PingResource()); environment.jersey().register(new VersionResource()); }
SnowizardApplication extends Application<SnowizardConfiguration> { @Override public void run(final SnowizardConfiguration config, final Environment environment) throws Exception { environment.jersey().register(new SnowizardExceptionMapper()); environment.jersey().register(new ProtocolBufferMessageBodyProvider()); if (config.isCORSEnabled()) { final FilterRegistration.Dynamic filter = environment.servlets() .addFilter("CrossOriginFilter", CrossOriginFilter.class); filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET"); } final IdWorker worker = new IdWorker(config.getWorkerId(), config.getDatacenterId(), 0L, config.validateUserAgent(), environment.metrics()); environment.metrics().register( MetricRegistry.name(SnowizardApplication.class, "worker_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getWorkerId(); } }); environment.metrics() .register( MetricRegistry.name(SnowizardApplication.class, "datacenter_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getDatacenterId(); } }); environment.healthChecks().register("empty", new EmptyHealthCheck()); environment.jersey().register(new IdResource(worker)); environment.jersey().register(new PingResource()); environment.jersey().register(new VersionResource()); } }
SnowizardApplication extends Application<SnowizardConfiguration> { @Override public void run(final SnowizardConfiguration config, final Environment environment) throws Exception { environment.jersey().register(new SnowizardExceptionMapper()); environment.jersey().register(new ProtocolBufferMessageBodyProvider()); if (config.isCORSEnabled()) { final FilterRegistration.Dynamic filter = environment.servlets() .addFilter("CrossOriginFilter", CrossOriginFilter.class); filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET"); } final IdWorker worker = new IdWorker(config.getWorkerId(), config.getDatacenterId(), 0L, config.validateUserAgent(), environment.metrics()); environment.metrics().register( MetricRegistry.name(SnowizardApplication.class, "worker_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getWorkerId(); } }); environment.metrics() .register( MetricRegistry.name(SnowizardApplication.class, "datacenter_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getDatacenterId(); } }); environment.healthChecks().register("empty", new EmptyHealthCheck()); environment.jersey().register(new IdResource(worker)); environment.jersey().register(new PingResource()); environment.jersey().register(new VersionResource()); }  }
SnowizardApplication extends Application<SnowizardConfiguration> { @Override public void run(final SnowizardConfiguration config, final Environment environment) throws Exception { environment.jersey().register(new SnowizardExceptionMapper()); environment.jersey().register(new ProtocolBufferMessageBodyProvider()); if (config.isCORSEnabled()) { final FilterRegistration.Dynamic filter = environment.servlets() .addFilter("CrossOriginFilter", CrossOriginFilter.class); filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET"); } final IdWorker worker = new IdWorker(config.getWorkerId(), config.getDatacenterId(), 0L, config.validateUserAgent(), environment.metrics()); environment.metrics().register( MetricRegistry.name(SnowizardApplication.class, "worker_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getWorkerId(); } }); environment.metrics() .register( MetricRegistry.name(SnowizardApplication.class, "datacenter_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getDatacenterId(); } }); environment.healthChecks().register("empty", new EmptyHealthCheck()); environment.jersey().register(new IdResource(worker)); environment.jersey().register(new PingResource()); environment.jersey().register(new VersionResource()); }  static void main(final String[] args); @Override String getName(); @Override void initialize(final Bootstrap<SnowizardConfiguration> bootstrap); @Override void run(final SnowizardConfiguration config,
            final Environment environment); }
SnowizardApplication extends Application<SnowizardConfiguration> { @Override public void run(final SnowizardConfiguration config, final Environment environment) throws Exception { environment.jersey().register(new SnowizardExceptionMapper()); environment.jersey().register(new ProtocolBufferMessageBodyProvider()); if (config.isCORSEnabled()) { final FilterRegistration.Dynamic filter = environment.servlets() .addFilter("CrossOriginFilter", CrossOriginFilter.class); filter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET"); } final IdWorker worker = new IdWorker(config.getWorkerId(), config.getDatacenterId(), 0L, config.validateUserAgent(), environment.metrics()); environment.metrics().register( MetricRegistry.name(SnowizardApplication.class, "worker_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getWorkerId(); } }); environment.metrics() .register( MetricRegistry.name(SnowizardApplication.class, "datacenter_id"), new Gauge<Integer>() { @Override public Integer getValue() { return config.getDatacenterId(); } }); environment.healthChecks().register("empty", new EmptyHealthCheck()); environment.jersey().register(new IdResource(worker)); environment.jersey().register(new PingResource()); environment.jersey().register(new VersionResource()); }  static void main(final String[] args); @Override String getName(); @Override void initialize(final Bootstrap<SnowizardConfiguration> bootstrap); @Override void run(final SnowizardConfiguration config,
            final Environment environment);  }