Source Code Cross Referenced for A_CmsReportThread.java in  » Content-Management-System » opencms » org » opencms » report » 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 » Content Management System » opencms » org.opencms.report 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/report/A_CmsReportThread.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:41 $
004:         * Version: $Revision: 1.25 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.report;
033:
034:        import org.opencms.file.CmsObject;
035:        import org.opencms.main.OpenCms;
036:        import org.opencms.util.CmsUUID;
037:
038:        import java.util.List;
039:        import java.util.Locale;
040:
041:        /** 
042:         * Provides a common Thread class for the reports.<p>
043:         * 
044:         * @author Alexander Kandzior  
045:         * 
046:         * @version $Revision: 1.25 $ 
047:         * 
048:         * @since 6.0.0 
049:         */
050:        public abstract class A_CmsReportThread extends Thread implements 
051:                I_CmsReportThread {
052:
053:            /** The OpenCms request context to use. */
054:            private CmsObject m_cms;
055:
056:            /** Indicates if the thread was already checked by the grim reaper. */
057:            private boolean m_doomed;
058:
059:            /** The id of this report. */
060:            private CmsUUID m_id;
061:
062:            /** The report that belongs to the thread. */
063:            private I_CmsReport m_report;
064:
065:            /** The time this report is running. */
066:            private long m_starttime;
067:
068:            /**
069:             * Constructs a new report Thread with the given name.<p>
070:             *
071:             * @param cms the current OpenCms context object 
072:             * @param name the name of the Thread
073:             */
074:            protected A_CmsReportThread(CmsObject cms, String name) {
075:
076:                super (OpenCms.getThreadStore().getThreadGroup(), name);
077:                // report Threads are never daemon Threads
078:                setDaemon(false);
079:                // the session in the cms context must not be updated when it is used in a report
080:                m_cms = cms;
081:                m_cms.getRequestContext().setUpdateSessionEnabled(false);
082:                // generate the report Thread id
083:                m_id = new CmsUUID();
084:                setName(name + " [" + m_id + "]");
085:                // new Threads are not doomed
086:                m_doomed = false;
087:                // set start time
088:                m_starttime = System.currentTimeMillis();
089:                // add this Thread to the main Thread store
090:                OpenCms.getThreadStore().addThread(this );
091:            }
092:
093:            /**
094:             * Adds an error object to the list of errors that occured during the report.<p>
095:             * 
096:             * @param obj the error object
097:             */
098:            public void addError(Object obj) {
099:
100:                if (getReport() != null) {
101:                    getReport().addError(obj);
102:                }
103:            }
104:
105:            /**
106:             * Returns the error exception in case there was an error during the execution of
107:             * this Thread, null otherwise.<p>
108:             * 
109:             * @return the error exception in case there was an error, null otherwise
110:             */
111:            public Throwable getError() {
112:
113:                return null;
114:            }
115:
116:            /**
117:             * Returns a list of all errors that occured during the report.<p>
118:             * 
119:             * @return an error list that occured during the report
120:             */
121:            public List getErrors() {
122:
123:                if (getReport() != null) {
124:                    return getReport().getErrors();
125:                } else {
126:                    return null;
127:                }
128:            }
129:
130:            /**
131:             * Returns the part of the report that is ready for output.<p>
132:             * 
133:             * @return the part of the report that is ready for output
134:             */
135:            public abstract String getReportUpdate();
136:
137:            /** 
138:             * Returns the time this report has been running.<p>
139:             * 
140:             * @return the time this report has been running
141:             */
142:            public synchronized long getRuntime() {
143:
144:                if (m_doomed) {
145:                    return m_starttime;
146:                } else {
147:                    return System.currentTimeMillis() - m_starttime;
148:                }
149:            }
150:
151:            /**
152:             * Returns the OpenCms UUID of this report thread.<p>
153:             * 
154:             * @return the OpenCms UUID of this report thread
155:             */
156:            public CmsUUID getUUID() {
157:
158:                return m_id;
159:            }
160:
161:            /**
162:             * Returns if the report generated an error output.<p>
163:             * 
164:             * @return true if the report generated an error, otherwise false
165:             */
166:            public boolean hasError() {
167:
168:                if (getReport() != null) {
169:                    return (getReport().getErrors().size() > 0);
170:                } else {
171:                    return false;
172:                }
173:            }
174:
175:            /**
176:             * Returns true if this thread is already "doomed" to be deleted.<p>
177:             * 
178:             * A OpenCms deamon Thread (the "Grim Reaper") will collect all 
179:             * doomed Threads, i.e. threads that are not longer active for some
180:             * time.<p>
181:             * 
182:             * @return true if this thread is already "doomed" to be deleted
183:             */
184:            public synchronized boolean isDoomed() {
185:
186:                if (isAlive()) {
187:                    // as long as the Thread is still active it is never doomed
188:                    return false;
189:                }
190:                if (m_doomed) {
191:                    // not longer active, and already doomed, so rest in peace...
192:                    return true;
193:                }
194:                // condemn the Thread to be collected by the grim reaper next time  
195:                m_starttime = getRuntime();
196:                m_doomed = true;
197:                return false;
198:            }
199:
200:            /**
201:             * Returns the OpenCms context object this Thread is initialized with.<p>
202:             * 
203:             * @return the OpenCms context object this Thread is initialized with
204:             */
205:            protected CmsObject getCms() {
206:
207:                return m_cms;
208:            }
209:
210:            /**
211:             * Returns the report where the output of this Thread is written to.<p>
212:             * 
213:             * @return the report where the output of this Thread is written to
214:             */
215:            protected I_CmsReport getReport() {
216:
217:                return m_report;
218:            }
219:
220:            /**
221:             * Initialize a HTML report for this Thread.<p>
222:             * 
223:             * @param locale the locale for the report output messages
224:             */
225:            protected void initHtmlReport(Locale locale) {
226:
227:                m_report = new CmsHtmlReport(locale, m_cms.getRequestContext()
228:                        .getSiteRoot());
229:            }
230:
231:            /**
232:             * Initialize a HTML report for this Thread.<p>
233:             * 
234:             * This method is reserved for older report threads that still use
235:             * XML templates to generate their output.<p>
236:             * 
237:             * @param locale the locale for the report output messages
238:             */
239:            protected void initOldHtmlReport(Locale locale) {
240:
241:                m_report = new CmsHtmlReport(locale, m_cms.getRequestContext()
242:                        .getSiteRoot(), true, false);
243:            }
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.