Source Code Cross Referenced for PortletConfigImpl.java in  » Portal » gridsphere » org » gridsphere » portlet » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » gridsphere » org.gridsphere.portlet.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.gridsphere.portlet.impl;
002:
003:        import org.gridsphere.portletcontainer.impl.descriptor.InitParam;
004:        import org.gridsphere.portletcontainer.impl.descriptor.PortletDefinition;
005:        import org.gridsphere.portletcontainer.impl.descriptor.PortletInfo;
006:        import org.gridsphere.portletcontainer.impl.descriptor.SupportedLocale;
007:
008:        import javax.portlet.Portlet;
009:        import javax.portlet.PortletConfig;
010:        import javax.portlet.PortletContext;
011:        import javax.servlet.ServletConfig;
012:        import java.util.*;
013:
014:        /**
015:         * The <CODE>PortletConfig</CODE> interface provides the portlet with
016:         * its configuration. The configuration holds information about the
017:         * portlet that is valid for all users. The configuration is retrieved
018:         * from the portlet definition in the deployment descriptor.
019:         * The portlet can only read the configuration data.
020:         * <p/>
021:         * The configuration information contains the portlet name, the portlet
022:         * initialization parameters, the portlet resource bundle and the portlet
023:         * application context.
024:         *
025:         * @see Portlet
026:         */
027:        public class PortletConfigImpl implements  PortletConfig {
028:
029:            private PortletContext context = null;
030:            private ClassLoader classLoader = null;
031:            private String portletName = null;
032:            private ResourceBundle infoBundle = null;
033:            private String resources = null;
034:            private Hashtable initParams = new Hashtable();
035:
036:            private static class DefaultResourceBundle extends
037:                    ListResourceBundle {
038:                private Object[][] resources;
039:
040:                public DefaultResourceBundle(PortletInfo portletInfo) {
041:                    String title = ((portletInfo.getTitle() != null) ? portletInfo
042:                            .getTitle().getContent()
043:                            : "");
044:                    String shortTitle = ((portletInfo.getShortTitle() != null) ? portletInfo
045:                            .getShortTitle().getContent()
046:                            : "");
047:                    String keywords = ((portletInfo.getKeywords() != null) ? portletInfo
048:                            .getKeywords().getContent()
049:                            : "");
050:                    resources = new Object[][] {
051:                            { "javax.portlet.title", title },
052:                            { "javax.portlet.short-title", shortTitle },
053:                            { "javax.portlet.keywords", keywords } };
054:                }
055:
056:                public Object[][] getContents() {
057:                    return resources;
058:                }
059:            }
060:
061:            private static class ResourceBundleImpl extends ResourceBundle {
062:                private HashMap data;
063:
064:                public ResourceBundleImpl(ResourceBundle bundle,
065:                        ResourceBundle defaults) {
066:                    data = new HashMap();
067:                    importData(defaults);
068:                    importData(bundle);
069:                }
070:
071:                private void importData(ResourceBundle bundle) {
072:                    if (bundle != null) {
073:                        for (Enumeration e = bundle.getKeys(); e
074:                                .hasMoreElements();) {
075:                            String key = (String) e.nextElement();
076:                            Object value = bundle.getObject(key);
077:                            data.put(key, value);
078:                        }
079:                    }
080:                }
081:
082:                protected Object handleGetObject(String key) {
083:                    return data.get(key);
084:                }
085:
086:                public Enumeration getKeys() {
087:                    return new Enumerator(data.keySet());
088:                }
089:            }
090:
091:            /**
092:             * Constructs an instance of PortletConfig from a servlet configuration
093:             * object and an application portlet descriptor
094:             *
095:             * @param servletConfig a <code>ServletConfig</code>
096:             * @param definition    a <code>PortletDefinition</code>
097:             */
098:            public PortletConfigImpl(ServletConfig servletConfig,
099:                    PortletDefinition definition, ClassLoader classLoader) {
100:
101:                this .classLoader = classLoader;
102:
103:                // create init params
104:                InitParam[] params = definition.getInitParam();
105:                if (params != null) {
106:                    for (int i = 0; i < params.length; i++) {
107:                        InitParam iparam = params[i];
108:                        String name = iparam.getName().getContent();
109:                        String value = iparam.getValue().getContent();
110:                        if ((name != null) && (value != null)) {
111:                            initParams.put(name, value);
112:                        }
113:                    }
114:                }
115:
116:                // create portlet context
117:                context = new PortletContextImpl(servletConfig
118:                        .getServletContext());
119:
120:                // get portlet name
121:                portletName = definition.getPortletName().getContent();
122:
123:                SupportedLocale[] locales = definition.getSupportedLocale();
124:                Locale[] supportedLocales = new Locale[locales.length];
125:                for (int i = 0; i < locales.length; i++) {
126:                    supportedLocales[i] = new Locale(locales[i].getContent());
127:                }
128:
129:                PortletInfo portletInfo = definition.getPortletInfo();
130:                if (portletInfo != null) {
131:                    infoBundle = new DefaultResourceBundle(portletInfo);
132:
133:                }
134:
135:                if (definition.getResourceBundle() != null) {
136:                    resources = definition.getResourceBundle().getContent();
137:
138:                }
139:
140:                //this.logConfig();
141:            }
142:
143:            /**
144:             * Returns the name of the portlet.
145:             * <p/>
146:             * The name may be provided via server administration, assigned in the
147:             * portlet application deployment descriptor with the <code>portlet-name</code>
148:             * tag.
149:             *
150:             * @return the portlet name
151:             */
152:            public String getPortletName() {
153:                return portletName;
154:            }
155:
156:            /**
157:             * Returns the <code>PortletContext</code> of the portlet application
158:             * the portlet is in.
159:             *
160:             * @return a <code>PortletContext</code> object, used by the
161:             *         caller to interact with its portlet container
162:             * @see PortletContext
163:             */
164:            public PortletContext getPortletContext() {
165:                return context;
166:            }
167:
168:            /**
169:             * Returns the path name of this portlet context
170:             *
171:             * @return Returns the context path of the web application.
172:             */
173:            public String getContextPath() {
174:                // todo fix me to confirm to servlet spec 2.5
175:                return "";
176:            }
177:
178:            /**
179:             * Gets the resource bundle for the given locale based on the
180:             * resource bundle defined in the deployment descriptor
181:             * with <code>resource-bundle</code> tag or the inlined resources
182:             * defined in the deployment descriptor.
183:             *
184:             * @param locale the locale for which to retrieve the resource bundle
185:             * @return the resource bundle for the given locale
186:             */
187:            public ResourceBundle getResourceBundle(java.util.Locale locale) {
188:                if (resources == null) {
189:                    return infoBundle;
190:                }
191:                ResourceBundle resourceBundle = null;
192:                try {
193:                    resourceBundle = ResourceBundle.getBundle(resources,
194:                            locale, classLoader);
195:                    if (infoBundle != null) {
196:                        return new ResourceBundleImpl(resourceBundle,
197:                                infoBundle);
198:                    }
199:                } catch (MissingResourceException e) {
200:                    System.err.println("Unable to find resource bundle: "
201:                            + resources + " for locale: " + locale);
202:                    if (infoBundle != null) {
203:                        return infoBundle;
204:                    }
205:                    // if everything goes wrong get the english locale (which needs to be there)
206:                    resourceBundle = ResourceBundle.getBundle(resources,
207:                            Locale.ENGLISH, classLoader);
208:                }
209:                return resourceBundle;
210:            }
211:
212:            /**
213:             * Returns a String containing the value of the named initialization parameter,
214:             * or null if the parameter does not exist.
215:             *
216:             * @param name a <code>String</code> specifying the name
217:             *             of the initialization parameter
218:             * @return a <code>String</code> containing the value
219:             * of the initialization parameter
220:             * @exception IllegalArgumentException if name is <code>null</code>.
221:             */
222:            public String getInitParameter(String name) {
223:                if (name == null)
224:                    throw new IllegalArgumentException("name is NULL");
225:                return (String) initParams.get(name);
226:            }
227:
228:            /**
229:             * Returns the names of the portlet initialization parameters as an
230:             * <code>Enumeration</code> of String objects, or an empty <code>Enumeration</code> if the
231:             * portlet has no initialization parameters.
232:             *
233:             * @return an <code>Enumeration</code> of <code>String</code>
234:             * objects containing the names of the portlet
235:             * initialization parameters, or an empty <code>Enumeration</code> if the
236:             * portlet has no initialization parameters.
237:             */
238:            public java.util.Enumeration getInitParameterNames() {
239:                return initParams.keys();
240:            }
241:
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.