Java Code Examples for io.dropwizard.setup.Bootstrap#setConfigurationSourceProvider()
The following examples show how to use
io.dropwizard.setup.Bootstrap#setConfigurationSourceProvider() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimbuctooV4.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
@Override public void initialize(Bootstrap<TimbuctooConfiguration> bootstrap) { //bundles activeMqBundle = new ActiveMQBundle(); bootstrap.addBundle(activeMqBundle); bootstrap.addBundle(new MultiPartBundle()); bootstrap.addBundle(new AssetsBundle("/static", "/static", "index.html")); /* * Make it possible to use environment variables in the config. * see: http://www.dropwizard.io/0.9.1/docs/manual/core.html#environment-variables */ bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider( bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(true) )); }
Example 2
Source File: TranslationService.java From talk-kafka-zipkin with MIT License | 5 votes |
@Override public void initialize(Bootstrap<TranslationServiceConfiguration> bootstrap) { // Enable variable substitution with environment variables bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false))); }
Example 3
Source File: FoxtrotServer.java From foxtrot with Apache License 2.0 | 5 votes |
@Override public void initialize(Bootstrap<FoxtrotServerConfiguration> bootstrap) { bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false))); bootstrap.addBundle(new AssetsBundle("/console/echo/", "/", "browse-events.htm", "console")); bootstrap.addBundle(new OorBundle<FoxtrotServerConfiguration>() { public boolean withOor() { return false; } }); final SwaggerBundleConfiguration swaggerBundleConfiguration = getSwaggerBundleConfiguration(); bootstrap.addBundle(new SwaggerBundle<FoxtrotServerConfiguration>() { @Override protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(FoxtrotServerConfiguration configuration) { return swaggerBundleConfiguration; } }); bootstrap.addBundle(GuiceBundle.<FoxtrotServerConfiguration>builder() .enableAutoConfig("com.flipkart.foxtrot") .modules( new FoxtrotModule()) .useWebInstallers() .printDiagnosticInfo() .build(Stage.PRODUCTION)); bootstrap.addCommand(new InitializerCommand()); configureObjectMapper(bootstrap.getObjectMapper()); }
Example 4
Source File: ExampleAppBase.java From soabase with Apache License 2.0 | 5 votes |
public void initialize(Bootstrap<ExampleConfiguration> bootstrap) { bootstrap.setConfigurationSourceProvider(new FlexibleConfigurationSourceProvider()); bootstrap.addBundle(new CuratorBundle<>()); bootstrap.addBundle(new SqlBundle<>()); bootstrap.addBundle(new SoaBundle<>()); }
Example 5
Source File: BaragonService.java From Baragon with Apache License 2.0 | 5 votes |
@Override public void initialize(Bootstrap<T> bootstrap) { if (!Strings.isNullOrEmpty(System.getProperty(BARAGON_DEFAULT_CONFIG_LOCATION))) { bootstrap.setConfigurationSourceProvider( new MergingConfigProvider( bootstrap.getConfigurationSourceProvider(), System.getProperty(BARAGON_DEFAULT_CONFIG_LOCATION), bootstrap.getObjectMapper(), new YAMLFactory())); } final Iterable<? extends Module> additionalModules = checkNotNull(getGuiceModules(bootstrap), "getGuiceModules() returned null"); GuiceBundle<BaragonConfiguration> guiceBundle = GuiceBundle.defaultBuilder(BaragonConfiguration.class) .modules(new BaragonServiceModule()) .modules(new BaragonResourcesModule()) .modules(getObjectMapperModule()) .modules(additionalModules) .enableGuiceEnforcer(false) .stage(getGuiceStage()) .build(); bootstrap.addBundle(new CorsBundle()); bootstrap.addBundle(new BaragonAuthBundle()); bootstrap.addBundle(guiceBundle); bootstrap.addBundle(new ViewBundle<>()); bootstrap.addBundle(new AssetsBundle("/assets/static/", "/static/")); }
Example 6
Source File: DashboardApplication.java From SeaCloudsPlatform with Apache License 2.0 | 5 votes |
@Override public void initialize(Bootstrap<DashboardConfiguration> bootstrap) { // Setting configuration from env variables bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false) ) ); // Routing static assets files bootstrap.addBundle(new AssetsBundle("/webapp", "/", "index.html")); // Routing API documentation bootstrap.addBundle(new SwaggerBundle<DashboardConfiguration>() { @Override protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(DashboardConfiguration configuration) { SwaggerBundleConfiguration swaggerBundleConfiguration = configuration.getSwaggerBundleConfiguration(); swaggerBundleConfiguration.setTitle("SeaClouds REST API"); swaggerBundleConfiguration.setDescription("This API allows to manage all the project functionality"); swaggerBundleConfiguration.setResourcePackage("eu.seaclouds.platform.dashboard.rest"); swaggerBundleConfiguration.setContact("[email protected]"); swaggerBundleConfiguration.setLicense("Apache 2.0"); swaggerBundleConfiguration.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0"); return swaggerBundleConfiguration; } }); }
Example 7
Source File: ServerApplication.java From triplea with GNU General Public License v3.0 | 5 votes |
@Override public void initialize(final Bootstrap<AppConfig> bootstrap) { // This bootstrap will replace ${...} values in YML configuration with environment // variable values. Without it, all values in the YML configuration are treated as literals. bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider( bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false))); // From: https://www.dropwizard.io/0.7.1/docs/manual/jdbi.html // By adding the JdbiExceptionsBundle to your application, Dropwizard will automatically unwrap // ant thrown SQLException or DBIException instances. This is critical for debugging, since // otherwise only the common wrapper exception’s stack trace is logged. bootstrap.addBundle(new JdbiExceptionsBundle()); bootstrap.addBundle(new RateLimitBundle(new InMemoryRateLimiterFactory())); // Note, websocket endpoint is instantiated dynamically on every new connection and does // not allow for constructor injection. To inject objects, we use 'userProperties' of the // socket configuration that can then be retrieved from a websocket session. gameConnectionWebsocket = ServerEndpointConfig.Builder.create( GameConnectionWebSocket.class, WebsocketPaths.GAME_CONNECTIONS) .build(); playerConnectionWebsocket = ServerEndpointConfig.Builder.create( PlayerConnectionWebSocket.class, WebsocketPaths.PLAYER_CONNECTIONS) .build(); bootstrap.addBundle(new WebsocketBundle(gameConnectionWebsocket, playerConnectionWebsocket)); }
Example 8
Source File: Utils.java From dropwizard-grpc with Apache License 2.0 | 5 votes |
/** * Runs a command for the {@link TestApplication} with the given yaml configuration. * * @param yamlConfig a <code>String</code> containing the yaml configuration * @return the TestApplication if successful * @throws Exception if the command failed */ public static TestApplication runDropwizardCommandUsingConfig(final String yamlConfig, final Function<TestApplication, Command> commandInstantiator) throws Exception { final TestApplication application = new TestApplication(); final Bootstrap<TestConfiguration> bootstrap = new Bootstrap<>(application); bootstrap.setConfigurationSourceProvider(new StringConfigurationSourceProvider()); final Command command = commandInstantiator.apply(application); command.run(bootstrap, new Namespace(Collections.singletonMap("file", yamlConfig))); return application; }
Example 9
Source File: HelloWorldApplication.java From dropwizard-consul with Apache License 2.0 | 5 votes |
@Override public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) { bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider( bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false))); bootstrap.addBundle( new ConsulBundle<HelloWorldConfiguration>(getName(), false, true) { @Override public ConsulFactory getConsulFactory(HelloWorldConfiguration configuration) { return configuration.getConsulFactory(); } }); }
Example 10
Source File: MainDc.java From SeaCloudsPlatform with Apache License 2.0 | 5 votes |
@Override public void initialize(Bootstrap<DCConfiguration> bootstrap) { bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false) ) ); }
Example 11
Source File: Main.java From dcos-cassandra-service with Apache License 2.0 | 5 votes |
@Override public void initialize(Bootstrap<CassandraExecutorConfiguration> bootstrap) { super.initialize(bootstrap); bootstrap.addBundle(new Java8Bundle()); bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider( bootstrap.getConfigurationSourceProvider(), new StrSubstitutor( new EnvironmentVariableLookup(false)))); }
Example 12
Source File: Main.java From dcos-cassandra-service with Apache License 2.0 | 5 votes |
@Override public void initialize(Bootstrap<MutableSchedulerConfiguration> bootstrap) { super.initialize(bootstrap); StrSubstitutor strSubstitutor = new StrSubstitutor(new EnvironmentVariableLookup(false)); strSubstitutor.setEnableSubstitutionInVariables(true); bootstrap.addBundle(new Java8Bundle()); bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider( bootstrap.getConfigurationSourceProvider(), strSubstitutor)); }
Example 13
Source File: AbstractTrellisApplication.java From trellis with Apache License 2.0 | 5 votes |
@Override public void initialize(final Bootstrap<T> bootstrap) { // Allow configuration property substitution from environment variables bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false))); }
Example 14
Source File: VerifyServiceProviderApplication.java From verify-service-provider with MIT License | 5 votes |
@Override public void initialize(Bootstrap<VerifyServiceProviderConfiguration> bootstrap) { // Enable variable substitution with environment variables bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false) ) ); IdaSamlBootstrap.bootstrap(); bootstrap.getObjectMapper().setDateFormat(StdDateFormat.getInstance()); bootstrap.addBundle(hubMetadataBundle); bootstrap.addBundle(msaMetadataBundle); bootstrap.addCommand(new ComplianceToolMode(bootstrap.getObjectMapper(), bootstrap.getValidatorFactory().getValidator(), this)); bootstrap.addBundle(new LogstashBundle()); }
Example 15
Source File: ExampleApplication.java From okta-auth-java with Apache License 2.0 | 5 votes |
@Override public void initialize(Bootstrap<ExampleConfiguration> bootstrap) { // look up config yaml on the classpath bootstrap.setConfigurationSourceProvider(new ResourceConfigurationSourceProvider()); bootstrap.addBundle(new AssetsBundle("/assets", "/static", null)); bootstrap.addBundle(new ViewBundle<ExampleConfiguration>() { @Override public Map<String, Map<String, String>> getViewConfiguration(ExampleConfiguration config) { return config.getViews(); } }); }
Example 16
Source File: HelloService.java From talk-kafka-zipkin with MIT License | 5 votes |
@Override public void initialize(Bootstrap<HelloServiceConfiguration> bootstrap) { // Enable variable substitution with environment variables bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false))); }
Example 17
Source File: ConsulBundle.java From dropwizard-consul with Apache License 2.0 | 4 votes |
@Override public void initialize(Bootstrap<?> bootstrap) { // Replace variables with values from Consul KV. Please override // getConsulAgentHost() and getConsulAgentPort() if Consul is not // listening on the default localhost:8500. try { LOGGER.debug("Connecting to Consul at {}:{}", getConsulAgentHost(), getConsulAgentPort()); final Consul.Builder builder = Consul.builder() .withHostAndPort(HostAndPort.fromParts(getConsulAgentHost(), getConsulAgentPort())); getConsulAclToken() .ifPresent( token -> { // setting both ACL token here and with header, supplying an // auth header. This should cover both use cases: endpoint // supports legacy ?token query param and other case // in which endpoint requires an X-Consul-Token header. // @see https://www.consul.io/api/index.html#acls LOGGER.debug("Using Consul ACL token: {}", token); builder .withAclToken(token) .withHeaders(ImmutableMap.of(CONSUL_AUTH_HEADER_KEY, token)); }); // using Consul as a configuration substitution provider bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider( bootstrap.getConfigurationSourceProvider(), new ConsulSubstitutor(builder.build(), strict, substitutionInVariables))); } catch (ConsulException e) { LOGGER.warn( "Unable to query Consul running on {}:{}," + " disabling configuration substitution", getConsulAgentHost(), getConsulAgentPort(), e); } }
Example 18
Source File: SingularityService.java From Singularity with Apache License 2.0 | 4 votes |
@Override public void initialize(final Bootstrap<T> bootstrap) { if ( !Strings.isNullOrEmpty( System.getProperty(SINGULARITY_DEFAULT_CONFIGURATION_PROPERTY) ) ) { bootstrap.setConfigurationSourceProvider( new MergingSourceProvider( bootstrap.getConfigurationSourceProvider(), System.getProperty(SINGULARITY_DEFAULT_CONFIGURATION_PROPERTY), bootstrap.getObjectMapper(), new YAMLFactory() ) ); } final Iterable<? extends Module> additionalModules = checkNotNull( getGuiceModules(bootstrap), "getGuiceModules() returned null" ); final Iterable<? extends Bundle> additionalBundles = checkNotNull( getDropwizardBundles(bootstrap), "getDropwizardBundles() returned null" ); final Iterable<? extends ConfiguredBundle<T>> additionalConfiguredBundles = checkNotNull( getDropwizardConfiguredBundles(bootstrap), "getDropwizardConfiguredBundles() returned null" ); guiceBundle = GuiceBundle .defaultBuilder(SingularityConfiguration.class) .modules(getServiceModule(), getObjectMapperModule(), new SingularityAuthModule()) .modules(additionalModules) .enableGuiceEnforcer(false) .stage(getGuiceStage()) .build(); bootstrap.addBundle(guiceBundle); bootstrap.addBundle(new CorsBundle()); bootstrap.addBundle(new ViewBundle<>()); bootstrap.addBundle(new AssetsBundle("/assets/static/", "/static/")); bootstrap.addBundle( new MigrationsBundle<SingularityConfiguration>() { @Override public DataSourceFactory getDataSourceFactory( final SingularityConfiguration configuration ) { return configuration.getDatabaseConfiguration().get(); } } ); for (Bundle bundle : additionalBundles) { bootstrap.addBundle(bundle); } for (ConfiguredBundle<T> configuredBundle : additionalConfiguredBundles) { bootstrap.addBundle(configuredBundle); } bootstrap.getObjectMapper().registerModule(new ProtobufModule()); bootstrap.getObjectMapper().registerModule(new GuavaModule()); bootstrap.getObjectMapper().registerModule(new Jdk8Module()); bootstrap.getObjectMapper().setSerializationInclusion(Include.NON_ABSENT); bootstrap .getObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); }
Example 19
Source File: OxdServerApplication.java From oxd with Apache License 2.0 | 4 votes |
@Override public void initialize(Bootstrap<OxdServerConfiguration> bootstrap) { bootstrap.setConfigurationSourceProvider(new SubstitutingSourceProvider( bootstrap.getConfigurationSourceProvider(), new EnvironmentVariableSubstitutor(false))); }
Example 20
Source File: MonetaDropwizardApplication.java From moneta with Apache License 2.0 | 4 votes |
@Override public void initialize(Bootstrap<MonetaDropwizardConfiguration> bootstrap) { bootstrap.setConfigurationSourceProvider(new MonetaConfigurationSourceProvider()); super.initialize(bootstrap); }