Interface CandidateRegistry
-
- All Known Subinterfaces:
Injector
- All Known Implementing Classes:
StandardInjector
public interface CandidateRegistryProvides methods to manage injection candidates, like registering and removing.Depending on the underlying store used certain invariants will be automatically enforced. For example, removing a candidate which is currently required as a dependency could result in an exception if the store is enforcing that all known candidates must be resolvable.
Depending on which extensions are active, more candidates will be derived from any given candidate when certain annotations or interfaces are implemented. For example, registering a candidate which has produces annotated members will also register the types produced. The same could apply to candidates implementing a provider interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontains(java.lang.reflect.Type type, java.lang.Object... qualifiers)Returnstruewhen the given type with the given qualifiers is present, otherwisefalse.voidregister(java.lang.reflect.Type type)Registers aType, and all its derived candidates if any, if all its dependencies can be resolved and it would not cause existing registered types to have ambiguous dependencies as a result of registering the given type.voidregister(java.util.Collection<java.lang.reflect.Type> types)Registers the givenTypes, and all their derived candidates if any, if all their dependencies can be resolved and it would not cause existing registered types to have ambiguous dependencies as a result of registering the given types.voidregisterInstance(java.lang.Object instance, java.lang.annotation.Annotation... qualifiers)Registers an instance, and all its derived candidates if any, as a singleton if it would not cause existing registered types to have ambiguous dependencies as a result.voidremove(java.lang.reflect.Type type)Removes the givenType, and all its derived candidates if any, if doing so would not result maintains all invariants for the remaining registered types.voidremove(java.util.Collection<java.lang.reflect.Type> types)Removes the givenTypes, all their derived candidates if any, if doing so would not result maintains all invariants for the remaining registered types.voidremoveInstance(java.lang.Object instance, java.lang.annotation.Annotation... qualifiers)Removes an instance, and all its derived candidates if any, if doing so would not result in broken dependencies in the remaining registered types.
-
-
-
Method Detail
-
contains
boolean contains(java.lang.reflect.Type type, java.lang.Object... qualifiers)Returnstruewhen the given type with the given qualifiers is present, otherwisefalse.- Parameters:
type- a type to check for, cannot benullqualifiers- optional list of qualifier annotations, eitherAnnotationorClass<? extends Annotation>- Returns:
truewhen the given type with the given criteria is present, otherwisefalse
-
register
void register(java.lang.reflect.Type type) throws AutoDiscoveryException, DefinitionException, DependencyExceptionRegisters aType, and all its derived candidates if any, if all its dependencies can be resolved and it would not cause existing registered types to have ambiguous dependencies as a result of registering the given type.If there are unresolvable dependencies, or registering this type would result in ambiguous dependencies for previously registered types, then this method will throw an exception.
- Parameters:
type- the type to register, cannot benull- Throws:
AutoDiscoveryException- when auto discovery fails to find all required typesDefinitionException- when a definition problem was encounteredDependencyException- when dependencies between registered types cannot be resolved
-
register
void register(java.util.Collection<java.lang.reflect.Type> types) throws AutoDiscoveryException, DefinitionException, DependencyExceptionRegisters the givenTypes, and all their derived candidates if any, if all their dependencies can be resolved and it would not cause existing registered types to have ambiguous dependencies as a result of registering the given types.If there are unresolvable dependencies, or registering these types would result in ambiguous dependencies for previously registered types, then this method will throw an exception.
- Parameters:
types- a collection of types to register, cannot benullor containnulls- Throws:
AutoDiscoveryException- when auto discovery fails to find all required typesDefinitionException- when a definition problem was encounteredDependencyException- when dependencies between registered types cannot be resolved
-
registerInstance
void registerInstance(java.lang.Object instance, java.lang.annotation.Annotation... qualifiers) throws DefinitionException, DependencyExceptionRegisters an instance, and all its derived candidates if any, as a singleton if it would not cause existing registered types to have ambiguous dependencies as a result.If registering this instance would result in ambiguous dependencies for previously registered classes, then this method will throw an exception.
- Parameters:
instance- the instance to register with the Injectorqualifiers- optional list of qualifiers for this instance- Throws:
DefinitionException- when a definition problem was encounteredDependencyException- when dependencies between registered types cannot be resolved
-
remove
void remove(java.lang.reflect.Type type) throws AutoDiscoveryException, DefinitionException, DependencyExceptionRemoves the givenType, and all its derived candidates if any, if doing so would not result maintains all invariants for the remaining registered types.If there would be broken dependencies then the removal will fail and an exception is thrown.
- Parameters:
type- the type to remove, cannot benull- Throws:
AutoDiscoveryException- when auto discovery fails to find all required typesDefinitionException- when a definition problem was encounteredDependencyException- when dependencies between registered types cannot be resolved
-
remove
void remove(java.util.Collection<java.lang.reflect.Type> types) throws AutoDiscoveryException, DefinitionException, DependencyExceptionRemoves the givenTypes, all their derived candidates if any, if doing so would not result maintains all invariants for the remaining registered types.If there would be broken dependencies then the removal will fail and an exception is thrown.
- Parameters:
types- a collection of types to remove, cannot benullor containnulls- Throws:
AutoDiscoveryException- when auto discovery fails to find all required typesDefinitionException- when a definition problem was encounteredDependencyException- when dependencies between registered types cannot be resolved
-
removeInstance
void removeInstance(java.lang.Object instance, java.lang.annotation.Annotation... qualifiers) throws DefinitionException, DependencyExceptionRemoves an instance, and all its derived candidates if any, if doing so would not result in broken dependencies in the remaining registered types.If there would be broken dependencies then the removal will fail and an exception is thrown.
- Parameters:
instance- the instance to remove, cannot benullqualifiers- optional list of qualifiers for this instance- Throws:
DefinitionException- when a definition problem was encounteredDependencyException- when dependencies between registered types cannot be resolved
-
-