01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.resource;
19:
20: import java.io.InputStream;
21: import java.util.List;
22:
23: /**
24: * Locates resources that are used at runtime. The
25: * <code>ResourceManager</code> queries registered
26: * <code>ResourceResolver</code> to find resources.
27: */
28: public interface ResourceManager {
29:
30: /**
31: * Resolve a resource. The ResourceManager will query all of the
32: * registered <code>ResourceResovler</code> objects until one
33: * manages to resolve the resource
34: *
35: * @param name name of resource to resolve.
36: * @param type type of resource to resolve.
37: * @return the resolved resource or null if nothing found.
38: */
39: <T> T resolveResource(String name, Class<T> type);
40:
41: /**
42: * Resolve a resource with via a specified list of resovlers. This allows
43: * resources to be specified with a locally defined list of resolvers.
44: *
45: * @param name name of resource to resolve.
46: * @param type type of resource to resolve.
47: * @param resolvers list of <code>ResourceResolvers</codea> to search.
48: * @return the resolved resource or null if nothing found.
49: */
50: <T> T resolveResource(String name, Class<T> type,
51: List<ResourceResolver> resolvers);
52:
53: /**
54: * Open stream to resource.
55: *
56: * @param name name of resource to resolve.
57: * @return the InputStream to the resource or null if the resource
58: * cannot be found.
59: */
60: InputStream getResourceAsStream(String name);
61:
62: /**
63: * Add a <code>ResourceResolver</code>. The newly added resolver
64: * is added at the head of the list so the most recently added
65: * will be queried first.
66: * @param resolver the <code>ResourceResolver</code> to
67: * add. Duplicates will be ignored.
68: */
69: void addResourceResolver(ResourceResolver resolver);
70:
71: /**
72: * Remove a <code>ResourceResolver</code>.
73: * @param resolver the <code>ResourceResolver</code> to remove.
74: * If not previously registered, it is ignored.
75: */
76: void removeResourceResolver(ResourceResolver resolver);
77:
78: /**
79: * Get all the currently registered resolvers. This method should return
80: * a copy of the list of resolvers so that resolvers added after this method
81: * has been called will alter the list returned.
82: */
83: List<ResourceResolver> getResourceResolvers();
84: }
|