Package org.eclipse.sisu.space
Class QualifiedTypeBinder
- java.lang.Object
-
- org.eclipse.sisu.space.QualifiedTypeBinder
-
- All Implemented Interfaces:
QualifiedTypeListener
public final class QualifiedTypeBinder extends java.lang.Object implements QualifiedTypeListener
-
-
Field Summary
Fields Modifier and Type Field Description private com.google.inject.Binder
binder
private java.lang.Object
currentSource
private static boolean
HAS_JSR299_TYPED
private MediationListener
mediationListener
private static com.google.inject.TypeLiteral<java.lang.Object>
OBJECT_TYPE_LITERAL
private com.google.inject.Binder
rootBinder
-
Constructor Summary
Constructors Constructor Description QualifiedTypeBinder(com.google.inject.Binder binder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
bindProviderType(java.lang.Class<?> providerType)
Binds the given provider type using a binding key determined by common-use heuristics.private void
bindQualifiedType(java.lang.Class<?> qualifiedType)
Binds the given qualified type using a binding key determined by common-use heuristics.private static <T> com.google.inject.Key<T>
getBindingKey(com.google.inject.TypeLiteral<T> bindingType, java.lang.annotation.Annotation qualifier)
private static com.google.inject.name.Named
getBindingName(java.lang.Class<?> qualifiedType)
private static java.lang.Class<?>[]
getBindingTypes(java.lang.Class<?> clazz)
void
hear(java.lang.Class qualifiedType, java.lang.Object source)
Invoked when theQualifiedTypeVisitor
finds a qualified type.private void
installModule(java.lang.Class<com.google.inject.Module> moduleType)
Installs an instance of the givenModule
.private static boolean
isEagerSingleton(java.lang.Class<?> type)
private static boolean
isSingleton(java.lang.Class<?> type)
private void
mediate(com.google.inject.Key watchedKey, Mediator mediator, java.lang.Class watcherType)
Uses the given mediator to mediate updates between theBeanLocator
and associated watchers.private <T> T
newInstance(java.lang.Class<T> type)
Attempts to create a new instance of the given type.private void
registerLegacyMediator(java.lang.Class<Mediator> mediatorType)
private void
registerMediator(java.lang.Class<Mediator> mediatorType)
Registers an instance of the givenMediator
using its generic type arguments as configuration.private static com.google.inject.TypeLiteral<?>[]
resolveTypeArguments(java.lang.Class<?> type, java.lang.Class<?> superType)
Resolves the type arguments of a super type based on the given concrete type.private static <T> com.google.inject.Key<T>
watchedKey(com.google.inject.TypeLiteral<T> type, java.lang.Class qualifierType)
-
-
-
Field Detail
-
OBJECT_TYPE_LITERAL
private static final com.google.inject.TypeLiteral<java.lang.Object> OBJECT_TYPE_LITERAL
-
HAS_JSR299_TYPED
private static final boolean HAS_JSR299_TYPED
-
rootBinder
private final com.google.inject.Binder rootBinder
-
mediationListener
private MediationListener mediationListener
-
currentSource
private java.lang.Object currentSource
-
binder
private com.google.inject.Binder binder
-
-
Method Detail
-
hear
public void hear(java.lang.Class qualifiedType, java.lang.Object source)
Description copied from interface:QualifiedTypeListener
Invoked when theQualifiedTypeVisitor
finds a qualified type.- Specified by:
hear
in interfaceQualifiedTypeListener
- Parameters:
qualifiedType
- The qualified typesource
- The source of this type- See Also:
Binder.withSource(Object)
-
installModule
private void installModule(java.lang.Class<com.google.inject.Module> moduleType)
Installs an instance of the givenModule
.- Parameters:
moduleType
- The module type
-
registerMediator
private void registerMediator(java.lang.Class<Mediator> mediatorType)
Registers an instance of the givenMediator
using its generic type arguments as configuration.- Parameters:
mediatorType
- The mediator type
-
registerLegacyMediator
private void registerLegacyMediator(java.lang.Class<Mediator> mediatorType)
-
mediate
private void mediate(com.google.inject.Key watchedKey, Mediator mediator, java.lang.Class watcherType)
Uses the given mediator to mediate updates between theBeanLocator
and associated watchers.- Parameters:
watchedKey
- The watched keymediator
- The bean mediatorwatcherType
- The watcher type
-
bindProviderType
private void bindProviderType(java.lang.Class<?> providerType)
Binds the given provider type using a binding key determined by common-use heuristics.- Parameters:
providerType
- The provider type
-
bindQualifiedType
private void bindQualifiedType(java.lang.Class<?> qualifiedType)
Binds the given qualified type using a binding key determined by common-use heuristics.- Parameters:
qualifiedType
- The qualified type
-
newInstance
private <T> T newInstance(java.lang.Class<T> type)
Attempts to create a new instance of the given type.- Parameters:
type
- The instance type- Returns:
- New instance;
null
if the instance couldn't be created
-
resolveTypeArguments
private static com.google.inject.TypeLiteral<?>[] resolveTypeArguments(java.lang.Class<?> type, java.lang.Class<?> superType)
Resolves the type arguments of a super type based on the given concrete type.- Parameters:
type
- The concrete typesuperType
- The generic super type- Returns:
- Resolved super type arguments
-
getBindingKey
private static <T> com.google.inject.Key<T> getBindingKey(com.google.inject.TypeLiteral<T> bindingType, java.lang.annotation.Annotation qualifier)
-
getBindingName
private static com.google.inject.name.Named getBindingName(java.lang.Class<?> qualifiedType)
-
getBindingTypes
private static java.lang.Class<?>[] getBindingTypes(java.lang.Class<?> clazz)
-
isSingleton
private static boolean isSingleton(java.lang.Class<?> type)
-
isEagerSingleton
private static boolean isEagerSingleton(java.lang.Class<?> type)
-
watchedKey
private static <T> com.google.inject.Key<T> watchedKey(com.google.inject.TypeLiteral<T> type, java.lang.Class qualifierType)
-
-