Source Code Cross Referenced for JetspeedPortletContext.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » container » 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 » jetspeed 2.1.3 » org.apache.jetspeed.container 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.container;
018:
019:        import java.io.InputStream;
020:        import java.util.Collection;
021:        import java.util.Enumeration;
022:        import java.util.Iterator;
023:
024:        import javax.servlet.ServletContext;
025:        import javax.servlet.RequestDispatcher;
026:
027:        import javax.portlet.PortletContext;
028:        import javax.portlet.PortletRequestDispatcher;
029:
030:        import org.apache.jetspeed.dispatcher.JetspeedRequestDispatcher;
031:        import org.apache.jetspeed.om.common.JetspeedServiceReference;
032:        import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
033:        import org.apache.jetspeed.services.JetspeedPortletServices;
034:        import org.apache.jetspeed.services.PortletServices;
035:        import org.apache.pluto.om.portlet.PortletApplicationDefinition;
036:
037:        /**
038:         * Implements the Portlet API Portlet Context class
039:         *
040:         * TODO: on LOCAL apps, we need to merge in web.xml props. See PLT 10.3
041:         *
042:         * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
043:         * @version $Id: JetspeedPortletContext.java 516448 2007-03-09 16:25:47Z ate $
044:         */
045:        public class JetspeedPortletContext implements  PortletContext,
046:                InternalPortletContext {
047:            /**
048:             * The path to the Local Portlet Apps directory
049:             */
050:            public static final String LOCAL_PA_ROOT = "/WEB-INF/apps";
051:
052:            private ServletContext servletContext;
053:            private MutablePortletApplication application;
054:
055:            public JetspeedPortletContext(ServletContext servletContext,
056:                    PortletApplicationDefinition application) {
057:                this .servletContext = servletContext;
058:                this .application = (MutablePortletApplication) application;
059:            }
060:
061:            public int getMajorVersion() {
062:                return ContainerInfo.getMajorSpecificationVersion();
063:            }
064:
065:            public int getMinorVersion() {
066:                return ContainerInfo.getMinorSpecificationVersion();
067:            }
068:
069:            // Delegated methods
070:
071:            public java.util.Set getResourcePaths(String path) {
072:                return servletContext.getResourcePaths(path);
073:            }
074:
075:            public javax.portlet.PortletRequestDispatcher getRequestDispatcher(
076:                    String path) {
077:                String localizedPath = localizePath(path, this .application);
078:                RequestDispatcher rd = null;
079:
080:                try {
081:                    rd = servletContext.getRequestDispatcher(localizedPath);
082:                } catch (Exception e) {
083:                    // Portlet API says: return null
084:                }
085:
086:                // TODO: factory
087:                if (rd != null) {
088:                    return new JetspeedRequestDispatcher(rd);
089:                }
090:                return null;
091:            }
092:
093:            public PortletRequestDispatcher getNamedDispatcher(String name) {
094:                // TODO: localize name
095:
096:                RequestDispatcher rd = null;
097:
098:                try {
099:                    rd = servletContext.getNamedDispatcher(name);
100:                } catch (Exception e) {
101:                    // Portlet API says: return null
102:                }
103:
104:                // TODO: factory
105:
106:                if (rd != null) {
107:                    return new JetspeedRequestDispatcher(rd);
108:                }
109:                return null;
110:            }
111:
112:            public String getMimeType(String file) {
113:                return servletContext.getMimeType(file);
114:            }
115:
116:            public InputStream getResourceAsStream(String path) {
117:                return servletContext.getResourceAsStream(localizePath(path,
118:                        this .application));
119:            }
120:
121:            public java.lang.Object getAttribute(java.lang.String name) {
122:                if (name == null) {
123:                    throw new IllegalArgumentException(
124:                            "Required parameter name is null");
125:                }
126:
127:                if (name.startsWith("cps:")) {
128:                    String serviceName = name.substring("cps:".length());
129:
130:                    // validate service
131:                    Collection validServices = application
132:                            .getJetspeedServices();
133:                    if (null == validServices) {
134:                        return null;
135:                    }
136:                    boolean found = false;
137:                    Iterator iterator = validServices.iterator();
138:                    while (iterator.hasNext()) {
139:                        JetspeedServiceReference validService = (JetspeedServiceReference) iterator
140:                                .next();
141:                        if (validService.getName().equals(serviceName)) {
142:                            found = true;
143:                            break;
144:                        }
145:                    }
146:
147:                    if (!found) {
148:                        return null;
149:                    }
150:
151:                    // return the service
152:                    PortletServices services = JetspeedPortletServices
153:                            .getSingleton();
154:                    return services.getService(serviceName);
155:                }
156:                return servletContext.getAttribute(name);
157:            }
158:
159:            public void log(java.lang.String msg) {
160:                // TODO: setup a logger for the portlet application
161:                servletContext.log(msg);
162:            }
163:
164:            public void log(java.lang.String message,
165:                    java.lang.Throwable throwable) {
166:                // TODO: setup a logger for the portlet application
167:                servletContext.log(message, throwable);
168:            }
169:
170:            public String getRealPath(String path) {
171:                return servletContext.getRealPath(localizePath(path,
172:                        this .application));
173:            }
174:
175:            public java.net.URL getResource(String path)
176:                    throws java.net.MalformedURLException {
177:                return servletContext.getResource(localizePath(path,
178:                        this .application));
179:            }
180:
181:            public Enumeration getAttributeNames() {
182:                return servletContext.getAttributeNames();
183:            }
184:
185:            public java.lang.String getInitParameter(java.lang.String name) {
186:                if (name == null) {
187:                    throw new IllegalArgumentException(
188:                            "Required parameter name is null");
189:                }
190:                return servletContext.getInitParameter(name);
191:            }
192:
193:            public java.util.Enumeration getInitParameterNames() {
194:                return servletContext.getInitParameterNames();
195:            }
196:
197:            public void removeAttribute(java.lang.String name) {
198:                if (name == null) {
199:                    throw new IllegalArgumentException("Attribute name == null");
200:                }
201:
202:                servletContext.removeAttribute(name);
203:            }
204:
205:            public void setAttribute(java.lang.String name,
206:                    java.lang.Object object) {
207:                if (name == null) {
208:                    throw new IllegalArgumentException("Attribute name == null");
209:                }
210:                servletContext.setAttribute(name, object);
211:            }
212:
213:            public String getServerInfo() {
214:                return ContainerInfo.getServerInfo();
215:            }
216:
217:            // internal portlet context implementation
218:
219:            public ServletContext getServletContext() {
220:                return this .servletContext;
221:            }
222:
223:            /**
224:             * @see org.apache.jetspeed.container.InternalPortletContext#getApplication()
225:             */
226:            public PortletApplicationDefinition getApplication() {
227:                return this .application;
228:            }
229:
230:            public String getPortletContextName() {
231:                return servletContext.getServletContextName();
232:            }
233:
234:            private String localizePath(String path,
235:                    MutablePortletApplication app) {
236:                if (path == null) {
237:                    return "/";
238:                }
239:                return path;
240:                // TODO: local PA with own/extra resource paths support
241:                /*        
242:                 if (app.getApplicationType() == MutablePortletApplication.WEBAPP)
243:                 {
244:                 return path;
245:                 }
246:
247:                 StringBuffer pathBuffer = new StringBuffer(LOCAL_PA_ROOT);
248:                 pathBuffer.append(app.getWebApplicationDefinition().getContextRoot());
249:                 if (!path.startsWith("/"))
250:                 {
251:                 pathBuffer.append("/");
252:                 }
253:                 pathBuffer.append(path);
254:                 String result = pathBuffer.toString();
255:                 return result;
256:                 */
257:            }
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.