本文整理匯總了Java中com.google.inject.Injector.getAllBindings方法的典型用法代碼示例。如果您正苦於以下問題:Java Injector.getAllBindings方法的具體用法?Java Injector.getAllBindings怎麽用?Java Injector.getAllBindings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.inject.Injector
的用法示例。
在下文中一共展示了Injector.getAllBindings方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GuiceQueryPluginFactory
import com.google.inject.Injector; //導入方法依賴的package包/類
@Inject
@SuppressWarnings("unchecked")
public GuiceQueryPluginFactory(Injector injector)
{
m_injector = injector;
Map<Key<?>, Binding<?>> bindings = injector.getAllBindings();
for (Key<?> key : bindings.keySet())
{
Class<?> bindingClass = key.getTypeLiteral().getRawType();
if (QueryPlugin.class.isAssignableFrom(bindingClass))
{
PluginName ann = (PluginName) bindingClass.getAnnotation(PluginName.class);
if (ann == null)
throw new IllegalStateException("Aggregator class " + bindingClass.getName() +
" does not have required annotation " + PluginName.class.getName());
m_plugins.put(ann.name(), (Class<QueryPlugin>)bindingClass);
}
}
}
示例2: GuiceGroupByFactory
import com.google.inject.Injector; //導入方法依賴的package包/類
@Inject
@SuppressWarnings("unchecked")
public GuiceGroupByFactory(Injector injector)
{
this.injector = injector;
Map<Key<?>, Binding<?>> bindings = injector.getAllBindings();
for (Key<?> key : bindings.keySet())
{
Class<?> bindingClass = key.getTypeLiteral().getRawType();
if (GroupBy.class.isAssignableFrom(bindingClass))
{
GroupByName name = (GroupByName)bindingClass.getAnnotation(GroupByName.class);
if (name == null)
throw new IllegalStateException("Aggregator class "+bindingClass.getName()+
" does not have required annotation "+GroupByName.class.getName());
groupBys.put(name.name(), (Class<GroupBy>)bindingClass);
}
}
}
示例3: HealthCheckServiceImpl
import com.google.inject.Injector; //導入方法依賴的package包/類
@Inject
public HealthCheckServiceImpl(Injector injector)
{
checkNotNull(injector);
Map<Key<?>, Binding<?>> bindings = injector.getAllBindings();
for (Key<?> key : bindings.keySet())
{
Class<?> bindingClass = key.getTypeLiteral().getRawType();
if (HealthStatus.class.isAssignableFrom(bindingClass))
{
checks.add((HealthStatus) injector.getInstance(bindingClass));
}
}
}
示例4: DataPointListenerProvider
import com.google.inject.Injector; //導入方法依賴的package包/類
@Inject
public DataPointListenerProvider(Injector injector)
{
Map<Key<?>, Binding<?>> bindings = injector.getAllBindings();
for (Key<?> key : bindings.keySet())
{
Class<?> bindingClass = key.getTypeLiteral().getRawType();
if (DataPointListener.class.isAssignableFrom(bindingClass))
{
DataPointListener listener = (DataPointListener)injector.getInstance(bindingClass);
m_listeners.add(listener);
}
}
}
示例5: GuiceCommandProvider
import com.google.inject.Injector; //導入方法依賴的package包/類
@Inject
public GuiceCommandProvider(Injector injector)
{
Map<Key<?>, Binding<?>> bindings = injector.getAllBindings();
for (Key<?> key : bindings.keySet())
{
Class<?> bindingClass = key.getTypeLiteral().getRawType();
if (TelnetCommand.class.isAssignableFrom(bindingClass))
{
TelnetCommand command = (TelnetCommand)injector.getInstance(bindingClass);
m_commandMap.put(command.getCommand(), command);
}
}
}
示例6: GuiceAggregatorFactory
import com.google.inject.Injector; //導入方法依賴的package包/類
@Inject
@SuppressWarnings("unchecked")
public GuiceAggregatorFactory(Injector injector)
{
m_injector = injector;
Map<Key<?>, Binding<?>> bindings = injector.getAllBindings();
for (Key<?> key : bindings.keySet())
{
Class<?> bindingClass = key.getTypeLiteral().getRawType();
if (Aggregator.class.isAssignableFrom(bindingClass))
{
AggregatorName ann = bindingClass.getAnnotation(AggregatorName.class);
if (ann == null)
throw new IllegalStateException("Aggregator class " + bindingClass.getName()+
" does not have required annotation " + AggregatorName.class.getName());
m_aggregators.put(ann.name(), (Class<Aggregator>)bindingClass);
ImmutableList<AggregatorPropertyMetadata> properties = getAggregatorPropertyMetadata(ann);
m_aggregatorsMetadata.add(new AggregatorMetadata(ann.name(), ann.description(), properties));
}
}
Collections.sort(m_aggregatorsMetadata, new Comparator<AggregatorMetadata>()
{
@Override
public int compare(AggregatorMetadata o1, AggregatorMetadata o2)
{
return o1.getName().compareTo(o2.getName());
}
});
}