io.dropwizard.assets.AssetsBundle Java Examples

The following examples show how to use io.dropwizard.assets.AssetsBundle. 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 vote down vote up
@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: ServerApplication.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Bootstrap<ServerConfig> bootstrap) {
    LOG.debug("Loading and registering guice bundle");
    GuiceBundle<ServerConfig> guiceBundle = GuiceBundleLoader.load();
    bootstrap.addBundle(guiceBundle);

    LOG.debug("Loading and registering static AssetsBundle on /assets");
    bootstrap.addBundle(new AssetsBundle("/assets", "/", "index.html", "/"));

    LOG.debug("Initializing guice injector context for current ServerApplication");
    guiceBundle.getInjector().injectMembers(this);

    try {
        EntityRepositoryScanner.scan();
    } catch (IllegalAccessException | InstantiationException e) {
        LOG.error("Failed to scan entity repository", e);
    }
}
 
Example #3
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/ajax", "/ajax", null, "ajax"));

    // 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 #4
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 #5
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 #6
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 #7
Source File: DashboardApplication.java    From SeaCloudsPlatform with Apache License 2.0 5 votes vote down vote up
@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 #8
Source File: ThirdEyeDashboardApplication.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void initialize(Bootstrap<ThirdEyeDashboardConfiguration> bootstrap) {
  bootstrap.addBundle(new ViewBundle());
  bootstrap.addBundle(new HelperBundle());
  bootstrap.addBundle(new RedirectBundle(new PathRedirect("/", "/app/#/home")));
  bootstrap.addBundle(new AssetsBundle("/app/", "/app", "index.html", "app"));
  bootstrap.addBundle(new AssetsBundle("/assets", "/assets", null, "assets"));
  bootstrap.addBundle(new AssetsBundle("/assets/css", "/assets/css", null, "css"));
  bootstrap.addBundle(new AssetsBundle("/assets/js", "/assets/js", null, "js"));
  bootstrap.addBundle(new AssetsBundle("/assets/lib", "/assets/lib", null, "lib"));
  bootstrap.addBundle(new AssetsBundle("/assets/img", "/assets/img", null, "img"));
  bootstrap.addBundle(new AssetsBundle("/assets/data", "/assets/data", null, "data"));
  bootstrap.addBundle(new ThirdEyeSwaggerBundle());
}
 
Example #9
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 #10
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 #11
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 #12
Source File: FoxtrotServer.java    From foxtrot with Apache License 2.0 5 votes vote down vote up
@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 #13
Source File: MainApplication.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<ApplicationConfiguration> bootstrap) {
  bootstrap.addBundle(new AssetsBundle("/swagger/", "/docs", "index.html"));
  bootstrap.addBundle(new ViewBundle<ApplicationConfiguration>() {
    @Override
    public Map<String, Map<String, String>> getViewConfiguration(
        ApplicationConfiguration configuration) {
      return new HashMap<>();
    }
  });
  bootstrap.addBundle(GuiceBundle.builder()
      .enableAutoConfig("io.scigraph.services")
      .injectorFactory(factory).modules(new SciGraphApplicationModule()).build());
}
 
Example #14
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 #15
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 #16
Source File: RegistryApplication.java    From registry with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Bootstrap<RegistryConfiguration> bootstrap) {
    // always deploy UI on /ui. If there is no other filter like Confluent etc, redirect / to /ui
    bootstrap.addBundle(new AssetsBundle("/assets", "/ui", "index.html", "static"));
    bootstrap.addBundle(new SwaggerBundle<RegistryConfiguration>() {
        @Override
        protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(RegistryConfiguration registryConfiguration) {
            return registryConfiguration.getSwaggerBundleConfiguration();
        }
    });
    super.initialize(bootstrap);
}
 
Example #17
Source File: LotteryApplication.java    From keycloak-dropwizard-integration with Apache License 2.0 5 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());

}
 
Example #18
Source File: KaramelServiceApplication.java    From karamel with Apache License 2.0 5 votes vote down vote up
@Override
  public void initialize(Bootstrap<KaramelServiceConfiguration> bootstrap) {

    logger.debug("Executing any initialization tasks.");
//        bootstrap.addBundle(new ConfiguredAssetsBundle("/assets/", "/dashboard/"));
    // https://groups.google.com/forum/#!topic/dropwizard-user/UaVcAYm0VlQ
    bootstrap.addBundle(new AssetsBundle("/assets/", "/"));
  }
 
Example #19
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 #20
Source File: JsClientBundle.java    From dropwizard-experiment with MIT License 4 votes vote down vote up
@Override
public void initialize(Bootstrap<?> bootstrap) {
    bootstrap.addBundle(new AssetsBundle(resourcePath, "/", "index.html"));
}
 
Example #21
Source File: DoctorKafkaMain.java    From doctorkafka with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<DoctorKafkaAppConfig> bootstrap) {
  bootstrap.addBundle(new AssetsBundle("/webapp/pages/", "/", "index.html"));
}
 
Example #22
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 #23
Source File: ThirdEyeAnomalyApplication.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(final Bootstrap<ThirdEyeAnomalyConfiguration> bootstrap) {
  bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
  bootstrap.addBundle(new ThirdEyeSwaggerBundle());
}
 
Example #24
Source File: GraphQLBundle.java    From dropwizard-graphql with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<?> bootstrap) {
  bootstrap.addBundle(new AssetsBundle("/assets", "/", "index.htm", "graphql-playground"));
}
 
Example #25
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 #26
Source File: MacroBaseServer.java    From macrobase with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<MacroBaseConf> bootstrap) {
    bootstrap.addBundle(new AssetsBundle("/frontend", "/", "console.html"));
}
 
Example #27
Source File: ShoppingApplication.java    From bookstore-cqrs-example with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<ShoppingConfiguration> bootstrap) {
  bootstrap.addBundle(new AssetsBundle("/assets/", "/", "index.html"));
}
 
Example #28
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 #29
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 #30
Source File: TestServerApplication.java    From jbrotli with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Bootstrap<TestServerConfiguration> bootstrap) {
  bootstrap.addBundle(new AssetsBundle("/public/", "/", "index.html"));
}