Package com.google.inject.internal
Class DynamicClassProvider
- java.lang.Object
-
- com.google.inject.internal.DynamicClassProvider
-
- All Implemented Interfaces:
com.google.inject.Provider<java.lang.Object>,javax.inject.Provider<java.lang.Object>
- Direct Known Subclasses:
DynamicSingletonProvider
public class DynamicClassProvider extends java.lang.Object implements com.google.inject.Provider<java.lang.Object>Provider allows using interfaces or abstract classes as normal guice beans. Simply annotate interface or abstract class with@ProvidedBy(DynamicClassProvider.class)and use it as usual guice bean.Original bean will be correctly handled by guice aop: provider will generate new class, which guice could use for proxy generation.
If used with injectors hierarchy or within private modules, use together with
GeneratorAnchorModuleto properly scope dynamic bindings.Providers use guice package to use internal guice api (to resolve actual required type)
- Since:
- 07.12.2014
- See Also:
if you prefer direct registration in module
-
-
Constructor Summary
Constructors Constructor Description DynamicClassProvider(com.google.inject.Injector injector)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectget()protected java.lang.Class<? extends java.lang.annotation.Annotation>getScopeAnnotation()Override it to specify different annotation.
-
-
-
Method Detail
-
get
public java.lang.Object get()
- Specified by:
getin interfacecom.google.inject.Provider<java.lang.Object>- Specified by:
getin interfacejavax.inject.Provider<java.lang.Object>
-
getScopeAnnotation
protected java.lang.Class<? extends java.lang.annotation.Annotation> getScopeAnnotation()
Override it to specify different annotation. By default, no annotation specified which will implicitly lead to default prototype scope.- Returns:
- scope annotation which should be applied to generated class
-
-