Package io.cucumber.guice
Class GuiceFactory
java.lang.Object
io.cucumber.guice.GuiceFactory
- All Implemented Interfaces:
Container,Lookup,ObjectFactory
Guice implementation of the
io.cucumber.core.backend.ObjectFactory.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate @Nullable com.google.inject.Injectorprivate final @Nullable Class<?> private @Nullable ScenarioScopeprivate final Collection<Class<?>> private @Nullable Class<?> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd a glue class to the test context.private voidcheckOnlyOneClassHasInjectorSource(Class<?> stepClass) <T> TgetInstance(Class<T> clazz) Provides an instance of a glue class.private booleanhasInjectorSource(Class<?> stepClass) (package private) voidsetInjector(com.google.inject.Injector injector) voidstart()Start the object factory.voidstop()Stops the object factory.
-
Field Details
-
injector
private @Nullable com.google.inject.Injector injector -
stepClasses
-
injectorSourceFromProperty
-
withInjectorSource
-
scenarioScope
-
-
Constructor Details
-
GuiceFactory
public GuiceFactory()
-
-
Method Details
-
addClass
Description copied from interface:ContainerAdd a glue class to the test context.Invoked after creation but before
ObjectFactory.start(). -
hasInjectorSource
-
checkOnlyOneClassHasInjectorSource
-
setInjector
void setInjector(com.google.inject.Injector injector) -
start
public void start()Description copied from interface:ObjectFactoryStart the object factory. Invoked once per scenario.While started
Lookup.getInstance(Class)may be invoked.- Specified by:
startin interfaceObjectFactory
-
stop
public void stop()Description copied from interface:ObjectFactoryStops the object factory. Called once per scenario.When stopped the object factory should dispose of all glue instances.
- Specified by:
stopin interfaceObjectFactory
-
getInstance
Description copied from interface:LookupProvides an instance of a glue class.- Specified by:
getInstancein interfaceLookup- Type Parameters:
T- type of Glue class- Parameters:
clazz- type of instance to be created.- Returns:
- new instance of type T
-