Java Code Examples for io.dropwizard.setup.Bootstrap#addBundle()

The following examples show how to use io.dropwizard.setup.Bootstrap#addBundle() . 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: LotteryApplication.java    From keycloak-dropwizard-integration with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Bootstrap<LotteryConfiguration> bootstrap) {

    // set up folders for static content
    bootstrap.addBundle(new AssetsBundle("/assets/css", "/css", null, "css"));
    bootstrap.addBundle(new AssetsBundle("/assets/js", "/js", null, "js"));
    bootstrap.addBundle(new AssetsBundle("/assets/fonts", "/fonts", null, "fonts"));
    bootstrap.addBundle(new AssetsBundle("/assets/html", "/html", null, "html"));

    // setup Freemarker views.
    bootstrap.addBundle(new ViewBundle());

    // tag::keycloak[]
    bootstrap.addBundle(new KeycloakBundle<LotteryConfiguration>() {
        @Override
        protected KeycloakConfiguration getKeycloakConfiguration(LotteryConfiguration configuration) {
            return configuration.getKeycloakConfiguration();
        }
        /* OPTIONAL: override getUserClass(), createAuthorizer() and createAuthenticator() if you want to use
         * a class other than de.ahus1.keycloak.dropwizard.User to be injected by @Auth */
    });
    // end::keycloak[]

}
 
Example 2
Source File: JerahmeelApplication.java    From judgels with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<JerahmeelApplicationConfiguration> bootstrap) {
    JudgelsObjectMappers.configure(bootstrap.getObjectMapper());

    bootstrap.addBundle(hibernateBundle);
    bootstrap.addBundle(new MultiPartBundle());
    bootstrap.addBundle(new JerahmeelMigrationsBundle());
    bootstrap.addBundle(new WebSecurityBundle());
}
 
Example 3
Source File: DropwizardApplication.java    From microservices-comparison with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<DropwizardServerConfiguration> bootstrap) {
    guiceBundle = GuiceBundle.<DropwizardServerConfiguration>newBuilder()
            .addModule(new HelloModule())
            .addModule(new CarModule())
            .setConfigClass(DropwizardServerConfiguration.class)
            .build();
    bootstrap.addBundle(guiceBundle);
    bootstrap.addBundle(new Java8Bundle());

    ObjectMapper objectMapper = bootstrap.getObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
Example 4
Source File: ExampleApplication.java    From okta-auth-java with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: Main.java    From myriad with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<MyriadConfiguration> bootstrap) {
	bootstrap.addBundle(new ViewBundle());
	bootstrap
			.addBundle(new AssetsBundle("/assets/css", "/css", null, "css"));
	bootstrap.addBundle(new AssetsBundle("/assets/js", "/js", null, "js"));
}
 
Example 6
Source File: ExampleApplication.java    From soabase with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<Configuration> bootstrap)
{
    // Use the StandardInjectorProvider unless you need special behavior - you can pass as many modules as you like
    InjectorProvider<Configuration> injectorProvider = new StandardInjectorProvider<>(new ExampleJerseyGuiceModule());
    bootstrap.addBundle(new GuiceBundle<>(injectorProvider));
}
 
Example 7
Source File: OntologyApplication.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<OntologyConfiguration> bootstrap) {
	// Add bundle for static asset directories
	bootstrap.addBundle(new AssetsBundle("/static", "/", "index.html", "static"));
	// Add webjars AssetsBundle, to include bootstrap, etc.
	bootstrap.addBundle(new AssetsBundle("/META-INF/resources/webjars", "/webjars", null, "webjars"));
}
 
Example 8
Source File: Main.java    From dcos-cassandra-service with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: BaragonService.java    From Baragon with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: HooksIndependentDeclarationTest.java    From dropwizard-guicey with MIT License 4 votes vote down vote up
@Override
public void initialize(Bootstrap<Configuration> bootstrap) {
    bootstrap.addBundle(GuiceBundle.builder()
            .extensions(Eager1.class, Eager2.class)
            .build());
}
 
Example 11
Source File: JaxWsExampleApplication.java    From dropwizard-jaxws with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<JaxWsExampleApplicationConfiguration> bootstrap) {
    bootstrap.addBundle(hibernate);
    bootstrap.addBundle(jaxWsBundle);
    bootstrap.addBundle(anotherJaxWsBundle);
}
 
Example 12
Source File: IronTestApplication.java    From irontest with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<IronTestConfiguration> bootstrap) {
    bootstrap.addCommand(new UpgradeCommand());

    bootstrap.addBundle(new AssetsBundle("/assets/app", "/ui", "index.htm", "ui"));
    bootstrap.addBundle(new AssetsBundle("/META-INF/resources/webjars", "/ui/lib", null, "lib"));
    bootstrap.addBundle(new AssetsBundle("/assets/mockserver", "/ui/mockserver", "mockserver.htm", "mockserver"));
    bootstrap.addBundle(new AssetsBundle("/assets/common", "/ui/common", null, "common"));
    bootstrap.addBundle(jaxWsBundle);
    bootstrap.addBundle(new MultiPartBundle());
    bootstrap.addBundle(new ViewBundle<IronTestConfiguration>(){
        @Override
        public Map<String, Map<String, String>> getViewConfiguration(IronTestConfiguration config) {
            return config.getViewRendererConfiguration();
        }
    });
    Configuration.setDefaults(new Configuration.Defaults() {
        private final JsonProvider jsonProvider = new JacksonJsonProvider();
        private final MappingProvider mappingProvider = new JacksonMappingProvider();

        @Override
        public JsonProvider jsonProvider() {
            return jsonProvider;
        }

        @Override
        public MappingProvider mappingProvider() {
            return mappingProvider;
        }

        @Override
        public Set<Option> options() {
            return EnumSet.noneOf(Option.class);
        }
    });

    //  configure the Jackson ObjectMapper used by JAX-RS (Jersey)
    ObjectMapper objectMapper = bootstrap.getObjectMapper();
    objectMapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION);
    IronTestUtils.addMixInsForWireMock(objectMapper);
}
 
Example 13
Source File: AbstractApplicationTest.java    From dropwizard-pac4j with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<C> bootstrap) {
    bootstrap.addBundle(bundle);
}
 
Example 14
Source File: MockApplication.java    From soabase with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<MockConfiguration> bootstrap)
{
    bootstrap.addBundle(new GuiceBundle<>(new StandardInjectorProvider<>(module)));
}
 
Example 15
Source File: BreakerboxDashboardBundle.java    From breakerbox with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.addBundle(new AssetsBundle());
}
 
Example 16
Source File: MockOldStyleApplication.java    From soabase with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<Configuration> bootstrap)
{
    bootstrap.addBundle(new GuiceBundle<>(new StandardInjectorProvider<>(modules)));
}
 
Example 17
Source File: OrderApplication.java    From bookstore-cqrs-example with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<OrderApplicationConfiguration> bootstrap) {
  bootstrap.addBundle(new AssetsBundle("/assets/", "/", "admin.html"));
}
 
Example 18
Source File: BundleApplication.java    From dropwizard-request-tracker with MIT License 4 votes vote down vote up
@Override
public void initialize(Bootstrap<BundleConfiguration> bootstrap) {
	bootstrap.addBundle(tracker);
}
 
Example 19
Source File: NewtsService.java    From newts with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<NewtsConfig> bootstrap) {
    bootstrap.addCommand(new InitCommand());
    bootstrap.addBundle(new AssetsBundle("/app", UI_URL_PATH, "index.html"));
}
 
Example 20
Source File: QualifiedAndParameterizedParamInjectionTest.java    From dropwizard-guicey with MIT License 4 votes vote down vote up
@Override
public void initialize(Bootstrap<Configuration> bootstrap) {
    bootstrap.addBundle(GuiceBundle.builder()
            .modules(new Mod())
            .build());
}