本文整理汇总了Java中io.dropwizard.Bundle类的典型用法代码示例。如果您正苦于以下问题:Java Bundle类的具体用法?Java Bundle怎么用?Java Bundle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Bundle类属于io.dropwizard包,在下文中一共展示了Bundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetImplementingBundles
import io.dropwizard.Bundle; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGetImplementingBundles() {
Bootstrap<?> bootstrap = new Bootstrap<>(null);
ConfiguredBundle hashSetBundle = (ConfiguredBundle) mock(HashSet.class, withSettings().extraInterfaces(ConfiguredBundle.class).defaultAnswer(RETURNS_DEEP_STUBS));
ConfiguredBundle hashMapBundle = (ConfiguredBundle) mock(HashMap.class, withSettings().extraInterfaces(ConfiguredBundle.class).defaultAnswer(RETURNS_DEEP_STUBS));
Bundle treeSetBundle = (Bundle) mock(TreeSet.class, withSettings().extraInterfaces(Bundle.class).defaultAnswer(RETURNS_DEEP_STUBS));
Bundle treeMapBundle = (Bundle) mock(TreeMap.class, withSettings().extraInterfaces(Bundle.class).defaultAnswer(RETURNS_DEEP_STUBS));
bootstrap.addBundle(hashMapBundle);
bootstrap.addBundle(hashSetBundle);
bootstrap.addBundle(treeMapBundle);
bootstrap.addBundle(treeSetBundle);
//
List<Set> setBundles = BootstrapExtensions.getImplementingBundles(bootstrap, Set.class);
List<Map> mapBundles = BootstrapExtensions.getImplementingBundles(bootstrap, Map.class);
//
assertThat(setBundles).isNotNull();
assertThat(setBundles).containsExactlyInAnyOrder((Set) hashSetBundle, (Set) treeSetBundle);
assertThat(mapBundles).isNotNull();
assertThat(mapBundles).containsExactlyInAnyOrder((Map) hashMapBundle, (Map) treeMapBundle);
}
示例2: renderReport
import io.dropwizard.Bundle; //导入依赖的package包/类
/**
* Renders configuration tree report according to provided config.
* By default report padded left with one tab. Subtrees are always padded with empty lines for better
* visibility.
*
* @param config tree rendering config
* @return rendered tree
*/
@Override
public String renderReport(final ContextTreeConfig config) {
final Set<Class<?>> scopes = service.getActiveScopes();
final TreeNode root = new TreeNode("APPLICATION");
renderScopeContent(config, root, Application.class);
renderSpecialScope(config, scopes, root, "BUNDLES LOOKUP", GuiceyBundleLookup.class);
renderSpecialScope(config, scopes, root, "DROPWIZARD BUNDLES", Bundle.class);
renderSpecialScope(config, scopes, root, "CLASSPATH SCAN", ClasspathScanner.class);
final StringBuilder res = new StringBuilder().append(Reporter.NEWLINE).append(Reporter.NEWLINE);
root.render(res);
return res.toString();
}
示例3: bundle_binds_work
import io.dropwizard.Bundle; //导入依赖的package包/类
@Test
public void bundle_binds_work() {
final Bundle bundle = mock(Bundle.class);
final Class<TestBundle> bundleClass = TestBundle.class;
Injector injector = Guice.createInjector(new AbstractPlugin() {
@Override
protected void configure() {
bindBundle(bundle);
bindBundle(bundleClass);
}
});
Set<Bundle> bundleSet = injector.getInstance(Keys.Bundles);
Set<Class<? extends Bundle>> bundleClassSet = injector.getInstance(Keys.BundleClasses);
assertThat(bundleSet, hasSize(1));
assertThat(bundleSet, hasItem(bundle));
assertThat(bundleClassSet, hasSize(1));
assertThat(bundleClassSet, hasItem(TestBundle.class));
}
示例4: initialize_adds_bundles
import io.dropwizard.Bundle; //导入依赖的package包/类
@Test
public void initialize_adds_bundles() {
final Bundle bundle = mock(Bundle.class);
final Class<TestBundle> bundleClass = TestBundle.class;
Application application = buildApplication(
new AbstractPlugin() {
@Override
protected void configure() {
bindBundle(bundle);
bindBundle(bundleClass);
}
}
);
new Platform(application).initialize(bootstrap);
verify(bootstrap).addBundle(eq(bundle));
verify(bootstrap).addBundle(isA(TestBundle.class));
}
示例5: initialize
import io.dropwizard.Bundle; //导入依赖的package包/类
@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");
final GuiceBundle<SingularityConfiguration> guiceBundle = GuiceBundle.defaultBuilder(SingularityConfiguration.class)
.modules(new SingularityServiceModule())
.modules(additionalModules)
.build();
bootstrap.addBundle(guiceBundle);
bootstrap.addBundle(new CorsBundle());
bootstrap.addBundle(new ViewBundle());
bootstrap.addBundle(new AssetsBundle("/assets/static/", "/static/"));
bootstrap.addBundle(new AssetsBundle("/assets/api-docs/", "/api-docs/", "index.html", "api-docs"));
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().setSerializationInclusion(Include.NON_NULL);
bootstrap.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
示例6: testAddBundleIfNotExist
import io.dropwizard.Bundle; //导入依赖的package包/类
@Test
public void testAddBundleIfNotExist() {
Bundle newBundle = mock(Bundle.class);
Bootstrap<?> bootstrap = new Bootstrap<>(null);
//
Bundle addedBundle = BootstrapExtensions.addBundleIfNotExist(bootstrap, Bundle.class, () -> newBundle);
//
assertThat(addedBundle).isSameAs(newBundle);
assertThat(BootstrapExtensions.getBundles(bootstrap)).containsExactly(newBundle);
}
示例7: testAddBundleIfNotExistPreExisting
import io.dropwizard.Bundle; //导入依赖的package包/类
@Test
public void testAddBundleIfNotExistPreExisting() {
Supplier<Bundle> bundleSupplier = mock(Supplier.class);
Bundle oldBundle = mock(Bundle.class);
Bootstrap<?> bootstrap = new Bootstrap<>(null);
bootstrap.addBundle(oldBundle);
//
Bundle addedBundle = BootstrapExtensions.addBundleIfNotExist(bootstrap, Bundle.class, bundleSupplier);
//
assertThat(addedBundle).isSameAs(oldBundle);
assertThat(BootstrapExtensions.getBundles(bootstrap)).containsExactly(oldBundle);
verifyZeroInteractions(bundleSupplier);
}
示例8: testGetBundles
import io.dropwizard.Bundle; //导入依赖的package包/类
@Test
public void testGetBundles() {
Bootstrap<?> bootstrap = new Bootstrap<>(null);
Bundle bundle = mock(Bundle.class);
bootstrap.addBundle(bundle);
//
List<Bundle> bundles = BootstrapExtensions.getBundles(bootstrap);
//
assertThat(bundles).isNotNull();
assertThat(bundles).containsExactly(bundle);
}
示例9: initialize
import io.dropwizard.Bundle; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<?> bootstrap) {
this.application = bootstrap.getApplication();
listServices(Bundle.class).forEach(bootstrap::addBundle);
listServices(ConfiguredBundle.class).forEach(bootstrap::addBundle);
listServices(Command.class).forEach(bootstrap::addCommand);
}
示例10: configure
import io.dropwizard.Bundle; //导入依赖的package包/类
@Override
protected void configure() {
bind(HK2ValidationBundle.class)
.to(HK2ValidationBundle.class)
.to(Bundle.class)
.in(Singleton.class);
bind(HK2ConfiguredBundle.class)
.to(HK2ConfiguredBundle.class)
.to(ConfiguredBundle.class)
.in(Singleton.class);
}
示例11: run
import io.dropwizard.Bundle; //导入依赖的package包/类
@Override
public void run(Environment environment) {
for(Class<? extends Bundle> bundleClass : runtimeBundleClasses) {
Bundle runtimeBundle = injector.getInstance(bundleClass);
runtimeBundle.run(environment);
}
//free up memory
runtimeBundleClasses.clear();
isInitialized = true;
}
示例12: renderScopeContent
import io.dropwizard.Bundle; //导入依赖的package包/类
/**
* Render entire scope subtree. Scope items are rendered first and bundles at the end (because most likely
* they will be subtrees).
*
* @param config tree config
* @param root root node
* @param scope scope to render
*/
private void renderScopeContent(final ContextTreeConfig config, final TreeNode root, final Class<?> scope) {
renderScopeItems(config, root, scope);
final List<Class<Object>> bundles = service.getData()
.getItems(Filters.registeredBy(scope).and(Filters.type(ConfigItem.Bundle)));
for (Class<Object> bundle : bundles) {
renderBundle(config, root, scope, bundle);
}
}
示例13: registerDwBundles
import io.dropwizard.Bundle; //导入依赖的package包/类
/**
* Register bundles, recognized from dropwizard bundles. {@link Bundle} used as context.
*
* @param bundles recognized bundles
* @see ru.vyarus.dropwizard.guice.GuiceBundle.Builder#configureFromDropwizardBundles()
*/
public void registerDwBundles(final List<GuiceyBundle> bundles) {
setScope(Bundle.class);
for (GuiceyBundle bundle : bundles) {
register(ConfigItem.Bundle, bundle);
}
closeScope();
}
示例14: registerLookupBundles
import io.dropwizard.Bundle; //导入依赖的package包/类
/**
* Register bundles resolved by lookup mechanism. {@link GuiceyBundleLookup} used as context.
*
* @param bundles bundles resolved by lookup mechanism
* @see GuiceyBundleLookup
*/
public void registerLookupBundles(final List<GuiceyBundle> bundles) {
setScope(GuiceyBundleLookup.class);
for (GuiceyBundle bundle : bundles) {
register(ConfigItem.Bundle, bundle);
}
closeScope();
}
示例15: buildBinders
import io.dropwizard.Bundle; //导入依赖的package包/类
private void buildBinders() {
if (!bindersBuilt) {
jerseyBinder = Multibinder.newSetBinder(binder(), Object.class, Graceland.class);
managedBinder = Multibinder.newSetBinder(binder(), Managed.class, Graceland.class);
managedClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.ManagedClass, Graceland.class);
healthCheckBinder = Multibinder.newSetBinder(binder(), HealthCheck.class, Graceland.class);
healthCheckClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.HealthCheckClass, Graceland.class);
taskBinder = Multibinder.newSetBinder(binder(), Task.class, Graceland.class);
taskClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.TaskClass, Graceland.class);
bundleBinder = Multibinder.newSetBinder(binder(), Bundle.class, Graceland.class);
bundleClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.BundleClass, Graceland.class);
commandBinder = Multibinder.newSetBinder(binder(), Command.class, Graceland.class);
commandClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.CommandClass, Graceland.class);
initializerBinder = Multibinder.newSetBinder(binder(), Initializer.class, Graceland.class);
initializerClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.InitializerClass, Graceland.class);
configuratorBinder = Multibinder.newSetBinder(binder(), Configurator.class, Graceland.class);
configuratorClassBinder = Multibinder.newSetBinder(binder(), TypeLiterals.ConfiguratorClass, Graceland.class);
bindersBuilt = true;
}
}