01: package org.objectweb.celtix.resource;
02:
03: import java.io.InputStream;
04: import java.util.List;
05:
06: /**
07: * Locates resources that are used at runtime. The
08: * <code>ResourceManager</code> queries registered
09: * <code>ResourceResolver</code> to find resources.
10: */
11: public interface ResourceManager {
12:
13: /**
14: * Resolve a resource. The ResourceManager will query all of the
15: * registered <code>ResourceResovler</code> objects until one
16: * manages to resolve the resource
17: *
18: * @param name name of resource to resolve.
19: * @param type type of resource to resolve.
20: * @return the resolved resource or null if nothing found.
21: */
22: <T> T resolveResource(String name, Class<T> type);
23:
24: /**
25: * Open stream to resource.
26: *
27: * @param name name of resource to resolve.
28: * @return the InputStream to the resource or null if the resource
29: * cannot be found.
30: */
31: InputStream getResourceAsStream(String name);
32:
33: /**
34: * Add a <code>ResourceResolver</code>. The newly added resolver
35: * is added at the head of the list so the most recently added
36: * will be queried first.
37: * @param resolver the <code>ResourceResolver</code> to
38: * add. Duplicates will be ignored.
39: */
40: void addResourceResolver(ResourceResolver resolver);
41:
42: /**
43: * Remove a <code>ResourceResolver</code>.
44: * @param resolver the <code>ResourceResolver</code> to remove.
45: * If not previously registered, it is ignored.
46: */
47: void removeResourceResolver(ResourceResolver resolver);
48:
49: /**
50: * Get all the currently registered resolvers
51: */
52: List getResourceResolvers();
53: }
|