Class GuiceDependencyInjector
java.lang.Object
com.github.thought2code.mcp.annotated.di.GuiceDependencyInjector
- All Implemented Interfaces:
DependencyInjector
This class implements the
DependencyInjector interface using Google Guice.- Author:
- codeboyzhou
-
Constructor Summary
ConstructorsConstructorDescriptionGuiceDependencyInjector(com.google.inject.Injector injector) Creates a new instance ofGuiceDependencyInjectorwith the specified GuiceInjector. -
Method Summary
Modifier and TypeMethodDescription<T> TgetInstance(Class<T> type) Returns an instance of the specified type.<T> TgetVariable(Class<T> type, String name) Returns the value of the specified variable.booleanReturns whether the dependency injector is initialized.
-
Constructor Details
-
GuiceDependencyInjector
public GuiceDependencyInjector(com.google.inject.Injector injector) Creates a new instance ofGuiceDependencyInjectorwith the specified GuiceInjector.- Parameters:
injector- the GuiceInjectorto use for dependency injection
-
-
Method Details
-
getInstance
Description copied from interface:DependencyInjectorReturns an instance of the specified type.- Specified by:
getInstancein interfaceDependencyInjector- Type Parameters:
T- the type of the instance to return- Parameters:
type- the class of the instance to return- Returns:
- an instance of the specified type
-
getVariable
Description copied from interface:DependencyInjectorReturns the value of the specified variable.- Specified by:
getVariablein interfaceDependencyInjector- Type Parameters:
T- the type of the variable to return- Parameters:
type- the class of the variable to returnname- the name of the variable to return- Returns:
- the value of the specified variable
-
isInitialized
public boolean isInitialized()Description copied from interface:DependencyInjectorReturns whether the dependency injector is initialized.- Specified by:
isInitializedin interfaceDependencyInjector- Returns:
trueif the dependency injector is initialized,falseotherwise
-