private Tracer getTracer() { try { return new com.uber.jaeger.Configuration( getName(), new com.uber.jaeger.Configuration.SamplerConfiguration("const", 1), new com.uber.jaeger.Configuration.ReporterConfiguration( true, "tracing-jaeger-agent", 6831, 1000, // flush interval in milliseconds 10000) /*max buffered Spans*/) .getTracer(); } catch (Exception e) { e.printStackTrace(); return NoopTracerFactory.create(); } }
private Tracer getTracer() { try { return new com.uber.jaeger.Configuration( getName(), new com.uber.jaeger.Configuration.SamplerConfiguration("const", 1), // 100% new com.uber.jaeger.Configuration.ReporterConfiguration( true, "tracing-jaeger-agent", 6831, 1000, // flush interval in milliseconds 10000) /*max buffered Spans*/) .getTracer(); } catch (Exception e) { e.printStackTrace(); return NoopTracerFactory.create(); } }
@Override public void run(Configuration configuration, Environment environment) throws Exception { // Preparing Translation Service final TranslationService translationService = new TranslationService(); // Preparing Greeting Service and inject Translation final GreetingResource greetingService = new GreetingResource(translationService); // Register Greeting Service environment.jersey().register(greetingService); // Add Metrics Instrumentation to count requests final CollectorRegistry collectorRegistry = new CollectorRegistry(); collectorRegistry.register(new DropwizardExports(environment.metrics())); // Register Metrics Servlet environment.admin() .addServlet("metrics", new MetricsServlet(collectorRegistry)) .addMapping("/metrics"); }
@Override public void run(final Configuration configuration, final Environment environment) { environment.jersey().register(new RateLimitingFactoryProvider.Binder(requestRateLimiterFactory)); environment.jersey().register(new RateLimited429EnforcerFeature()); environment.lifecycle().manage(new Managed() { @Override public void start() { } @Override public void stop() throws Exception { requestRateLimiterFactory.close(); } }); }
@Test @SuppressWarnings("unchecked") public void registersACustomNameOfHealthCheckAndDBPoolMetrics() throws Exception { final HibernateBundle<Configuration> customBundle = new HibernateBundle<Configuration>(entities, factory) { @Override public DataSourceFactory getDataSourceFactory(Configuration configuration) { return dbConfig; } @Override protected String name() { return "custom-hibernate"; } }; when(factory.build(eq(customBundle), any(Environment.class), any(DataSourceFactory.class), anyList(), eq("custom-hibernate"))).thenReturn(sessionFactory); customBundle.run(configuration, environment); final ArgumentCaptor<SessionFactoryHealthCheck> captor = ArgumentCaptor.forClass(SessionFactoryHealthCheck.class); verify(healthChecks).register(eq("custom-hibernate"), captor.capture()); }
@Override public void run(final T config, final Environment environment) throws Exception { Module bootstrapModule = new AbstractModule() { @Override protected void configure() { install(new DropwizardModule()); if (mainModule != null) install(mainModule); bind(Configuration.class).toInstance(config); bind(configClass).toInstance(config); bind(Environment.class).toInstance(environment); } }; environment.servlets() // .addFilter("guice-request-scope", new GuiceFilter()) // .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); Guice.createInjector(bootstrapModule).getInstance(applicationClass).run(); }
@Override protected void configure() { // Initialize the BouncyCastle security provider for cryptography support. BouncyCastle.require(); bind(Clock.class).toInstance(Clock.systemUTC()); install(new CookieModule(config.getCookieKey())); install(new CryptoModule(config.getDerivationProviderClass(), config.getContentKeyStore())); bind(CookieConfig.class).annotatedWith(SessionCookie.class) .toInstance(config.getSessionCookieConfig()); bind(CookieConfig.class).annotatedWith(Xsrf.class) .toInstance(config.getXsrfCookieConfig()); // TODO(justin): Consider https://github.com/HubSpot/dropwizard-guice. bind(Environment.class).toInstance(environment); bind(Configuration.class).toInstance(config); bind(KeywhizConfig.class).toInstance(config); }
@Override public void initialize(Bootstrap<?> bootstrap) { final InjectableValues injectableValues = new InjectableValues() { @Override public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance) { return null; } }; final ConfigurationFactoryFactory<? extends Configuration> configurationFactoryFactory = bootstrap.getConfigurationFactoryFactory(); ConfigurationFactoryFactory factoryFactory = new ConfigurationFactoryFactory() { @Override public ConfigurationFactory create(Class klass, Validator validator, ObjectMapper objectMapper, String propertyPrefix) { objectMapper.setInjectableValues(injectableValues); //noinspection unchecked return configurationFactoryFactory.create(klass, validator, objectMapper, propertyPrefix); } }; //noinspection unchecked bootstrap.setConfigurationFactoryFactory(factoryFactory); }
@Override public DynamicAttributes build(Configuration configuration, Environment environment, List<String> scopes) { SqlSession sqlSession = SoaBundle.getFeatures(environment).getNamedRequired(SqlSession.class, sessionName); final SqlDynamicAttributes dynamicAttributes = new SqlDynamicAttributes(sqlSession, scopes); ScheduledExecutorService service = environment.lifecycle().scheduledExecutorService("SqlDynamicAttributes-%d", true).build(); Runnable command = new Runnable() { @Override public void run() { dynamicAttributes.update(); } }; service.scheduleAtFixedRate(command, refreshPeriodSeconds, refreshPeriodSeconds, TimeUnit.SECONDS); return dynamicAttributes; }
@Override public DynamicAttributes build(Configuration configuration, Environment environment, List<String> scopes) { DBI jdbi = SoaBundle.getFeatures(environment).getNamedRequired(DBI.class, name); final JdbiDynamicAttributes dynamicAttributes = new JdbiDynamicAttributes(jdbi, scopes); ScheduledExecutorService service = environment.lifecycle().scheduledExecutorService("JdbiDynamicAttributes-%d", true).build(); Runnable command = new Runnable() { @Override public void run() { dynamicAttributes.update(); } }; service.scheduleAtFixedRate(command, refreshPeriodSeconds, refreshPeriodSeconds, TimeUnit.SECONDS); return dynamicAttributes; }
@Override public void run(Configuration configuration, Environment environment) throws Exception { SoaConfiguration soaConfiguration = ComposedConfigurationAccessor.access(configuration, environment, SoaConfiguration.class); updateInstanceName(soaConfiguration); List<String> scopes = Lists.newArrayList(); scopes.add(soaConfiguration.getInstanceName()); scopes.add(soaConfiguration.getServiceName()); scopes.addAll(soaConfiguration.getScopes()); environment.getApplicationContext().setAttribute(DynamicAttributesBundle.Scopes.class.getName(), new Scopes(scopes)); // attributes must be allocated first - Discovery et al might need them DynamicAttributes attributes = StandardAttributesContainer.wrapAttributes(SoaBundle.checkManaged(environment, soaConfiguration.getAttributesFactory().build(configuration, environment, scopes)), SoaBundle.hasAdminKey); environment.getApplicationContext().setAttribute(DynamicAttributes.class.getName(), attributes); }
@Override protected void internalRun(Configuration configuration, Environment environment) { Metric metric = new Gauge<Integer>() { final Random random = new Random(); @Override public Integer getValue() { return random.nextInt(100); } }; environment.metrics().register("goodbye-random", metric); environment.jersey().register(GoodbyeResource.class); JerseyEnvironment adminJerseyEnvironment = SoaBundle.getFeatures(environment).getNamedRequired(JerseyEnvironment.class, SoaFeatures.ADMIN_NAME); adminJerseyEnvironment.register(GoodbyeAdminResource.class); }
@Test @SuppressWarnings("unchecked") public void testFindEntityClassesFromDirectory() { String packageWithEntities = "com.scottescue.dropwizard.entitymanager.entity.fake.entities.pckg"; ScanningEntityManagerBundle bundle = new ScanningEntityManagerBundle(packageWithEntities) { @Override public void run(Object o, Environment environment) throws Exception { } @Override public PooledDataSourceFactory getDataSourceFactory(Configuration configuration) { return null; } }; assertThat(bundle.getEntities()).containsOnly( FakeEntity1.class, DeepFakeEntity.class, DeeperFakeEntity.class); }
@Test @SuppressWarnings("unchecked") public void testFindEntityClassesFromMultipleDirectories() { String root = "com.scottescue.dropwizard.entitymanager.entity.fake.entities."; ScanningEntityManagerBundle bundle = new ScanningEntityManagerBundle( root.concat("pckg"), root.concat("pckg2"), root.concat("pckg3")) { @Override public void run(Object o, Environment environment) throws Exception { } @Override public PooledDataSourceFactory getDataSourceFactory(Configuration configuration) { return null; } }; assertThat(bundle.getEntities()).containsOnly( FakeEntity1.class, FakeEntity2.class, FakeEntity3.class, DeepFakeEntity.class, DeeperFakeEntity.class); }
@Test public void testRun() throws Exception { final CircuitBreakerBundle<Configuration> bundle = new CircuitBreakerBundle<Configuration>() { @Override protected CircuitBreakerConfiguration getConfiguration( final Configuration configuration) { final CircuitBreakerConfiguration circuitBreaker = new CircuitBreakerConfiguration(); circuitBreaker.setRateType(RateType.FIVE_MINUTES); circuitBreaker.setThreshold(0.5d); return circuitBreaker; } }; bundle.run(new Configuration(), this.environment); verify(this.jersey, times(1)) .register(any(CircuitBreakerApplicationEventListener.class)); final CircuitBreakerManager manager = bundle.getCircuitBreakerManager(); assertThat(manager.getRateType()).isEqualTo(RateType.FIVE_MINUTES); assertThat(manager.getDefaultThreshold()).isEqualTo(0.5d); }
@Override public void run(final Configuration config, final Environment environment) throws Exception { logger.error("------------------- application-run-1"); environment.healthChecks().register("dummy", new HealthCheck() { @Override protected Result check() throws Exception { return Result.healthy("dummy"); } }); //f ooEvent.fire(foo); environment.jersey().register(DummyResource.class); environment.getApplicationContext().addServlet(MyServlet.class, "/foo"); logger.error("------------------- application-run-2"); }
@Override public void run(Configuration configuration, Environment environment) throws InvalidKeySpecException, NoSuchAlgorithmException, ServletException, DeploymentException { environment.lifecycle().addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarted(LifeCycle event) { cdl.countDown(); } }); environment.jersey().register(new MyResource()); environment.healthChecks().register("alive", new HealthCheck() { @Override protected HealthCheck.Result check() throws Exception { return HealthCheck.Result.healthy(); } }); // Using ServerEndpointConfig lets you inject objects to the websocket endpoint: final ServerEndpointConfig config = ServerEndpointConfig.Builder.create(EchoServer.class, "/extends-ws").build(); // config.getUserProperties().put(Environment.class.getName(), environment); // Then you can get it from the Session object // - obj = session.getUserProperties().get("objectName"); websocketBundle.addEndpoint(config); }
/** * Bind configuration hierarchy: all superclasses and direct interfaces for each level (except interfaces * from java package). * * @param type configuration type */ @SuppressWarnings("unchecked") private void bindConfig(final Class type) { bind(type).toInstance(configuration); if (type == Configuration.class) { return; } if (context.option(BindConfigurationInterfaces)) { for (Class iface : type.getInterfaces()) { final String pkg = iface.getPackage().getName(); if (pkg.startsWith("java.") || pkg.startsWith("groovy.")) { continue; } bind(iface).toInstance(configuration); } } bindConfig(type.getSuperclass()); }
/** * Process initially registered and all transitive bundles. * <ul> * <li>Executing initial bundles (registered in {@link ru.vyarus.dropwizard.guice.GuiceBundle} * and by bundle lookup)</li> * <li>During execution bundles may register other bundles (through {@link GuiceyBootstrap})</li> * <li>Execute registered bundles and repeat from previous step until no new bundles registered</li> * </ul> * Bundles duplicates are checked by type: only one bundle instance may be registered. * * @param context bundles context * @param configuration configuration object * @param environment environment object * @param application application instance */ public static void processBundles(final ConfigurationContext context, final Configuration configuration, final Environment environment, final Application application) { final List<GuiceyBundle> bundles = context.getBundles(); final List<Class<? extends GuiceyBundle>> installedBundles = Lists.newArrayList(); final GuiceyBootstrap guiceyBootstrap = new GuiceyBootstrap( context, bundles, configuration, environment, application); // iterating while no new bundles registered while (!bundles.isEmpty()) { final List<GuiceyBundle> processingBundles = Lists.newArrayList(BundleSupport.removeDuplicates(bundles)); bundles.clear(); for (GuiceyBundle bundle : removeTypes(processingBundles, installedBundles)) { final Class<? extends GuiceyBundle> bundleType = bundle.getClass(); Preconditions.checkState(!installedBundles.contains(bundleType), "State error: duplicate bundle '%s' registration", bundleType.getName()); context.setScope(bundleType); bundle.initialize(guiceyBootstrap); installedBundles.add(bundleType); context.closeScope(); } } }
@Test public void useAllExceptionMappers() { final TenacityConfiguredBundle<Configuration> bundle = TenacityBundleBuilder .newBuilder() .configurationFactory(CONFIGURATION_FACTORY) .mapAllHystrixRuntimeExceptionsTo(429) .build(); assertThat(bundle) .isEqualTo(new TenacityConfiguredBundle<>( CONFIGURATION_FACTORY, Optional.empty(), ImmutableList.<ExceptionMapper<? extends Throwable>>of( new TenacityExceptionMapper(429), new TenacityContainerExceptionMapper(429)) )); }
@Test public void withExecutionMappers() throws Exception { final HystrixCommandExecutionHook hook = new ExceptionLoggingCommandHook(); final TenacityConfiguredBundle<Configuration> bundle = TenacityBundleBuilder .newBuilder() .configurationFactory(CONFIGURATION_FACTORY) .commandExecutionHook(hook) .build(); assertThat(bundle) .isEqualTo(new TenacityConfiguredBundle<>( CONFIGURATION_FACTORY, Optional.of(hook), Collections.<ExceptionMapper<? extends Throwable>>emptyList() )); }
@Test public void withTenacityCircuitBreakerHealthCheck() { final TenacityConfiguredBundle<Configuration> bundle = TenacityBundleBuilder .newBuilder() .configurationFactory(CONFIGURATION_FACTORY) .withCircuitBreakerHealthCheck() .build(); assertThat(bundle) .isEqualTo(new TenacityConfiguredBundle<>( CONFIGURATION_FACTORY, Optional.empty(), Collections.<ExceptionMapper<? extends Throwable>>emptyList(), true, false )); }
@Override public void run(Configuration configuration, Environment environment) throws Exception { registerFilters(environment); registerExceptionMappers(environment); registerHypermediaSupport(environment); registerResources(environment); }
public void run(Configuration configuration, Environment environment) { // Preparing Http Client final HttpClient httpClient = HttpClientBuilder.create().build(); // Dependency Injection final HelloTranslationClient translationClient = new HelloTranslationClient(httpClient); final HelloWorldResource resource = new HelloWorldResource(translationClient); // Register Hello World Resource environment.jersey().register(resource); }
@Override public void run(Configuration configuration, Environment environment) { // Instantiate Http Client final HttpClient httpClient = HttpClientBuilder.create().build(); // Dependency Injection final HelloWorldClient helloWorldClient = new HelloWorldClient(httpClient); final GreetingService greetingService = new GreetingService(helloWorldClient); // Register Greeting Service environment.jersey().register(greetingService); }
public void run(Configuration configuration, Environment environment) { // Dependency Injection final HelloTranslationRepository repository = new HelloTranslationRepository(); final HelloTranslationResource resource = new HelloTranslationResource(repository); // Register HTTP Resource environment.jersey().register(resource); }
public void run(Configuration configuration, Environment environment) throws Exception { final CollectorRegistry collectorRegistry = new CollectorRegistry(); collectorRegistry.register(new DropwizardExports(environment.metrics())); environment.admin() .addServlet("metrics", new MetricsServlet(collectorRegistry)) .addMapping("/metrics"); final PrometheusMetricsReporter reporter = PrometheusMetricsReporter.newMetricsReporter() .withCollectorRegistry(collectorRegistry) .withConstLabel("service", getName()) .build(); final Tracer tracer = getTracer(); final Tracer metricsTracer = io.opentracing.contrib.metrics.Metrics.decorate(tracer, reporter); GlobalTracer.register(metricsTracer); final DynamicFeature tracing = new ServerTracingDynamicFeature.Builder(metricsTracer).build(); environment.jersey().register(tracing); final HttpHost httpHost = new HttpHost("tweets-elasticsearch", 9200); final RestClientBuilder restClientBuilder = RestClient.builder(httpHost).setHttpClientConfigCallback(new TracingHttpClientConfigCallback(metricsTracer)); final RestClient restClient = restClientBuilder.build(); final RestHighLevelClient restHighLevelClient = new RestHighLevelClient(restClient); final TweetRepository tweetRepository = new ElasticsearchTweetRepository(restHighLevelClient); final TweetsResource tweetsResource = new TweetsResource(tweetRepository); environment.jersey().register(tweetsResource); }
public void run(Configuration configuration, Environment environment) throws Exception { final CollectorRegistry collectorRegistry = new CollectorRegistry(); collectorRegistry.register(new DropwizardExports(environment.metrics())); environment.admin() .addServlet("metrics", new MetricsServlet(collectorRegistry)) .addMapping("/metrics"); final PrometheusMetricsReporter reporter = PrometheusMetricsReporter.newMetricsReporter() .withCollectorRegistry(collectorRegistry) .withConstLabel("service", getName()) .build(); final Tracer tracer = getTracer(); final Tracer metricsTracer = io.opentracing.contrib.metrics.Metrics.decorate(tracer, reporter); GlobalTracer.register(metricsTracer); final DynamicFeature tracing = new ServerTracingDynamicFeature.Builder(metricsTracer).build(); environment.jersey().register(tracing); final Properties producerConfigs = new Properties(); producerConfigs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "tweets-kafka:9092"); producerConfigs.put(ProducerConfig.ACKS_CONFIG, "all"); producerConfigs.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, true); final KafkaProducer<Long, String> kafkaProducer = new KafkaProducer<>(producerConfigs, new LongSerializer(), new StringSerializer()); final Producer<Long, String> tracingKafkaProducer = new TracingKafkaProducer<>(kafkaProducer, metricsTracer); final ObjectMapper objectMapper = environment.getObjectMapper(); final TweetEventRepository tweetRepository = new KafkaTweetEventRepository(tracingKafkaProducer, objectMapper); final TweetsService tweetsService = new TweetsService(tweetRepository); final TweetsResource tweetsResource = new TweetsResource(tweetsService); environment.jersey().register(tweetsResource); }
public void run(Configuration configuration, Environment environment) throws Exception { // INSTRUMENTATION // Metrics Instrumentation final CollectorRegistry collectorRegistry = new CollectorRegistry(); collectorRegistry.register(new DropwizardExports(environment.metrics())); environment.admin() .addServlet("metrics", new MetricsServlet(collectorRegistry)) .addMapping("/metrics"); final PrometheusMetricsReporter reporter = PrometheusMetricsReporter.newMetricsReporter() .withCollectorRegistry(collectorRegistry) .withConstLabel("service", getName()) .build(); // Tracing Instrumentation final Tracer tracer = getTracer(); final Tracer metricsTracer = io.opentracing.contrib.metrics.Metrics.decorate(tracer, reporter); GlobalTracer.register(metricsTracer); final HttpHost httpHost = new HttpHost("tweets-elasticsearch", 9200); final RestClientBuilder restClientBuilder = RestClient.builder(httpHost).setHttpClientConfigCallback(new TracingHttpClientConfigCallback(metricsTracer)); final RestClient restClient = restClientBuilder.build(); final ElasticsearchTweetRepository elasticsearchRepository = new ElasticsearchTweetRepository(restClient); final Properties consumerConfigs = new Properties(); consumerConfigs.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "tweets-kafka:9092"); consumerConfigs.put(ConsumerConfig.GROUP_ID_CONFIG, getName()); consumerConfigs.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); consumerConfigs.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false); final KafkaConsumer<Long, String> kafkaConsumer = new KafkaConsumer<>(consumerConfigs, new LongDeserializer(), new StringDeserializer()); final TracingKafkaConsumer<Long, String> tracingKafkaConsumer = new TracingKafkaConsumer<>(kafkaConsumer, metricsTracer); final Runnable kafkaTweetEventConsumer = new KafkaTweetEventConsumer(tracingKafkaConsumer, elasticsearchRepository); final ExecutorService executorService = environment.lifecycle().executorService("kafka-consumer").build(); executorService.submit(kafkaTweetEventConsumer); }
public void run(Configuration configuration, Environment environment) { final CollectorRegistry collectorRegistry = new CollectorRegistry(); collectorRegistry.register(new DropwizardExports(environment.metrics())); final PrometheusMetricsReporter reporter = PrometheusMetricsReporter.newMetricsReporter() .withCollectorRegistry(collectorRegistry) .withConstLabel("service", getName()) .build(); final Tracer tracer = getTracer(); final Tracer metricsTracer = io.opentracing.contrib.metrics.Metrics.decorate(tracer, reporter); GlobalTracer.register(metricsTracer); final String jdbcUrl = "jdbc:tracing:postgresql://tweets-db/postgres"; final String jdbcUsername = "postgres"; final String jdbcPassword = "example"; final TweetsRepository tweetsRepository = new JooqPostgresTweetsRepository(jdbcUrl, jdbcUsername, jdbcPassword); final TweetsService tweetsService = new TweetsService(tweetsRepository); final TweetsResource tweetsResource = new TweetsResource(tweetsService); environment.jersey().register(tweetsResource); final DynamicFeature tracing = new ServerTracingDynamicFeature.Builder(metricsTracer).build(); environment.jersey().register(tracing); environment.admin() .addServlet("metrics", new MetricsServlet(collectorRegistry)) .addMapping("/metrics"); }
public void initialize(Bootstrap<Configuration> bootstrap) { redisClient = RedisClient.create("redis://localhost"); RequestRateLimiterFactory factory = new RedisRateLimiterFactory(redisClient); //RequestRateLimiterFactory factory = new InMemoryRateLimiterFactory(); bootstrap.addBundle(new RateLimitBundle(factory)); }
@Override public void run(Configuration configuration, Environment environment) { environment.jersey().register(new LoginResource()); environment.jersey().register(new UserResource()); environment.jersey().register(new AuthDynamicFeature( new OAuthCredentialAuthFilter.Builder<PrincipalImpl>() .setAuthenticator(new TestOAuthAuthenticator()).setPrefix("Bearer") .buildAuthFilter())); environment.jersey().register(RolesAllowedDynamicFeature.class); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(PrincipalImpl.class)); //TODO move this cleanup into the tests environment.lifecycle().manage(new Managed() { @Override public void start() { } @Override public void stop() { flushRedis(); } private void flushRedis() { try (StatefulRedisConnection<String, String> connection = redisClient.connect()) { connection.sync().flushdb(); } redisClient.shutdownAsync(); } }); }
@Override public void initialize(Bootstrap<Configuration> bootstrap) { bootstrap.addBundle(GuiceBundle.builder() .enableAutoConfig(getClass().getPackage().getName()) // bridge is required to inject guice service into hk managed sub resource .option(GuiceyOptions.UseHkBridge, true) // make sure service will not be created in both contexts (advanced validation for test) .strictScopeControl() .build()); }
@Override public void initialize(Bootstrap<Configuration> bootstrap) { bootstrap.addBundle(GuiceBundle.builder() .enableAutoConfig(getClass().getPackage().getName()) .useWebInstallers() .modules(new SampleModule()) .build()); }
@Override public void initialize(Bootstrap<Configuration> bootstrap) { bootstrap.addBundle(GuiceBundle.builder() // module is not required, but used here to show precise guice beans configuration .modules(new ManualModule()) // in manual mode extension classes must be declared explicitly to be recognized by installer and properly installed .extensions(SampleResource.class) .build()); }
@Override public void initialize(Bootstrap<Configuration> bootstrap) { bootstrap.addBundle(GuiceBundle.builder() .enableAutoConfig("ru.vyarus.dropwizard.guice.examples") // module is not required, but used here to show precise guice beans configuration .modules(new AutoscanModule()) .build()); }
@Override public void initialize(Bootstrap<Configuration> bootstrap) { bootstrap.addBundle(GuiceBundle.builder() .enableAutoConfig(getClass().getPackage().getName()) .bundles(new EventBusBundle()) .build()); }
@Override public void initialize(Bootstrap<Configuration> bootstrap) { bootstrap.addBundle(GuiceBundle.builder() .enableAutoConfig(getClass().getPackage().getName()) .modules( // register validation module, but with exclusion for rest resources (which are guice beans) // because dropwizard already applies validation support there new ImplicitValidationModule(bootstrap.getValidatorFactory()) .withMatcher(Matchers.not(Matchers.annotatedWith(Path.class))) ) .build()); }