Class InjectorImpl
- All Implemented Interfaces:
Injector
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <U> Injector
bindImplicit
(Class<?> clazz) Registers a class for implicit binding.<U> Injector
bindInstance
(Class<U> clazz, U instance) Binds a specific instance to a class type.bindScope
(Class<? extends Annotation> scopeAnnotation, Supplier<Scope> scope) Binds a scope annotation to a supplier that creates scope implementations.bindScope
(Class<? extends Annotation> scopeAnnotation, Scope scope) Binds a scope annotation to its implementation.protected <Q> Supplier<Q>
discover
(ClassLoader classLoader) Configures the injector to discover injectable components from the specified ClassLoader.protected void
doBindImplicit
(Key<?> key, Binding<?> binding) getBindings
(Key<T> key) <Q> Supplier<Q>
getCompiledBinding
(Dependency<Q> dep) <T> T
getInstance
(Class<T> key) Retrieves or creates an instance of the specified type.<T> T
getInstance
(Key<T> key) Retrieves or creates an instance for the specified key.<T> void
injectInstance
(T instance) Performs field and method injection on an existing instance.protected <Q,
T> List<Q> protected <K,
V, T> Map<K, V>
-
Constructor Details
-
InjectorImpl
public InjectorImpl()
-
-
Method Details
-
getInstance
Description copied from interface:Injector
Retrieves or creates an instance of the specified type.- Specified by:
getInstance
in interfaceInjector
- Type Parameters:
T
- the type to retrieve- Parameters:
key
- the class representing the type to retrieve- Returns:
- an instance of the requested type
-
getInstance
Description copied from interface:Injector
Retrieves or creates an instance for the specified key.This method allows retrieval of instances with specific qualifiers or generic type parameters.
- Specified by:
getInstance
in interfaceInjector
- Type Parameters:
T
- the type to retrieve- Parameters:
key
- the key identifying the instance to retrieve- Returns:
- an instance matching the requested key
-
injectInstance
Description copied from interface:Injector
Performs field and method injection on an existing instance.This method will inject dependencies into annotated fields and methods of the provided instance but will not create a new instance.
- Specified by:
injectInstance
in interfaceInjector
- Type Parameters:
T
- the type of the instance- Parameters:
instance
- the instance to inject dependencies into
-
discover
Description copied from interface:Injector
Configures the injector to discover injectable components from the specified ClassLoader.This method scans for classes annotated with injection-related annotations and automatically registers them with the injector.
-
bindScope
@Nonnull public Injector bindScope(@Nonnull Class<? extends Annotation> scopeAnnotation, @Nonnull Scope scope) Description copied from interface:Injector
Binds a scope annotation to its implementation.This allows custom scopes to be registered with the injector. The scope annotation must be annotated with
Scope
. -
bindScope
@Nonnull public Injector bindScope(@Nonnull Class<? extends Annotation> scopeAnnotation, @Nonnull Supplier<Scope> scope) Description copied from interface:Injector
Binds a scope annotation to a supplier that creates scope implementations.Similar to
Injector.bindScope(Class, Scope)
but allows lazy creation of scope implementations. -
bindInstance
Description copied from interface:Injector
Binds a specific instance to a class type.This method allows pre-created instances to be used for injection instead of having the injector create new instances.
- Specified by:
bindInstance
in interfaceInjector
- Type Parameters:
U
- the type of the instance- Parameters:
clazz
- the class to bind toinstance
- the instance to use for injection- Returns:
- this injector instance for method chaining
-
bindImplicit
Description copied from interface:Injector
Registers a class for implicit binding.Implicit bindings allow the injector to create instances of classes without explicit binding definitions. The class must have appropriate injection annotations.
- Specified by:
bindImplicit
in interfaceInjector
- Parameters:
clazz
- the class to register for implicit binding- Returns:
- this injector instance for method chaining
-
bind
-
getBindings
-
getBoundKeys
-
getBindings
-
getCompiledBinding
-
compile
-
doBindImplicit
-
map
-
list
-