1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.pluto.core.impl;
21
22 import java.util.Iterator;
23 import java.util.Locale;
24 import java.util.ResourceBundle;
25
26 import javax.portlet.PortletConfig;
27 import javax.portlet.PortletContext;
28
29 import org.apache.pluto.core.InternalPortletConfig;
30 import org.apache.pluto.om.common.Language;
31 import org.apache.pluto.om.common.LanguageSet;
32 import org.apache.pluto.om.common.Parameter;
33 import org.apache.pluto.om.portlet.PortletDefinition;
34
35 public class PortletConfigImpl implements PortletConfig, InternalPortletConfig
36 {
37 private javax.servlet.ServletConfig servletConfig;
38 private PortletContext portletContext;
39 private PortletDefinition portletDefinition;
40
41 public PortletConfigImpl(javax.servlet.ServletConfig servletConfig,
42 PortletContext portletContext,
43 PortletDefinition portletDefinition)
44 {
45 this.servletConfig = servletConfig;
46 this.portletContext = portletContext;
47 this.portletDefinition = portletDefinition;
48 }
49
50
51 public String getPortletName()
52 {
53 return portletDefinition.getName();
54 }
55
56 public PortletContext getPortletContext()
57 {
58 return portletContext;
59 }
60
61 public ResourceBundle getResourceBundle(java.util.Locale locale)
62 {
63 LanguageSet languageSet = portletDefinition.getLanguageSet();
64 Language lang = languageSet.get(locale);
65
66 if (lang == null)
67 {
68 Locale defaultLocale = languageSet.getDefaultLocale();
69 lang = languageSet.get(defaultLocale);
70 }
71
72 return lang.getResourceBundle();
73 }
74
75 public String getInitParameter(String name)
76 {
77 Parameter parm = null;
78 if (name == null)
79 {
80 throw new IllegalArgumentException("Parameter name == null");
81 }
82 parm = portletDefinition.getInitParameterSet().get(name);
83 return (parm == null ? null : parm.getValue());
84 }
85
86 public java.util.Enumeration getInitParameterNames()
87 {
88 return new java.util.Enumeration()
89 {
90 private Iterator iterator = portletDefinition.getInitParameterSet().iterator();
91
92 public boolean hasMoreElements()
93 {
94 return iterator.hasNext();
95 }
96
97 public Object nextElement()
98 {
99 if (iterator.hasNext())
100 {
101 return((Parameter)iterator.next()).getName();
102 }
103 else
104 {
105 return null;
106 }
107 }
108 };
109 }
110
111
112
113 public javax.servlet.ServletConfig getServletConfig()
114 {
115 return servletConfig;
116 }
117
118 public PortletDefinition getInternalPortletDefinition()
119 {
120 return portletDefinition;
121 }
122
123 }