io.dropwizard.migrations.MigrationsBundle Java Examples

The following examples show how to use io.dropwizard.migrations.MigrationsBundle. 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: TodoListApplication.java    From dropwizard-experiment with MIT License 6 votes vote down vote up
@Override
public void initialize(Bootstrap<TodoListConfiguration> bootstrap) {
    ebeanBundle = new EbeanBundle();
    //rabbitMqBundle = new RabbitMQBundle();

    // This outputs xDateTimes as ISO strings rather than an array of numbers in JSON.
    bootstrap.getObjectMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

    bootstrap.addBundle(new Java8Bundle());
    bootstrap.addBundle(ebeanBundle);
    //bootstrap.addBundle(rabbitMqBundle);
    bootstrap.addBundle(new OAuth2Bundle(ebeanBundle));
    bootstrap.addBundle(new TodoClientBundle());
    bootstrap.addBundle(new MigrationsBundle<TodoListConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(TodoListConfiguration configuration) {
            return configuration.getDatabaseConfig();
        }
    });

    // The anonymous subclass seems to be needed for the config type to be picked up correctly.
    bootstrap.addCommand(new WorkersCommand<TodoListConfiguration>(TodoListApplication.this) {});
    bootstrap.addCommand(new DbDiffCommand<TodoListConfiguration>() {});
}
 
Example #2
Source File: NiPingMonitorApplication.java    From SAPNetworkMonitor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<ServerConfiguration> bootstrap) {

    bootstrap.addBundle(new MigrationsBundle<ServerConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(ServerConfiguration configuration) {
            return configuration.getDataSourceFactory();
        }
    });

    bootstrap.addBundle(new AssetsBundle("/com/cloudwise/sap/niping/view/static", "/static", null, "static"));
    bootstrap.addBundle(new AssetsBundle("/com/cloudwise/sap/niping/view/vendor", "/vendor", null, "vendor"));
    bootstrap.addBundle(new ViewBundle<ServerConfiguration>());
}
 
Example #3
Source File: RufusApplication.java    From rufus with MIT License 5 votes vote down vote up
@Override
public void initialize(Bootstrap<RufusConfiguration> bootstrap) {
    bootstrap.addBundle(new AssetsBundle("/app", "/", "index.html"));
    bootstrap.addBundle(new ViewBundle<>());
    bootstrap.addBundle(new MultiPartBundle());
    bootstrap.addBundle(new MigrationsBundle<RufusConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(RufusConfiguration conf) {
            return conf.getDataSourceFactory();
        }
    });
}
 
Example #4
Source File: TrellisApplication.java    From trellis with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(final Bootstrap<AppConfiguration> bootstrap) {
    super.initialize(bootstrap);
    bootstrap.addBundle(new MigrationsBundle<AppConfiguration>() {
        @Override
        public DataSourceFactory getDataSourceFactory(final AppConfiguration config) {
            return config.getDataSourceFactory();
        }
        @Override
        public String getMigrationsFileName() {
            return "org/trellisldp/jdbc/migrations.yml";
        }
    });
}
 
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);
}