classafIoc::Configuration
sys::Obj afIoc::Configuration
Passed to AppModule
@Contribute methods to allow the method to contribute configuration.
The service defines the type of contribution by declaring a parameterised list or map in its ctor or builder method. Contributions must be compatible with the type.
@since 1.7.0
- add
Constraints add(Obj value)
Adds a value to the service configuration with optional ordering constraints.
Because the keys of added values are unknown, they cannot be overridden. For that reason it is advised to use
set()
instead.value
is coerced to the service's contribution type.- addPlaceholder
Constraints addPlaceholder(Str key)
Adds a placeholder. Placeholders are empty configurations used to aid ordering of actual values:
config.placeholder("end") config.set("wot", ever).before("end") config.set("last", last).after("end")
While not very useful in the same contribution method, they become very powerful when used across multiple modules and pods.
Placeholders do not appear in the the resulting configuration and are never seen by the end service.
- autobuild
Obj autobuild(Type type, Obj?[]? ctorArgs := null, [Field:Obj?]? fieldVals := null)
A convenience method for Registry.autobuild.
- createProxy
Obj createProxy(Type mixinType, Type? implType := null, Obj?[]? ctorArgs := null, [Field:Obj?]? fieldVals := null)
A convenience method for Registry.autobuild.
- overrideValue
Constraints overrideValue(Obj existingKey, Obj? newValue, Obj? newKey := null)
Overrides and replaces a contributed value. The existing key must exist.
existingKey
is the id / key of the value to be replaced. It may have been initially provided byset()
or have be thenewKey
of a previous override.newKey
does not appear in the the resulting configuration and is never seen by the end service. It is only used as reference to this override, so this override itself may be overridden. 3rd party libraries, when overriding, should always supply anewKey
.newKey
may be anyObj
instance but sane and intelligent people will always pass in aStr
.newValue
is coerced to the service's contribution type.- registry
Registry registry()
A convenience method that returns the IoC Registry.
- remove
Void remove(Obj existingKey, Obj? newKey := null)
A special kind of override whereby, should this be the last override applied, the value is removed from the configuration.
existingKey
is the id / key of the value to be replaced. It may have been initially provided byset()
or have be thenewKey
of a previous override.newKey
does not appear in the the resulting configuration and is never seen by the end service. It is only used as reference to this override, so this override itself may be overridden. 3rd party libraries, when overriding, should always supply anewKey
.newKey
may be anyObj
instance but sane and intelligent people will always pass in aStr
.- set
@
Operator
Constraints set(Obj key, Obj? value)Sets a key / value pair to the service configuration with optional ordering constraints.
If the end service configuration is a List, then the keys are discarded and only the values passed use. In this case, typically
Str
keys are used for ease of use when overriding / adding constraints.Configuration contributions are ordered across modules.
key
andvalue
are coerced to the service's contribution type.