本文整理汇总了Java中org.glassfish.hk2.api.TypeLiteral类的典型用法代码示例。如果您正苦于以下问题:Java TypeLiteral类的具体用法?Java TypeLiteral怎么用?Java TypeLiteral使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeLiteral类属于org.glassfish.hk2.api包,在下文中一共展示了TypeLiteral类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
context.register(new AbstractBinder() {
@Override
protected void configure() {
Injector injector = ClientGuiceBridgeFeature.getInjector(context.getConfiguration());
ClientGuiceInjectInjector injectInjector = new ClientGuiceInjectInjector(injector);
bind(injectInjector).to(new TypeLiteral<InjectionResolver<com.google.inject.Inject>>() {
});
}
});
return true;
}
示例2: setUp
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
ServiceLocator locator = ServiceLocatorUtilities.createAndPopulateServiceLocator();
ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
@Override
protected void configure() {
bind(SecurityService.class).to(SecurityService.class);
bind(accountDao).to(AccountDao.class);
bind(passwordDao).to(AccountPasswordDao.class);
bind(userProvider).to(UserProvider.class);
bind(event).to(new TypeLiteral<Event<SignedInEvent>>() {
});
}
});
locator.inject(this);
}
示例3: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
Configuration configuration = context.getConfiguration();
if (!configuration.isRegistered(ConfigPropertyResolver.class)) {
LOGGER.debug("Register ConfigPropertyFeature");
context.register(ConfigPropertyResolver.class);
context.register(new AbstractBinder() {
@Override
protected void configure() {
bind(ConfigPropertyResolver.class)
.to(new TypeLiteral<InjectionResolver<ConfigProperty>>() {})
.in(Singleton.class);
}
});
}
return true;
}
示例4: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
// for now only supporting Guice injection to resources
// TODO: if we want to inject web environment objects back into Guice
// services or to use JSR-330 annotations in Resources, we need
// org.glassfish.hk2:guice-bridge integration
// This feature can inject HK2 ServiceLocator in constructor, and then
// we can bridge it both ways with Guice
context.register(new AbstractBinder() {
@Override
protected void configure() {
bind(GuiceInjectInjector.class).to(new TypeLiteral<InjectionResolver<com.google.inject.Inject>>() {
}).in(Singleton.class);
}
});
return true;
}
示例5: run
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
public void run(T configuration, Environment environment) {
final HazelcastSessionConfig hazelcastSessionConfig = getHazelcastSessionConfig(configuration);
final Class<? extends Factory<SessionsStore>> sessionsStoreFactoryClass = hazelcastSessionConfig.getSessionsStoreFactoryClass();
environment.jersey().register(new AbstractBinder() {
@Override
protected void configure() {
bindFactory(sessionsStoreFactoryClass).to(SessionsStore.class).in(Singleton.class);
bind(hazelcastSessionConfig).to(HazelcastSessionConfig.class);
bind(SessionObjectResolver.class)
.to(new TypeLiteral<InjectionResolver<Session>>() {
})
.in(Singleton.class);
}
});
// environment.lifecycle().manage(new HazelcastInstanceManager(hazelcastInstance));
environment.jersey().register(SetSessionIdResponseFilter.class);
}
示例6: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
context.register(new AbstractBinder() {
@Override
public void configure() {
bind(TokenAuthenticator.class)
.in(Singleton.class);
bind(TokenFactory.class)
.in(Singleton.class);
bind(TokenFactoryProvider.class)
.to(ValueFactoryProvider.class)
.in(Singleton.class);
bind(TokenParamInjectionResolver.class)
.to(new TypeLiteral<InjectionResolver<RobeAuth>>() {
})
.in(Singleton.class);
}
});
return true;
}
示例7: generate
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
public Client generate() {
ClientConfig clientConfig = clientConfigBase != null
? new ClientConfig().loadFrom(clientConfigBase)
: new ClientConfig();
final List<JerseyConfig.Binder> binders = new ArrayList<>();
binders.add(binder -> binder.bind(serviceDefinition).to(ServiceDefinition.class).named(SERVICE_DEFINITION_INJECTION));
JsonConfig jsonConfig = serviceDefinition.getJsonConfig();
ObjectMapper mapper = jsonConfig.get();
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(mapper);
clientConfig.register(provider);
binders.add(binder -> binder.bind(mapper).to(ObjectMapper.class));
if (! Strings.isNullOrEmpty(clientAppName)) {
binders.add(binder -> binder.bind(clientAppName).to(String.class).named(ClientNameFilter.CLIENT_APPNAME));
}
if (appTokenSupplier != null) {
binders.add(binder -> binder
.bind(appTokenSupplier)
.to(new TypeLiteral<Supplier<String>>() {
})
.named(AppTokenClientFilter.APP_TOKEN_SUPPLIER_BIND_NAME)
);
clientConfig.register(AppTokenClientFilter.class);
}
clientConfig.register(new AbstractBinder() {
@Override
protected void configure() {
binders.forEach(it -> it.addBindings(this));
}
});
return ClientBuilder.newClient(clientConfig);
}
示例8: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
bind(new RateLimiterFactoryProvider(requestRateLimiterFactory)).to(RateLimiterFactoryProvider.class);
bind(RateLimitingFactoryProvider.class).to(ValueFactoryProvider.class).in(Singleton.class);
bind(RateLimitingFactoryProvider.RateLimitingInjectionResolver.class)
.to(new TypeLiteral<InjectionResolver<RateLimiting>>() {}).in(Singleton.class);
}
示例9: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
bind(TestRateLimitingFactoryProvider.class).to(ValueFactoryProvider.class).in(Singleton.class);
bind(TestRateLimitingFactoryProvider.TestRateLimitingInjectionResolver.class).to(
new TypeLiteral<InjectionResolver<RateLimiting>>() {
}
).in(Singleton.class);
}
示例10: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
bind(JsonParamValueFactoryProvider.class).to(ValueFactoryProvider.class).in(Singleton.class);
bind(JsonParamValueFactoryProvider.InjectionResolver.class).to(new TypeLiteral<InjectionResolver<JsonParam>>() {
}).in(Singleton.class);
}
示例11: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
// Binding naming services
bind(DefaultMetricNameService.class).to(MetricNameService.class).in(Singleton.class);
bind(DefaultMetricNameFormatter.class).to(MetricNameFormatter.class).in(Singleton.class);
bind(CodahaleMetricNameFilter.class).to(MetricNameFilter.class).in(Singleton.class).ranked(MetricNameFilter.DEFAULT_NAME_PRIORITY);
bindAsContract(TaggedMetricRegistry.class).in(Singleton.class);
// Bind Metric method handlers
bind(GaugeAnnotationActivator.class).to(InstanceLifecycleListener.class).in(Singleton.class);
bind(CachedGaugeAnnotationActivator.class).to(InstanceLifecycleListener.class).in(Singleton.class);
// Bind Metric interceptors
bind(CountedInterceptorFactory.class)
.to(new TypeLiteral<AnnotatedMethodInterceptorFactory<Counted>>() {})
.to(new TypeLiteral<AnnotatedConstructorInterceptorFactory<Counted>>() {})
.in(Singleton.class);
bind(ExceptionMeteredInterceptorFactory.class)
.to(new TypeLiteral<AnnotatedMethodInterceptorFactory<ExceptionMetered>>() {})
.to(new TypeLiteral<AnnotatedConstructorInterceptorFactory<ExceptionMetered>>() {})
.in(Singleton.class);
bind(MeteredInterceptorFactory.class)
.to(new TypeLiteral<AnnotatedMethodInterceptorFactory<Metered>>() {})
.to(new TypeLiteral<AnnotatedConstructorInterceptorFactory<Metered>>() {})
.in(Singleton.class);
bind(TimedInterceptorFactory.class)
.to(new TypeLiteral<AnnotatedMethodInterceptorFactory<Timed>>() {})
.to(new TypeLiteral<AnnotatedConstructorInterceptorFactory<Timed>>() {})
.in(Singleton.class);
}
示例12: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
bind(dataSourceFactoryProvider);
bindFactory(JDBIFactory.class)
.to(DBI.class)
.in(Singleton.class);
bind(JDBIInjectionResolver.class)
.to(new TypeLiteral<InjectionResolver<InjectDAO>>() {})
.in(Singleton.class);
}
示例13: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Override
protected void configure() {
bind(profile).to(ProfileFactoryBuilder.class);
bind(optProfile).to(OptionalProfileFactoryBuilder.class);
bind(manager).to(ProfileManagerFactoryBuilder.class);
bind(Pac4JProfileValueFactoryProvider.class).to(ValueFactoryProvider.class).in(Singleton.class);
bind(ProfileInjectionResolver.class).to(new TypeLiteral<InjectionResolver<Pac4JProfile>>() {
}).in(Singleton.class);
bind(ProfileManagerInjectionResolver.class).to(new TypeLiteral<InjectionResolver<Pac4JProfileManager>>() {
}).in(Singleton.class);
}
示例14: configure
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
/**
* Configures default binding for dependencies required by {@link JerseyApplicationBase}.
*/
@Override
protected void configure() {
bind(new LateBoundApplicationResolver())
.to(ApplicationResolver.class)
.to(LateBoundApplicationResolver.class);
bind(new ResourceConfig())
.to(ResourceConfig.class);
bindFactory(configContextFactory)
.to(new TypeLiteral<ConfigContext<ConfigT>>() { })
.in(Singleton.class);
}
示例15: configContextInstanceIsBoundToConfigContextMockConfigAsSingleton
import org.glassfish.hk2.api.TypeLiteral; //导入依赖的package包/类
@Test
public void configContextInstanceIsBoundToConfigContextMockConfigAsSingleton() {
ConfigContext<MockConfig> configContext1 = serviceLocator.getService(
new TypeLiteral<ConfigContext<MockConfig>>() { }.getRawType());
ConfigContext<MockConfig> configContext2 = serviceLocator.getService(
new TypeLiteral<ConfigContext<MockConfig>>() { }.getRawType());
assertThat(configContext1)
.isNotNull()
.isEqualTo(configContext2);
}