KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > portal > portlets > AbstractInstancePortlet


1 /*
2  * Copyright 2000-2001,2004 The Apache Software Foundation.
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
18
package org.apache.jetspeed.portal.portlets;
19
20 // imports
21
import org.apache.jetspeed.portal.PortletConfig;
22
23 /**
24 * Extend AbstractPortlet to re-define the handle used for portlet caching:
25 * This handle uses the portlet's unique id and the portal page's id to form
26 * a portlet instance id for caching.
27 * @author <a HREF="mailto:taylor@apache.org">David Sean Taylor</a>
28 * @author <a HREF="mailto:ggolden@apache.org">Glenn R. Golden</a>
29 */

30 public class AbstractInstancePortlet
31     extends AbstractPortlet
32 {
33     /**
34     * Construct the handle used for caching.
35     * @param config The config object, expected to be a PortletConfig.
36     */

37     public static Object JavaDoc getHandle(Object JavaDoc config)
38     {
39         //this implementation expects a PortletConfig object as its
40
// configuration
41
PortletConfig pc = null;
42
43         if (!(config instanceof PortletConfig))
44         {
45             return null;
46         }
47
48         // form the key from the current request's portal page profile
49
// and the portlet id in the config
50
pc = (PortletConfig)config;
51
52         StringBuffer JavaDoc handle = new StringBuffer JavaDoc(256);
53         handle.append(pc.getPageId());
54         handle.append('/');
55         handle.append(pc.getPortletId());
56
57         return handle.toString();
58
59     } // getHandle
60

61 } // AbstractInstancePortlet
62

63
Popular Tags