io.dropwizard.views.ViewBundle Java Examples

The following examples show how to use io.dropwizard.views.ViewBundle. 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: FreeMarkerOnlineTester.java    From freemarker-online-tester with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Bootstrap<FreeMarkerOnlineTesterConfiguration> bootstrap) {
    bootstrap.addBundle(new ViewBundle<FreeMarkerOnlineTesterConfiguration>() {
        @Override
        public Map<String, Map<String, String>> getViewConfiguration(FreeMarkerOnlineTesterConfiguration config) {
            return config.getViewRendererConfiguration();
        }        	
    });
    bootstrap.addBundle(new SslReloadBundle());
    bootstrap.addBundle(new ConfiguredAssetsBundle(
    		ImmutableMap.of(
    				"/assets/", "/assets/", // css, js, images...
    				"/override-me/", "/.well-known/acme-challenge/" // Map to a file outside the jar in the yml!
    				)));
    bootstrap.addBundle(new RedirectBundle(
            new UriRedirect(
                    "http://freemarker-online.kenshoo.com(?::\\d+)?(/.*)$",
                    "https://try.freemarker.apache.org$1"),
            new UriRedirect(
                    "http://try.freemarker.org(?::\\d+)?(/.*)$",
                    "https://try.freemarker.apache.org$1"),
            new UriRedirect(
                    "http://try.freemarker.apache.org((:\\d+)?/(?!\\.well-known/acme-challenge/).*)$",
                    "https://try.freemarker.apache.org$1")
    ));
}
 
Example #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
Source File: AirpalApplicationBase.java    From airpal with Apache License 2.0 4 votes vote down vote up
public Iterable<ConfiguredBundle<T>> getConfiguredBundles()
{
    return Arrays.asList(new ViewBundle());
}
 
Example #13
Source File: HelloJDBIService.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
    bootstrap.addBundle(new ViewBundle<>());
    bootstrap.addBundle(new JdbiExceptionsBundle()); // Provides automatic unwrapping of SQLException and DBIException
}
 
Example #14
Source File: HelloMongoService.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void initialize(Bootstrap<HelloMongoConfiguration> bootstrap) {
    bootstrap.addBundle(new ViewBundle());
}
 
Example #15
Source File: HelloWorldService.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
    bootstrap.addBundle(hibernate);
    bootstrap.addBundle(new ViewBundle<>());
}
 
Example #16
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);
}