...
Code Block |
|
|
@Model(adaptables=SlingHttpServletRequest.class)
public interface MyModel {
// will return request.getResource().adaptTo(ValueMap.class).get("propertyName", String.class)
@Inject @Via("resource")
String getPropertyName();
} |
If there is ambiguity where a given injection could be handled by more than one injector, the @Source annotation can be used to define which injector is responsible:
Code Block |
|
|
@Model(adaptables=SlingHttpServletRequest.class)
public interface MyModel {
// Ensure that "resource" is retrived from the bindings, not a request attribute
@Inject @Source("script-bindings")
Resource getResource();
}
|
If the injected object does not match the desired type and the object implements the Adaptable interface, YAMF will try to adapt it. This provides the ability to create rich object graphs. For example:
...