Source Code Cross Referenced for HarnessRedirector.java in  » Portal » Open-Portal » com » sun » portal » harness » 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 » Open Portal » com.sun.portal.harness 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004:         */
005:
006:        package com.sun.portal.harness;
007:
008:        import java.util.HashMap;
009:
010:        import java.io.File;
011:        import java.io.Serializable;
012:
013:        import javax.servlet.http.HttpSession;
014:        import javax.servlet.http.HttpServletRequest;
015:        import javax.servlet.http.HttpSessionBindingListener;
016:        import javax.servlet.http.HttpSessionBindingEvent;
017:
018:        import com.sun.portal.desktop.context.PropertiesClientContext;
019:        import com.sun.portal.desktop.context.PropertiesServiceContext;
020:        import com.sun.portal.desktop.context.PropertiesConfigContext;
021:
022:        // RedirectorContext is used in the top level JSP's to obtain redirection information
023:        // on where to find the actual content producing jsp's located in the desktop directory.
024:        // Basically, it produces just enough of the context to be able to get template paths.
025:        // The top level jsp's do not produce any actual content, and thus do not have to be
026:        // translated.
027:
028:        // Like ProviderHarness we store our real context in a private cache because we do not want
029:        // to try to store them on HTTP session.
030:
031:        public class HarnessRedirector implements  HttpSessionBindingListener,
032:                Serializable {
033:
034:            static public HarnessRedirector getRedirector(HttpServletRequest req)
035:                    throws ProviderHarnessException {
036:
037:                HarnessRedirector red = null;
038:                String cfgdir = req.getParameter(ProviderHarness.ARG_CONFIGDIR);
039:                HttpSession sess = req.getSession();
040:
041:                if (cfgdir == null) {
042:                    red = (HarnessRedirector) sess.getAttribute(SESSION_KEY);
043:                    if (red == null) {
044:                        throw new ProviderHarnessException(
045:                                "Cannot find HarnessRedirector in Session");
046:                    }
047:                    synchronized (m_RedCache) {
048:                        red.m_RedCtx = (RedirectorContext) m_RedCache
049:                                .get(red.m_CacheKey);
050:                    }
051:                    if (red.m_RedCtx == null) {
052:                        throw new ProviderHarnessException(
053:                                "Unexpected lookup failure in HarnessRedirector cache");
054:                    }
055:                    red.m_IgnoreUnbind = true;
056:                    sess.setAttribute(SESSION_KEY, red);
057:                    red.m_IgnoreUnbind = false;
058:                    return red;
059:                }
060:
061:                red = new HarnessRedirector();
062:
063:                synchronized (m_RedCache) {
064:                    ++m_RedCounter;
065:                    red.m_CacheKey = "RED#" + m_RedCounter;
066:                    red.m_RedCtx = new RedirectorContext(cfgdir, req
067:                            .getLocale().toString());
068:                    sess.setAttribute(SESSION_KEY, red);
069:                    m_RedCache.put(red.m_CacheKey, red.m_RedCtx);
070:                }
071:
072:                return red;
073:            }
074:
075:            public String getRelativePath(String jspname)
076:                    throws ProviderHarnessException {
077:                return m_RedCtx.getRelativePath(jspname);
078:            }
079:
080:            public void valueUnbound(
081:                    HttpSessionBindingEvent httpSessionBindingEvent) {
082:                if (!m_IgnoreUnbind) {
083:                    synchronized (m_RedCache) {
084:                        m_RedCache.remove(m_CacheKey);
085:                    }
086:                }
087:            }
088:
089:            public void valueBound(
090:                    HttpSessionBindingEvent httpSessionBindingEvent) {
091:            }
092:
093:            private String m_CacheKey;
094:            private boolean m_IgnoreUnbind = false;
095:
096:            private transient RedirectorContext m_RedCtx;
097:
098:            private static int m_RedCounter = 0;
099:            private static HashMap m_RedCache = new HashMap();
100:
101:            private static final String SESSION_KEY = "desktop.Simulator.HarnessRedirector";
102:        }
103:
104:        class RedirectorContext {
105:            RedirectorContext(String configdir, String locale) {
106:                try {
107:                    m_ConfigDir = new File(configdir).getCanonicalPath();
108:                } catch (Exception ex) {
109:                    m_ConfigDir = configdir;
110:                }
111:                m_Locale = locale;
112:                m_DesktopProperties = new PropertiesConfigContext();
113:                m_DesktopProperties.init(configdir
114:                        + "/desktop/desktopconfig.properties");
115:                m_TplContext = new HarnessTemplateContext();
116:                m_ServiceContext = new PropertiesServiceContext(configdir
117:                        + "/service-context.properties");
118:                m_ClientContext = new PropertiesClientContext(configdir
119:                        + "/client-context.properties");
120:            }
121:
122:            public String getRelativePath(String jspname)
123:                    throws ProviderHarnessException {
124:
125:                // This mimics the providercontext lookup with both provider name and
126:                // channel name = HARNESS_TEMPLATES and a locale = the user's "real" locale,
127:                // not the locale they are testing.
128:
129:                File f = m_TplContext.getTemplatePath(m_DesktopProperties
130:                        .getTemplateBaseDir(), m_ServiceContext
131:                        .getDesktopType(), m_Locale, HARNESS_TEMPLATES,
132:                        HARNESS_TEMPLATES, m_ClientContext
133:                                .getClientPath(m_ClientContext
134:                                        .getClientType(null)), jspname);
135:
136:                if (f == null) {
137:                    throw new ProviderHarnessException(
138:                            "Cannot find template for " + HARNESS_TEMPLATES
139:                                    + "/" + jspname);
140:                }
141:
142:                String rp = null;
143:                try {
144:                    rp = f.getCanonicalPath();
145:                } catch (Exception ex) {
146:                    rp = f.getPath();
147:                }
148:
149:                if (rp.startsWith(m_ConfigDir)) {
150:                    return rp.substring(m_ConfigDir.length() + 1);
151:                }
152:
153:                throw new ProviderHarnessException(
154:                        "Template file did not begin with config directory.");
155:            }
156:
157:            private PropertiesConfigContext m_DesktopProperties;
158:            private HarnessTemplateContext m_TplContext;
159:            private PropertiesServiceContext m_ServiceContext;
160:            private PropertiesClientContext m_ClientContext;
161:            private String m_ConfigDir;
162:            private String m_Locale;
163:
164:            private static final String HARNESS_TEMPLATES = "harness";
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.