
[[_resources_resources_aware_transformation]]
= The @ResourcesAware AST Transformation

Any component may gain the ability to locate resources through a +ResourceHandler+
instance. You only need annotate the class with +{link_resources_aware}+
and it will automatically gain all methods exposed by +{link_resource_handler}+.

This feature is just a shortcut to avoid reaching for the application instance
from objects that do not hold a reference to it.

Here's an example of a custom bean that's able to locate resources

[source,groovy]
[subs="verbatim,attributes"]
----
@griffon.transform.ResourcesAware
class Bean {
    String name
}
----

This class can be used in the following way

[source,groovy]
[subs="verbatim,attributes"]
----
class SampleService {
    @Inject Bean bean

    InputStream fetchResource(String arg) {
        bean.name = arg
        bean.getResourceAsStream(bean.name)
    }
}
----
