io.dropwizard.setup.Bootstrap类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(194)

本文整理了Java中io.dropwizard.setup.Bootstrap类的一些代码示例,展示了Bootstrap类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bootstrap类的具体详情如下:
包路径:io.dropwizard.setup.Bootstrap
类名称:Bootstrap

Bootstrap介绍

[英]The pre-start application environment, containing everything required to bootstrap a Dropwizard command.
[中]预启动应用程序环境,包含引导Dropwizard命令所需的一切。

代码示例

代码示例来源:origin: signalapp/BitHub

@Override
public void initialize(Bootstrap<BithubServerConfiguration> bootstrap) {
 bootstrap.addBundle(new ViewBundle());
}

代码示例来源:origin: graphhopper/graphhopper

@Override
public void initialize(Bootstrap<GraphHopperServerConfiguration> bootstrap) {
  bootstrap.addBundle(new GraphHopperBundle());
  bootstrap.addBundle(new ConfiguredAssetsBundle("/assets/", "/maps/", "index.html"));
  bootstrap.addCommand(new ImportCommand(bootstrap.getObjectMapper()));
}

代码示例来源:origin: dropwizard/dropwizard

@Override
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
  // Enable variable substitution with environment variables
  bootstrap.setConfigurationSourceProvider(
      new SubstitutingSourceProvider(
          bootstrap.getConfigurationSourceProvider(),
          new EnvironmentVariableSubstitutor(false)
      )
  );
  bootstrap.addCommand(new RenderCommand());
  bootstrap.addBundle(new AssetsBundle());
  bootstrap.addBundle(new MigrationsBundle<HelloWorldConfiguration>() {
    @Override
    public DataSourceFactory getDataSourceFactory(HelloWorldConfiguration configuration) {
      return configuration.getDataSourceFactory();
    }
  });
  bootstrap.addBundle(hibernateBundle);
  bootstrap.addBundle(new ViewBundle<HelloWorldConfiguration>() {
    @Override
    public Map<String, Map<String, String>> getViewConfiguration(HelloWorldConfiguration configuration) {
      return configuration.getViewRendererConfiguration();
    }
  });
}

代码示例来源:origin: dropwizard/dropwizard

@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
  final Environment environment = new Environment(bootstrap.getApplication().getName(),
                          bootstrap.getObjectMapper(),
                          bootstrap.getValidatorFactory(),
                          bootstrap.getMetricRegistry(),
                          bootstrap.getClassLoader(),
                          bootstrap.getHealthCheckRegistry());
  configuration.getMetricsFactory().configure(environment.lifecycle(),
                        bootstrap.getMetricRegistry());
  configuration.getServerFactory().configure(environment);
  bootstrap.run(configuration, environment);
  application.run(configuration, environment);
  run(environment, namespace, configuration);
}

代码示例来源:origin: paukiatwee/budgetapp

@Override
public void initialize(Bootstrap<AppConfiguration> bootstrap) {
  MigrationsBundle<AppConfiguration> migrationBundle = new MigrationsBundle<AppConfiguration>() {
    @Override
    public DataSourceFactory getDataSourceFactory(AppConfiguration configuration) {
      return configuration.getDataSourceFactory();
    }
  };
  // allow using Environment variable in yaml
  bootstrap.setConfigurationSourceProvider(
      new SubstitutingSourceProvider(
          bootstrap.getConfigurationSourceProvider(),
          new EnvironmentVariableSubstitutor(false)
      )
  );
  bootstrap.addBundle(migrationBundle);
  bootstrap.addBundle(hibernate);
  bootstrap.addBundle(new ConfiguredAssetsBundle("/app", "/app", "index.html"));
}

代码示例来源:origin: HubSpot/Singularity

@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()));
   .modules(additionalModules)
   .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) {
  bootstrap.addBundle(bundle);
  bootstrap.addBundle(configuredBundle);
 bootstrap.getObjectMapper().registerModule(new ProtobufModule());
 bootstrap.getObjectMapper().registerModule(new GuavaModule());
 bootstrap.getObjectMapper().setSerializationInclusion(Include.NON_NULL);
 bootstrap.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

代码示例来源:origin: signalapp/Signal-Server

@Override
public void initialize(Bootstrap<WhisperServerConfiguration> bootstrap) {
 bootstrap.addCommand(new DirectoryCommand());
 bootstrap.addCommand(new VacuumCommand());
 bootstrap.addCommand(new TrimMessagesCommand());
 bootstrap.addCommand(new PeriodicStatsCommand());
 bootstrap.addCommand(new DeleteUserCommand());
 bootstrap.addCommand(new CertificateCommand());
 bootstrap.addBundle(new NameableMigrationsBundle<WhisperServerConfiguration>("accountdb", "accountsdb.xml") {
  @Override
  public DataSourceFactory getDataSourceFactory(WhisperServerConfiguration configuration) {
   return configuration.getDataSourceFactory();
  }
 });
 bootstrap.addBundle(new NameableMigrationsBundle<WhisperServerConfiguration>("messagedb", "messagedb.xml") {
  @Override
  public DataSourceFactory getDataSourceFactory(WhisperServerConfiguration configuration) {
   return configuration.getMessageStoreConfiguration();
  }
 });
 bootstrap.addBundle(new NameableMigrationsBundle<WhisperServerConfiguration>("abusedb", "abusedb.xml") {
  @Override
  public PooledDataSourceFactory getDataSourceFactory(WhisperServerConfiguration configuration) {
   return configuration.getAbuseDatabaseConfiguration();
  }
 });
}

代码示例来源:origin: alex-shpak/rx-jersey

@Override
public void initialize(Bootstrap<RxJerseyConfiguration> bootstrap) {
  bootstrap.getObjectMapper()
      .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
  bootstrap.addBundle(new RxJerseyBundle<RxJerseyConfiguration>()
      .setClientConfigurationProvider(config -> config.client)
      .register(HeaderInterceptor.class)
  );
}

代码示例来源:origin: homeaway/stream-registry

@Override
public void initialize(final Bootstrap<StreamRegistryConfiguration> bootstrap) {
  // EnvironmentVariableSubstitutor enables EnvVariables to be substituted into the configuration before initialization
  bootstrap.setConfigurationSourceProvider(
      new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(),
          new EnvironmentVariableSubstitutor(false)
      )
  );
  bootstrap.addBundle(new SwaggerBundle<StreamRegistryConfiguration>() {
    @Override
    protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(StreamRegistryConfiguration configuration) {
      return configuration.getSwaggerBundleConfiguration();
    }
  });
  metricRegistry = bootstrap.getMetricRegistry();
}

代码示例来源:origin: soabase/soabase

public void initialize(Bootstrap<ExampleConfiguration> bootstrap)
{
  bootstrap.setConfigurationSourceProvider(new FlexibleConfigurationSourceProvider());
  bootstrap.addBundle(new CuratorBundle<>());
  bootstrap.addBundle(new SqlBundle<>());
  bootstrap.addBundle(new SoaBundle<>());
}

代码示例来源:origin: robeio/robe

bootstrap.addBundle(new GuiceBundle<T>(modules, bootstrap.getApplication().getConfigurationClass()));
bootstrap.addBundle(hibernateBundle);
bootstrap.addBundle(new TokenAuthBundle<T>());
bootstrap.addCommand(new InitializeCommand(this, hibernateBundle));
bootstrap.addBundle(new QuartzBundle<T>());
bootstrap.addBundle(new MailBundle<T>());
bootstrap.addBundle(new AdvancedAssetBundle<T>());

代码示例来源:origin: soabase/soabase

@Override
public final void initialize(Bootstrap<T> bootstrap)
{
  bootstrap.setConfigurationFactoryFactory(builder.getFactoryFactory());
  bootstrap.setConfigurationSourceProvider(new FlexibleConfigurationSourceProvider());
  ConfiguredBundle<T> bundle = new ConfiguredBundle<T>()
  {
    @Override
    public void run(T configuration, Environment environment) throws Exception
    {
      DefaultServerFactory factory = new DefaultServerFactory();
      factory.setAdminConnectors(Lists.<ConnectorFactory>newArrayList());
      configuration.setServerFactory(factory);
    }
    @Override
    public void initialize(Bootstrap<?> bootstrap)
    {
      // NOP
    }
  };
  addBundles(bootstrap, BundleSpec.Phase.PRE_SOA);
  bootstrap.addBundle(bundle);
  bootstrap.addBundle(new SoaBundle<>());
  bootstrap.addBundle(new ComponentBundle(builder.getAppName(), builder.getCompanyName(), builder.getFooterMessage(), builder.getTabs(), builder.getMetrics(), builder.getAuthSpec()));
  bootstrap.addBundle(new AssetsBundle("/assets/soa"));
  addBundles(bootstrap, BundleSpec.Phase.POST_SOA);
}

代码示例来源:origin: palantir/atlasdb

private void enableEnvironmentVariablesInConfig(Bootstrap<AtlasDbEteConfiguration> bootstrap) {
    bootstrap.setConfigurationSourceProvider(
        new SubstitutingSourceProvider(
            bootstrap.getConfigurationSourceProvider(),
            new EnvironmentVariableSubstitutor()));
  }
}

代码示例来源:origin: dropwizard/dropwizard

@Override
public final void initialize(Bootstrap<?> bootstrap) {
  bootstrap.getObjectMapper().registerModule(createHibernate5Module());
}

代码示例来源:origin: dropwizard/dropwizard

@Override
@SuppressWarnings("unchecked")
public void run(Bootstrap<?> wildcardBootstrap, Namespace namespace) throws Exception {
  final Bootstrap<T> bootstrap = (Bootstrap<T>) wildcardBootstrap;
  configuration = parseConfiguration(bootstrap.getConfigurationFactoryFactory(),
                    bootstrap.getConfigurationSourceProvider(),
                    bootstrap.getValidatorFactory().getValidator(),
                    namespace.getString("file"),
                    getConfigurationClass(),
                    bootstrap.getObjectMapper());
  try {
    if (configuration != null) {
      configuration.getLoggingFactory().configure(bootstrap.getMetricRegistry(),
                            bootstrap.getApplication().getName());
    }
    run(bootstrap, namespace, configuration);
  } finally {
    if (!asynchronous) {
      cleanup();
    }
  }
}

代码示例来源:origin: mesosphere/dcos-commons

@Override
public void initialize(Bootstrap<KeystoreConfiguration> bootstrap) {
  // Enable variable substitution with environment variables
  bootstrap.setConfigurationSourceProvider(
      new SubstitutingSourceProvider(
          bootstrap.getConfigurationSourceProvider(),
          new EnvironmentVariableSubstitutor(false)
      )
  );
  bootstrap.addCommand(new TLSTruststoreTestCommand<>(this));
}

代码示例来源:origin: bazaarvoice/emodb

@Override
public void initialize(Bootstrap<EmoConfiguration> bootstrap) {
  bootstrap.addCommand(new CreateKeyspacesCommand());
  bootstrap.addCommand(new RegisterCassandraCommand());
  bootstrap.addCommand(new ListCassandraCommand());
  bootstrap.addCommand(new UnregisterCassandraCommand());
  bootstrap.addCommand(new PurgeDatabusEventsCommand());
  bootstrap.addCommand(new AllTablesReportCommand());
  bootstrap.addCommand(new EncryptConfigurationApiKeyCommand());
  EmoServiceObjectMapperFactory.configure(bootstrap.getObjectMapper());
  bootstrap.getMetricRegistry().register("jvm.gc.totals", new EmoGarbageCollectorMetricSet());
}

代码示例来源:origin: net.smartcosmos/smartcosmos-extension-api

@Override
public void initialize(Bootstrap<?> bootstrap)
{
  ConfigurationFactory<T> cf = new DefaultConfigurationFactoryFactory<T>().create(extensionConfigurationClass,
      bootstrap.getValidatorFactory().getValidator(),
      bootstrap.getObjectMapper(),
      "dw");
  if (extensionConfigurationPath != null && !extensionConfigurationPath.isEmpty())
  {
    try
    {
      extensionConfiguration = (T) cf.build(bootstrap.getConfigurationSourceProvider(), extensionConfigurationPath);
      initialize(extensionConfiguration);
    } catch (Exception e)
    {
      handleInitializationException(e);
    }
  } else
  {
    throw new RuntimeException("Server extension " + name + " has no configuration.");
  }
}

代码示例来源:origin: dropwizard/dropwizard

@Override
@SuppressWarnings("unchecked")
public final void initialize(Bootstrap<?> bootstrap) {
  final Class<T> klass = (Class<T>) bootstrap.getApplication().getConfigurationClass();
  bootstrap.addCommand(new DbCommand<>(name(), this, klass, getMigrationsFileName()));
}

代码示例来源:origin: robeio/robe

protected T loadConfiguration(Bootstrap bootstrap) {
  if (config == null) {
    try {
      config = (T) bootstrap.getConfigurationFactoryFactory().create(
          bootstrap.getApplication().getConfigurationClass(),
          bootstrap.getValidatorFactory().getValidator(),
          bootstrap.getObjectMapper(), "")
          .build(new File(configurationPath));
    } catch (Exception e) {
      throw new RobeRuntimeException("Can't load configuration :" + configurationPath, e);
    }
  }
  return config;
}

相关文章