Source Code Cross Referenced for PortletTrackingManagerImpl.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » aggregator » 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 » jetspeed 2.1.3 » org.apache.jetspeed.aggregator.impl 
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.aggregator.impl;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collections;
021:        import java.util.HashMap;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Map;
025:
026:        import org.apache.jetspeed.aggregator.PortletTrackingManager;
027:        import org.apache.jetspeed.aggregator.RenderTrackable;
028:        import org.apache.jetspeed.container.window.PortletWindowAccessor;
029:        import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
030:        import org.apache.pluto.om.window.PortletWindow;
031:
032:        /**
033:         * Tracks out of service status for portlets
034:         *  
035:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
036:         * @version $Id: $
037:         */
038:        public class PortletTrackingManagerImpl implements 
039:                PortletTrackingManager {
040:            protected Map outOfService = Collections
041:                    .synchronizedMap(new HashMap());
042:
043:            /**
044:             * when rendering a portlet, the default timeout period in milliseconds
045:             * setting to zero will disable (no timeout) the timeout
046:             *  
047:             */
048:            protected long defaultPortletTimeout;
049:
050:            /**
051:             * Out of service limit, if a portlet entity times out past its limit (or default limit) n consecutive times, 
052:             * it is taken out of service
053:             */
054:            protected int outOfServiceLimit;
055:
056:            protected PortletWindowAccessor windowAccessor;
057:
058:            public PortletTrackingManagerImpl(
059:                    PortletWindowAccessor windowAccessor,
060:                    long defaultPortletTimeout, int outOfServiceLimit) {
061:                this .windowAccessor = windowAccessor;
062:                this .defaultPortletTimeout = defaultPortletTimeout;
063:                this .outOfServiceLimit = outOfServiceLimit;
064:            }
065:
066:            public long getDefaultPortletTimeout() {
067:                return this .defaultPortletTimeout;
068:            }
069:
070:            public boolean exceededTimeout(long renderTime, PortletWindow window) {
071:                RenderTrackable trackInfo = (RenderTrackable) window
072:                        .getPortletEntity();
073:                long defaultTimeout = this .getDefaultPortletTimeout();
074:                if (trackInfo.getExpiration() > 0) {
075:                    return (renderTime > trackInfo.getExpiration());
076:                } else if (defaultTimeout > 0) {
077:                    return (renderTime > defaultTimeout);
078:                }
079:                return false;
080:            }
081:
082:            public boolean isOutOfService(PortletWindow window) {
083:                RenderTrackable trackable = (RenderTrackable) window
084:                        .getPortletEntity();
085:                if (trackable.getRenderTimeoutCount() > this .outOfServiceLimit) {
086:                    return true;
087:                }
088:                return false;
089:            }
090:
091:            public int getOutOfServiceLimit() {
092:                return this .outOfServiceLimit;
093:            }
094:
095:            public void incrementRenderTimeoutCount(PortletWindow window) {
096:                RenderTrackable trackable = (RenderTrackable) window
097:                        .getPortletEntity();
098:                trackable.incrementRenderTimeoutCount();
099:            }
100:
101:            public void success(PortletWindow window) {
102:                RenderTrackable trackable = (RenderTrackable) window
103:                        .getPortletEntity();
104:                trackable.success();
105:            }
106:
107:            public void setExpiration(PortletWindow window, long expiration) {
108:                RenderTrackable trackable = (RenderTrackable) window
109:                        .getPortletEntity();
110:                trackable.setExpiration(expiration); // * 1000);                
111:            }
112:
113:            public void takeOutOfService(PortletWindow window) {
114:                RenderTrackable trackable = (RenderTrackable) window
115:                        .getPortletEntity();
116:                trackable
117:                        .setRenderTimeoutCount((int) this .defaultPortletTimeout + 1);
118:            }
119:
120:            public void putIntoService(PortletWindow window) {
121:                RenderTrackable trackable = (RenderTrackable) window
122:                        .getPortletEntity();
123:                trackable.setRenderTimeoutCount(0);
124:            }
125:
126:            public void putIntoService(List fullPortletNames) {
127:                Iterator windows = this .windowAccessor.getPortletWindows()
128:                        .iterator();
129:                while (windows.hasNext()) {
130:                    PortletWindow window = (PortletWindow) windows.next();
131:                    PortletDefinitionComposite pd = (PortletDefinitionComposite) window
132:                            .getPortletEntity().getPortletDefinition();
133:                    for (int ix = 0; ix < fullPortletNames.size(); ix++) {
134:                        if (pd.getUniqueName().equals(fullPortletNames.get(ix))) {
135:                            putIntoService(window);
136:                        }
137:                    }
138:                }
139:            }
140:
141:            public List getOutOfServiceList(String fullPortletName) {
142:                List outs = new ArrayList();
143:                Iterator windows = this .windowAccessor.getPortletWindows()
144:                        .iterator();
145:                while (windows.hasNext()) {
146:                    PortletWindow window = (PortletWindow) windows.next();
147:                    PortletDefinitionComposite pd = (PortletDefinitionComposite) window
148:                            .getPortletEntity().getPortletDefinition();
149:                    if (pd.getUniqueName().equals(fullPortletName)
150:                            && isOutOfService(window)) {
151:                        outs.add(window);
152:                    }
153:                }
154:                return outs;
155:            }
156:
157:            public List getOutOfServiceList() {
158:                List outs = new ArrayList();
159:                Iterator windows = this .windowAccessor.getPortletWindows()
160:                        .iterator();
161:                while (windows.hasNext()) {
162:                    PortletWindow window = (PortletWindow) windows.next();
163:                    if (isOutOfService(window)) {
164:                        outs.add(window);
165:                    }
166:                }
167:                return outs;
168:            }
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.