本文整理汇总了Java中org.glassfish.hk2.api.DynamicConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java DynamicConfiguration类的具体用法?Java DynamicConfiguration怎么用?Java DynamicConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DynamicConfiguration类属于org.glassfish.hk2.api包,在下文中一共展示了DynamicConfiguration类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public boolean bind(final Class<?> component, final Set<Class<?>> providerContracts) {
if (!managedClasses().contains(component)) {
return false;
}
LOG.trace("Binding {} {} to dependency injection", component, providerContracts);
final DynamicConfiguration dynamicConfig = Injections.getConfiguration(locator);
final DependencyInjectionFactory<Object> factory = new DependencyInjectionFactory<>(
(Class<Object>) component,
dependencyInjection()
);
final ServiceBindingBuilder<Object> binding = Injections.newFactoryBinder(factory)
.to(component);
(providerContracts == null ? Collections.<Class<?>>emptySet() : providerContracts).forEach(binding::to);
Injections.addBinding(binding, dynamicConfig);
dynamicConfig.commit();
return true;
}
示例2: link
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
/**
* @see #link(ServiceLocator, Injector)
* @see #newChildInjector(Injector, ServiceLocator)
*/
private static ServiceLocator link(ServiceLocator locator,
Injector injector, Iterable<? extends Binder> binders) {
DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
DynamicConfiguration dc = dcs.createDynamicConfiguration();
GuiceJustInTimeResolver resolver = new GuiceJustInTimeResolver(locator, injector);
dc.bind(BuilderHelper.createConstantDescriptor(resolver));
dc.addActiveDescriptor(GuiceScopeContext.class);
bind(locator, dc, new MessagingBinders.HeaderDelegateProviders());
for (Binder binder : binders) {
bind(locator, dc, binder);
}
dc.commit();
return locator;
}
示例3: RestApplication
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
@Inject
public RestApplication(ServiceLocator serviceLocator) {
DynamicConfiguration dc = Injections.getConfiguration(serviceLocator);
Injections.addBinding(Injections.newBinder(DatabaseClientService.class).to(IClientService.class),dc);
Injections.addBinding(Injections.newBinder(Configuration.class).to(IConfiguration.class),dc);
Injections.addBinding(Injections.newBinder(Configuration.class).to(IRSConfiguration.class),dc);
Injections.addBinding(Injections.newBinder(DefaultPrincipalUserService.class).to(IUserService.class),dc);
Injections.addBinding(Injections.newBinder(CachingAccessTokenStorage.class).to(IAccessTokenStorageService.class),dc);
Injections.addBinding(Injections.newBinder(IntegratedAccessTokenVerifier.class).to(IAccessTokenVerifier.class),dc);
Injections.addBinding(Injections.newBinder(RequestFactory.class).to(IRequestFactory.class),dc);
Injections.addBinding(Injections.newBinder(MD5TokenGenerator.class).to(ITokenGenerator.class),dc);
Injections.addBinding(Injections.newBinder(UUIDClientIdGenerator.class).to(IClientIdGenerator.class),dc);
EntityManagerFactory emf = new PersistenceProvider().get();
Injections.addBinding(Injections.newBinder(emf).to(EntityManagerFactory.class),dc);
CacheManager cacheManager = new DefaultCacheManagerProvider().get();
Injections.addBinding(Injections.newBinder(cacheManager).to(CacheManager.class),dc);
dc.commit();
}
示例4: finishBinding
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
/**
* Completes the {@link #activeBuilder} and adds it to the {@link #getLocator() service locator}
*/
private void finishBinding() {
if (activeBuilder != null) {
DynamicConfiguration config = ServiceLocatorUtilities.createDynamicConfiguration(getLocator());
BindingBuilderFactory.addBinding(activeBuilder, config);
config.commit();
activeBuilder = null;
}
}
示例5: bind
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
@Override
default void bind(DynamicConfiguration config) {
new AbstractBinder() {
@Override
protected void configure() {
configureBindings(this);
}
}.bind(config);
}
示例6: bind
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
@Override
public void bind(DynamicConfiguration config) {
Injections.addBinding(
Injections.newFactoryBinder(this).to(type).in(Singleton.class),
config);
Injections.addBinding(
Injections.newBinder(this).to(ValueFactoryProvider.class),
config);
}
示例7: RESTApplication
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
@Inject
public RESTApplication(ServiceLocator serviceLocator) {
log.info("Initialisation de l'application");
classes.add(LdapResource.class);
classes.add(NameNotFoundMapper.class);
classes.add(MultiPartFeature.class);
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
singletons.add(provider);
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(SPRING_CONFIG);
Rest2LdapConfig config = ctx.getBean("rest2ldapConfig", Rest2LdapConfig.class);
ILdapDAO ldapDAO = ctx.getBean(ILdapDAO.class);
DynamicConfiguration dc = Injections.getConfiguration(serviceLocator);
Injections.addBinding(
Injections.newBinder(ctx).to(ApplicationContext.class), dc);
Injections.addBinding(
Injections.newBinder(config).to(Rest2LdapConfig.class), dc);
Injections.addBinding(
Injections.newBinder(ldapDAO).to(ILdapDAO.class), dc);
dc.commit();
testLdapConnection(ctx);
}
示例8: bind
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
@Override
public void bind(DynamicConfiguration configuration) {
super.bind(configuration);
BootstrapExtensions.getImplementingBundles(bootstrap, SimpleBinder.class).forEach(bundle -> bundle.bind(configuration));
}
示例9: bind
import org.glassfish.hk2.api.DynamicConfiguration; //导入依赖的package包/类
/**
* @see ServiceLocator#inject(Object)
* @see Binder#bind(DynamicConfiguration)
*/
private static void bind(ServiceLocator locator, DynamicConfiguration dc, Binder binder) {
locator.inject(binder);
binder.bind(dc);
}