Source Code Cross Referenced for AbsCleanTask.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_lib » deployment » work » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_lib.deployment.work 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer(s): Benoit PELLETIER
022:         * --------------------------------------------------------------------------
023:         * $Id: AbsCleanTask.java 6673 2005-04-28 16:53:00Z benoitf $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas_lib.deployment.work;
026:
027:        import java.io.File;
028:
029:        import java.util.Enumeration;
030:        import java.util.Vector;
031:
032:        import org.objectweb.util.monolog.api.Logger;
033:        import org.objectweb.util.monolog.api.BasicLevel;
034:
035:        import org.objectweb.jonas.common.Log;
036:
037:        /**
038:         * Abstract Clean Task class which define a generic job executed by the cleaner
039:         * thread
040:         * @author Benoit PELLETIER
041:         */
042:        public abstract class AbsCleanTask {
043:
044:            /**
045:             * The logger used in JOnAS
046:             */
047:            private static Logger logger = Log
048:                    .getLogger(Log.JONAS_DEPLOY_WORK_PREFIX);
049:
050:            /**
051:             * Default constructor : Construct a new cleaner.
052:             */
053:            protected AbsCleanTask() {
054:            }
055:
056:            /**
057:             * @return the logger
058:             */
059:            protected static Logger getLogger() {
060:                return logger;
061:            }
062:
063:            /**
064:             * Abstract method defined in the derived classes return true if the work
065:             * copy exist and is up to date
066:             * @param logEntry entry in a deploy log
067:             * @return true if the work copy exists and is up to date
068:             * @throws CleanerException if it fails
069:             */
070:            protected abstract boolean isValidLogEntry(LogEntry logEntry)
071:                    throws CleanerException;
072:
073:            /**
074:             * Abstract method defined in the derived classes remove the work copy
075:             * specified in the log entry and the log entry
076:             * @param logEntry entry in a deploy log
077:             * @throws CleanerException if it fails
078:             */
079:            protected abstract void removeLogEntry(LogEntry logEntry)
080:                    throws CleanerException;
081:
082:            /**
083:             * Abstract method defined in the derived classes get the log entries
084:             * @return the log entries
085:             */
086:            protected abstract Vector getLogEntries();
087:
088:            /**
089:             * Check if the package pointed by the log entry is currently deploy
090:             * @param logEntry entry in a deploy log
091:             * @return true if the package pointed by the log entry is currently deployed
092:             * @throws CleanerException if it fails
093:             */
094:            protected abstract boolean isDeployLogEntry(LogEntry logEntry)
095:                    throws CleanerException;
096:
097:            /**
098:             * Run the clean task
099:             * @throws CleanerException if it failed.
100:             */
101:            public void execute() throws CleanerException {
102:
103:                if (getLogger().isLoggable(BasicLevel.DEBUG)) {
104:                    getLogger().log(BasicLevel.DEBUG, "execute : called");
105:                }
106:
107:                // Get the entries from the logger
108:                Vector logEntries = getLogEntries();
109:
110:                // Check if the files in this vector exists
111:                LogEntry logEntry = null;
112:
113:                for (Enumeration e = logEntries.elements(); e.hasMoreElements();) {
114:
115:                    logEntry = (LogEntry) e.nextElement();
116:                    if (getLogger().isLoggable(BasicLevel.DEBUG)) {
117:                        getLogger().log(
118:                                BasicLevel.DEBUG,
119:                                "LogEntry <" + logEntry.getOriginal().getName()
120:                                        + "," + logEntry.getCopy().getName()
121:                                        + ">");
122:                    }
123:
124:                    // if the package is deployed, do nothing
125:                    if (isDeployLogEntry(logEntry)) {
126:                        if (getLogger().isLoggable(BasicLevel.DEBUG)) {
127:                            getLogger()
128:                                    .log(BasicLevel.DEBUG,
129:                                            "LogEntry currently deployed - > do nothing");
130:                        }
131:
132:                        continue;
133:
134:                    }
135:
136:                    // if the source package file doesn't exists anymore
137:                    // or if the file is present but don't care the right timestamp
138:                    if (!isValidLogEntry(logEntry)) {
139:
140:                        // we remove the entry
141:                        removeLogEntry(logEntry);
142:
143:                        // enumeration is now inconsistent, so we 're restarting the
144:                        // loop
145:                        e = logEntries.elements();
146:
147:                    }
148:                    //else time stamp always the same
149:                }
150:            }
151:
152:            /**
153:             * Remove a directory with all its child (recursive)
154:             * @param file the file or directory which must be deleted
155:             */
156:            protected void removeRecursiveDirectory(File file) {
157:
158:                //File or directory doesn't exists, exit.
159:                if (!file.exists()) {
160:                    return;
161:                }
162:
163:                //Remove the child before the current file(directory)
164:                if (file.isDirectory()) {
165:                    //remove all the child
166:                    File[] childFiles = file.listFiles();
167:                    for (int i = 0; i < childFiles.length; i++) {
168:                        removeRecursiveDirectory(childFiles[i]);
169:                    }
170:                }
171:                //Since all childs are removed , remove us
172:                file.delete();
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.