public enum Scope extends Enum<Scope>
This enum specifies the scope of a dependency injection. During the injection, the injector should decide that it will use a previously created value, of will create a whole new instance. It is allowed to use existing values only from the injection's current scope. If there is no valid value for the injection, a new instance will be created.
These are the scopes:
About the ibello dependency injection system, see hu.ibello.inject.
| Enum Constant and Description |
|---|
ELEMENTS
Marks an element repository class with
Injectable annotation. |
PAGE
Marks a page object class with
Injectable annotation. |
PROTOTYPE
Marks a prototype-scoped class with
Injectable annotation. |
SESSION
Marks a session-scoped class with
Injectable annotation. |
SINGLETON
Marks a singleton class with
Injectable annotation. |
SPECIFICATION
Marks a specification-scoped class with
Injectable annotation. |
STEPS
Marks a step library class with
Injectable annotation. |
TEST
Marks a test-scoped class with
Injectable annotation. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accepts(Scope childScope)
Checks if this scope accepts the given scope as child.
|
static Scope |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Scope[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Scope PROTOTYPE
Injectable annotation.
Prototype scope means that every time when an instance of the marked class needs to be injected, a new instance will be created.
About the ibello dependency injection system, see hu.ibello.inject.
public static final Scope TEST
Injectable annotation.
Test scope means that during a test method execution the same instance is used.
Instances are not shared between test executions.
About the ibello dependency injection system, see hu.ibello.inject.
public static final Scope SPECIFICATION
Injectable annotation.
Specification scope means that during the execution of a specification (a test class) the same instance is used.
Instances are not shared between specification executions.
About the ibello dependency injection system, see hu.ibello.inject.
public static final Scope SESSION
Injectable annotation.
Session scope means that during a session (in a single thread) the same instance is used.
Instances are not shared between sessions.
About the ibello dependency injection system, see hu.ibello.inject.
public static final Scope SINGLETON
Injectable annotation.
Singleton scope means that during the whole test execution the same instance is used.
About the ibello dependency injection system, see hu.ibello.inject.
public static final Scope PAGE
Injectable annotation.
The marked class will be in session scope. It means that during a session (in a single thread) the same instance is used.
Instances are not shared between sessions.
Additionally the class is considered as a page object, and some special injections are performed on every instances.
About the ibello dependency injection system, see hu.ibello.inject.
public static final Scope ELEMENTS
Injectable annotation.
The marked class will be in prototype scope. It means that for each declared usage location of this class a new instance will be created.
Additionally the class is considered as an element repository, and some special injections are performed on every instances.
About the ibello dependency injection system, see hu.ibello.inject.
public static final Scope STEPS
Injectable annotation.
The marked class will be in session scope. It means that during a session (in a single thread) the same instance is used.
Instances are not shared between sessions.
Additionally the class is considered as a step library, and some special injections are performed on every instances.
About the ibello dependency injection system, see hu.ibello.inject.
public static Scope[] values()
for (Scope c : Scope.values()) System.out.println(c);
public static Scope valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic boolean accepts(Scope childScope)
Checks if this scope accepts the given scope as child.
Imagine that you have a class marked with Injectable annotation, with the current scope.
This class has an injected field. The injected class is also marked with Injectable annotation,
but with the given scope. If this method returns false, then the field cannot be injected because it's scope
does not fit into this scope.
Example: you cannot inject a test-scoped field into a singleton class, because instance in test scope are valid only during a single test run, while singleton instances are valid for the entire execution.
About the ibello dependency injection system, see hu.ibello.inject.
childScope - the scope which will be verified as child scopetrue if instances from childScope can be injected into this scope, false if notCreated by Kornél Simon, 2022