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


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.desktop.context;
006:
007:        import com.sun.common.pool.PartitionObject;
008:        import com.sun.common.util.LockWithMemory;
009:        import com.sun.portal.desktop.DesktopThreadLocalManager;
010:        import com.sun.portal.desktop.dp.DPHelper;
011:        import com.sun.portal.desktop.dp.FQCN;
012:        import com.sun.portal.desktop.monitoring.MonitoringSubsystemWrapper;
013:        import com.sun.portal.log.common.PortalLogger;
014:        import com.sun.portal.monitoring.utilities.ActivityTime;
015:        import com.sun.portal.providers.Provider;
016:        import com.sun.portal.providers.context.ContainerProviderContext;
017:
018:        import javax.servlet.ServletConfig;
019:        import javax.servlet.ServletContext;
020:        import javax.servlet.http.HttpServletRequest;
021:        import javax.servlet.http.HttpServletResponse;
022:        import java.util.logging.Level;
023:        import java.util.logging.LogRecord;
024:        import java.util.logging.Logger;
025:        import java.util.Set;
026:
027:        public class ReusableProviderCaller extends Thread implements 
028:                PartitionObject {
029:            private static Logger logger = PortalLogger
030:                    .getLogger(ReusableProviderCaller.class);
031:
032:            private static LogRecord getLogRecord(Level level, String message,
033:                    Object[] parameters, Throwable t) {
034:                LogRecord result = new LogRecord(level, message);
035:                result.setLoggerName(logger.getName());
036:                result.setParameters(parameters);
037:                result.setThrown(t);
038:                return result;
039:            }
040:
041:            private ContainerProviderContext providerContext = null;
042:            private Provider provider = null;
043:            private StringBuffer content = null;
044:            private HttpServletRequest request = null;
045:            private HttpServletResponse response = null;
046:            private HttpServletRequest origRequest = null;
047:            private HttpServletResponse origResponse = null;
048:            private String parent = null;
049:            private Monitor monitor = null;
050:            private boolean initialized = false;
051:            private boolean running = true;
052:            private LockWithMemory begin = new LockWithMemory();
053:            private LockWithMemory end = new LockWithMemory();
054:            private ProviderCallerPool pool = null;
055:            private DesktopAppContext desktopAppContext = null;
056:            private DesktopContext desktopContext = null;
057:            private ServletContext servletContext = null;
058:            private ServletConfig servletConfig = null;
059:            private Set cuMembership = null;
060:            private int partition = 0;
061:
062:            public ReusableProviderCaller() {
063:                setDaemon(true);
064:                setName(getClass().getName());
065:            }
066:
067:            public void setPartition(int partition) {
068:                this .partition = partition;
069:            }
070:
071:            public int getPartition() {
072:                return this .partition;
073:            }
074:
075:            void init(DesktopAppContext dac, DesktopContext dc,
076:                    ContainerProviderContext cpc, Provider p, String parent,
077:                    Monitor m, HttpServletRequest req, HttpServletResponse res,
078:                    HttpServletRequest origReq, HttpServletResponse origRes,
079:                    ServletConfig servletConfig, ServletContext servletContext,
080:                    Set cuMembership, ProviderCallerPool callerPool) {
081:                this .providerContext = cpc;
082:                this .provider = p;
083:                this .parent = parent;
084:                this .monitor = m;
085:                this .request = req;
086:                this .response = res;
087:                this .origRequest = origReq;
088:                this .origResponse = origRes;
089:                this .desktopAppContext = dac;
090:                this .desktopContext = dc;
091:                this .servletConfig = servletConfig;
092:                this .servletContext = servletContext;
093:                this .pool = callerPool;
094:                this .cuMembership = cuMembership;
095:
096:                initialized = true;
097:            }
098:
099:            void clear() {
100:                initialized = false;
101:                content = null;
102:
103:                this .providerContext = null;
104:                this .provider = null;
105:                this .parent = null;
106:                this .monitor = null;
107:                this .request = null;
108:                this .response = null;
109:                this .origRequest = null;
110:                this .origResponse = null;
111:                this .desktopAppContext = null;
112:                this .desktopContext = null;
113:                this .servletContext = null;
114:                this .servletConfig = null;
115:            }
116:
117:            public void execute() {
118:                begin.signal();
119:            }
120:
121:            void finish() {
122:                running = false;
123:                begin.signal();
124:            }
125:
126:            public Provider getProvider() {
127:                return provider;
128:            }
129:
130:            public StringBuffer getContent() {
131:                return content;
132:            }
133:
134:            public void endOfTask(long timeout) {
135:                try {
136:                    end.waitFor(timeout);
137:                } catch (InterruptedException e) {
138:                    ; // ignore
139:                }
140:            }
141:
142:            private void doFinally(String name, FQCN fqcn,
143:                    ActivityTime activityTime) {
144:                if (name != null) {
145:                    monitor.put(name, content);
146:                    MonitoringSubsystemWrapper.getDesktopMonitoringSubsystem()
147:                            .stopProviderContentServiceTransaction(
148:                                    fqcn.encoded());
149:                    if (activityTime != null) {
150:                        MonitoringSubsystemWrapper
151:                                .getDesktopMonitoringSubsystem()
152:                                .getContentChannelActionStatistic().measure(
153:                                        activityTime, fqcn.plain());
154:                    }
155:                }
156:
157:                if (initialized) {
158:                    // Clean up only once
159:                    DesktopThreadLocalManager.release();
160:                    CommunityUserMembershipThreadLocalizer.reset();
161:                    pool.releaseCaller(this );
162:                    end.signal();
163:                }
164:            }
165:
166:            public void run() {
167:                String name = null;
168:                FQCN fqcn = null;
169:                ActivityTime activityTime = null;
170:
171:                try {
172:                    while (running) {
173:                        try {
174:                            try {
175:                                begin.waitFor();
176:                            } catch (InterruptedException ie) {
177:                                continue;
178:                            }
179:
180:                            if (!running) {
181:                                // finishing, going out of pool or out of service.
182:                                break;
183:                            }
184:
185:                            if (!initialized) {
186:                                throw new ContextError(
187:                                        "ProviderCaller.run(): attmpted un-initialized loop!");
188:                            }
189:
190:                            DesktopThreadLocalManager
191:                                    .init(desktopAppContext, request, response,
192:                                            origRequest, origResponse,
193:                                            servletConfig, servletContext);
194:                            DesktopThreadLocalManager.init(desktopContext,
195:                                    providerContext);
196:                            DesktopThreadLocalManager.init(parent);
197:                            CommunityUserMembershipThreadLocalizer.set(
198:                                    desktopContext.getUserID(), cuMembership);
199:                            ProviderContextThreadLocalizer.set(providerContext);
200:
201:                            name = provider.getName();
202:                            fqcn = DPHelper.getFQCN(desktopContext.getDPRoot(),
203:                                    name);
204:                            activityTime = new ActivityTime();
205:                            MonitoringSubsystemWrapper
206:                                    .getDesktopMonitoringSubsystem()
207:                                    .getContentChannelActionStatistic().mark(
208:                                            activityTime);
209:                            MonitoringSubsystemWrapper
210:                                    .getDesktopMonitoringSubsystem()
211:                                    .startProviderContentServiceTransaction(
212:                                            fqcn.encoded());
213:                            content = provider.getContent(request, response);
214:                            if (provider.getRefreshTime() > 0) {
215:                                providerContext.putCachedContent(name, content);
216:                            }
217:                        } catch (Throwable t) {
218:                            if (logger.isLoggable(Level.SEVERE)) {
219:                                logger.log(getLogRecord(Level.SEVERE,
220:                                        "PSDT_CSPDC0025",
221:                                        new Object[] { name }, t));
222:                            }
223:                        } finally {
224:                            doFinally(name, fqcn, activityTime);
225:                            name = null;
226:                            fqcn = null;
227:                            activityTime = null;
228:                        }
229:                    }
230:                } catch (Throwable t2) {
231:                    if (logger.isLoggable(Level.SEVERE)) {
232:                        if (logger.isLoggable(Level.SEVERE)) {
233:                            logger
234:                                    .log(getLogRecord(Level.SEVERE,
235:                                            "PSDT_CSPDC0025",
236:                                            new Object[] { name }, t2));
237:                        }
238:                    }
239:                } finally {
240:                    doFinally(name, fqcn, activityTime);
241:                }
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.