KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > portlet > context > PortletContextResourceLoader


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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     /**
45      * Create a new PortletContextResourceLoader.
46      * @param portletContext the PortletContext to load resources with
47      */

48     public PortletContextResourceLoader(PortletContext portletContext) {
49         this.portletContext = portletContext;
50     }
51
52     /**
53      * This implementation supports file paths beneath the root of the web application.
54      * @see PortletContextResource
55      */

56     protected Resource getResourceByPath(String JavaDoc path) {
57         return new PortletContextResource(this.portletContext, path);
58     }
59
60 }
61
Popular Tags