ScopedProxyMode enum
Whether a bean of a custom (or prototype) scope is injected directly or
through a scoped proxy (@Scope(proxyMode:)).
A singleton keeps what it was injected with, so a screen-scoped bean
injected directly stays the first screen's instance forever (the
container logs a warning). With a proxy, every injection point and
lookup gets one shared object implementing the bean's class; each call
on it asks the scope for the current instance. The generator writes
the proxy class (the type must be implementable from generated code,
like for @Lazy injection points); by hand it is
BeanDefinition.scopedProxy. An ObjectProvider<T> is the other way
to reach the current instance.
// A singleton that always talks to the state of the current screen.
@Component()
@Scope('screen', proxyMode: ScopedProxyMode.targetClass)
class ScreenState { ... }
@Service()
class Analytics {
Analytics(this.state); // the proxy: the current screen's state
final ScreenState state;
}
Spring (Java):
@Component
@Scope(value = "screen", proxyMode = ScopedProxyMode.TARGET_CLASS)
class ScreenState { ... }
Differences from Spring: there is no DEFAULT (a Dart keyword; no is
the default); interfaces and targetClass both generate a class
implementing the bean's type (Dart classes are interfaces too); the
target is not registered as a separate scopedTarget. bean.
Values
- no → const ScopedProxyMode
-
No proxy: the instance is injected directly. The default.
- interfaces → const ScopedProxyMode
-
A proxy implementing the bean's type (Spring's JDK interface proxy).
- targetClass → const ScopedProxyMode
-
A proxy implementing the bean's class (Spring's CGLIB proxy).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
ScopedProxyMode> - A constant List of the values in this enum, in order of their declaration.