|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=RUNTIME) @Target(value={METHOD,TYPE,FIELD,PARAMETER}) @Documented @Qualifier public @interface Resource
An injection point qualifier that may be used to specify a resource to
inject. The injection point can specify either a URL
, an
InputStream
or a Properties
bundle (if the resource points to
a properties bundle). For example:
@Inject @Resource("WEB-INF/beans.xml") URL beansXml; @Inject @Resource("WEB-INF/web.xml") InputStream webXml; @Inject @Resource("META-INF/aws.properties") Properties awsProperties;
If a input stream is loaded, it will be automatically closed when the InputStream goes out of scope. If a URL is used to create an input stream, the application is responsible for closing it. For this reason it is recommended that managed input streams are used where possible.
If you don't know the name of the resource to load at development time, then
you may wish to use ResourceProvider
which can dynamically load
resources.
ResourceProvider
Required Element Summary | |
---|---|
String |
value
|
Element Detail |
---|
public abstract String value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |