01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.web.portlet.context;
18:
19: import javax.portlet.PortletContext;
20:
21: import org.springframework.core.io.DefaultResourceLoader;
22: import org.springframework.core.io.Resource;
23:
24: /**
25: * ResourceLoader implementation that resolves paths as PortletContext
26: * resources, for use outside a Portlet ApplicationContext (for example,
27: * in a GenericPortletBean subclass).
28: *
29: * <p>Within a WebApplicationContext, resource paths are automatically
30: * resolved as PortletContext resources by the context implementation.
31: *
32: * @author Juergen Hoeller
33: * @author John A. Lewis
34: * @since 2.0
35: * @see #getResourceByPath
36: * @see PortletContextResource
37: * @see org.springframework.web.portlet.GenericPortletBean
38: */
39: public class PortletContextResourceLoader extends DefaultResourceLoader {
40:
41: private final PortletContext portletContext;
42:
43: /**
44: * Create a new PortletContextResourceLoader.
45: * @param portletContext the PortletContext to load resources with
46: */
47: public PortletContextResourceLoader(PortletContext portletContext) {
48: this .portletContext = portletContext;
49: }
50:
51: /**
52: * This implementation supports file paths beneath the root of the web application.
53: * @see PortletContextResource
54: */
55: protected Resource getResourceByPath(String path) {
56: return new PortletContextResource(this.portletContext, path);
57: }
58:
59: }
|