io.dropwizard.Bundle Java Examples

The following examples show how to use io.dropwizard.Bundle. 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: AirpalApplicationBase.java    From airpal with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<T> bootstrap)
{
    for (ConfiguredBundle<T> configuredBundle : getConfiguredBundles()) {
        bootstrap.addBundle(configuredBundle);
    }
    for (Bundle bundle : getBundles()) {
        bootstrap.addBundle(bundle);
    }
}
 
Example #2
Source File: BundleSpec.java    From soabase with Apache License 2.0 4 votes vote down vote up
public BundleSpec(Bundle bundle, Phase phase)
{
    this.bundle = bundle;
    this.configuredBundle = null;
    this.phase = phase;
}
 
Example #3
Source File: BundleSpec.java    From soabase with Apache License 2.0 4 votes vote down vote up
public Bundle getBundle()
{
    return bundle;
}
 
Example #4
Source File: EmbeddedSingularityExample.java    From Singularity with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<? extends Bundle> getDropwizardBundles(
  final Bootstrap<SingularityConfiguration> bootstrap
) {
  return ImmutableSet.of();
}
 
Example #5
Source File: SingularityService.java    From Singularity with Apache License 2.0 4 votes vote down vote up
@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 #6
Source File: SingularityService.java    From Singularity with Apache License 2.0 2 votes vote down vote up
/**
 * Dropwizard bundles used in addition to the bundles required by Singularity. This is an extension point when embedding
 * Singularity into a custom service.
 */
public Iterable<? extends Bundle> getDropwizardBundles(Bootstrap<T> bootstrap) {
  return ImmutableList.of();
}