KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > portlet > impl > PortalContextImpl


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.portlet.impl;
10
11 import java.util.Enumeration JavaDoc;
12 import java.util.HashSet JavaDoc;
13 import java.util.Iterator JavaDoc;
14 import java.util.Set JavaDoc;
15
16 import javax.portlet.PortalContext;
17
18 import org.jboss.portal.common.util.Tools;
19 import org.jboss.portal.portlet.PortletUtils;
20 import org.jboss.portal.server.Portal;
21 import org.jboss.portal.server.PortalConstants;
22 import org.jboss.portal.server.plugins.mode.Mode;
23 import org.jboss.portal.server.plugins.mode.ModeProvider;
24 import org.jboss.portal.server.plugins.mode.Modes;
25 import org.jboss.portal.server.plugins.windowstate.WindowStateProvider;
26
27 /**
28  * todo : does not provide customizable values for portlet modes and window states.
29  *
30  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
31  * @version $Revision: 1.8 $
32  */

33 public class PortalContextImpl implements PortalContext
34 {
35
36    private Portal portal;
37
38    private ModeProvider modes;
39    private WindowStateProvider windowStates;
40
41    public PortalContextImpl(Portal portal)
42    {
43       if (portal == null)
44       {
45          throw new IllegalArgumentException JavaDoc();
46       }
47       this.portal = portal;
48       this.modes = (Modes)portal.getPlugin(PortalConstants.PLUGIN_MODES);
49       this.windowStates = (WindowStateProvider)portal.getPlugin(PortalConstants.PLUGIN_WINDOW_STATES);
50       
51       // Initialize properties
52
}
53
54    public String JavaDoc getPortalInfo()
55    {
56       return PortalConstants.VERSION.toString();
57    }
58
59    public String JavaDoc getProperty(String JavaDoc name)
60    {
61       return (String JavaDoc)portal.getProperties().get(name);
62    }
63
64    public Enumeration JavaDoc getPropertyNames()
65    {
66       return Tools.toEnumeration(portal.getProperties().keySet().iterator());
67    }
68
69    public Enumeration JavaDoc getSupportedPortletModes()
70    {
71       Set JavaDoc tmp = modes.getModes();
72       Set JavaDoc supportedPortletModes = new HashSet JavaDoc(tmp.size());
73       for (Iterator JavaDoc i = tmp.iterator();i.hasNext();)
74       {
75          Mode mode = (Mode)i.next();
76          supportedPortletModes.add(PortletUtils.decodePortletMode(mode.toString()));
77       }
78       return Tools.toEnumeration(supportedPortletModes.iterator());
79    }
80
81    public Enumeration JavaDoc getSupportedWindowStates()
82    {
83       Set JavaDoc tmp = windowStates.getWindowStates();
84       Set JavaDoc supportedWindowStates = new HashSet JavaDoc(tmp.size());
85       for (Iterator JavaDoc i = tmp.iterator();i.hasNext();)
86       {
87          org.jboss.portal.server.plugins.windowstate.WindowState windowState = (org.jboss.portal.server.plugins.windowstate.WindowState)i.next();
88          supportedWindowStates.add(PortletUtils.decodeWindowState(windowState.toString()));
89       }
90       return Tools.toEnumeration(supportedWindowStates.iterator());
91    }
92 }
93
Popular Tags