Implemented by an object that wants the context's resource loader (to
read files such as resources:templates/mail.txt) handed to it through
a method call.
A bean can simply inject ResourceLoader, or a single file with
@Value('resources:...') Resource. This callback matters for an
ImportSelector or a registrar, which are not injected. The loader is
the context itself, so custom protocols added to it work.
// Loads mail templates by name when they are needed.
@Component()
class Templates implements ResourceLoaderAware {
late ResourceLoader loader;
@override
void setResourceLoader(ResourceLoader resourceLoader) =>
loader = resourceLoader;
}
Spring (Java):
@Component
class Templates implements ResourceLoaderAware {
public void setResourceLoader(ResourceLoader resourceLoader) { ... }
}
- Implemented types
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- 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
-
setResourceLoader(
ResourceLoader resourceLoader) → void - Receives the context, which is the resource loader; called once, after injection and before the init callbacks.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited