Source Code Cross Referenced for EarCleanTask.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:         * --------------------------------------------------------------------------
022:         * $Id: EarCleanTask.java 6673 2005-04-28 16:53:00Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_lib.deployment.work;
025:
026:        import java.io.File;
027:        import java.net.MalformedURLException;
028:        import java.net.URL;
029:        import java.util.Vector;
030:
031:        import org.objectweb.jonas.service.ServiceManager;
032:        import org.objectweb.jonas.ear.EarService;
033:
034:        import org.objectweb.util.monolog.api.BasicLevel;
035:
036:        /**
037:         * JOnAS Ear unused directory clean task class. This class provides a way for
038:         * removing directories wich are unconsistent directories for ear files.
039:         * @author Florent BENOIT
040:         * @author Benoit PELLETIER
041:         */
042:        public class EarCleanTask extends AbsCleanTask {
043:
044:            /**
045:             * reference to the deployerLog
046:             */
047:            private static DeployerLog earDeployerLog = null;
048:
049:            /**
050:             * Url of the jonas_ROOT/apps directory
051:             */
052:            private static URL earAppsUrl = null;
053:
054:            /**
055:             * Default constructor : Construct a new cleaner.
056:             * @param earApps the jonasroot apps directory
057:             * @param earDeployerLog the deployer logger
058:             */
059:            public EarCleanTask(URL earApps, DeployerLog earDeployerLog) {
060:                super ();
061:                EarCleanTask.earAppsUrl = earApps;
062:                EarCleanTask.earDeployerLog = earDeployerLog;
063:            }
064:
065:            /**
066:             * Return true if the work copy exists and is up to date
067:             * @param logEntry entry in a deploy log
068:             * @return true if the work copy exists and is up to date
069:             * @throws CleanerException if it fails
070:             */
071:            protected boolean isValidLogEntry(LogEntry logEntry)
072:                    throws CleanerException {
073:                String fTimeStamp = null;
074:                File earLogEntryFile = logEntry.getOriginal();
075:                String earLogEntryUnpackedDir = logEntry.getCopy().getName();
076:                //File dirEar = new File(earAppsUrl.getFile() + File.separator + earLogEntryUnpackedDir);
077:                if (getLogger().isLoggable(BasicLevel.DEBUG)) {
078:                    getLogger().log(
079:                            BasicLevel.DEBUG,
080:                            "LogEntry <" + earLogEntryFile.getName()
081:                                    + "> exist :" + earLogEntryFile.exists());
082:                }
083:
084:                // if the file doesn't exist, return
085:                if (!earLogEntryFile.exists()) {
086:                    return false;
087:                }
088:
089:                //get the timestamp
090:                try {
091:                    fTimeStamp = FileManager.fileToTimeStampDir(earLogEntryFile
092:                            .toURL());
093:                } catch (FileManagerException efme) {
094:                    throw new CleanerException(
095:                            "Can't get the timestamp of the file "
096:                                    + earLogEntryFile + " : "
097:                                    + efme.getMessage());
098:                } catch (MalformedURLException mue) {
099:                    throw new CleanerException(
100:                            "Can't get the timestamp of the file "
101:                                    + earLogEntryFile + " : "
102:                                    + mue.getMessage());
103:                }
104:
105:                if (getLogger().isLoggable(BasicLevel.DEBUG)) {
106:                    getLogger().log(BasicLevel.DEBUG,
107:                            "LogEntry fTimeStamp :" + fTimeStamp);
108:                    getLogger()
109:                            .log(
110:                                    BasicLevel.DEBUG,
111:                                    "LogEntry isValid :"
112:                                            + fTimeStamp
113:                                                    .equalsIgnoreCase(earLogEntryUnpackedDir));
114:                }
115:
116:                //compare
117:                return (fTimeStamp.equalsIgnoreCase(earLogEntryUnpackedDir));
118:
119:            }
120:
121:            /**
122:             * Remove the work copy specified in the log entry and the log entry
123:             * @param logEntry entry in a deploy log
124:             * @throws CleanerException if it fails
125:             */
126:            protected void removeLogEntry(LogEntry logEntry)
127:                    throws CleanerException {
128:                String earLogEntryUnpackedDir = logEntry.getCopy().getName();
129:
130:                File dirEar = new File(earAppsUrl.getFile() + File.separator
131:                        + earLogEntryUnpackedDir);
132:
133:                removeRecursiveDirectory(dirEar);
134:
135:                try {
136:                    earDeployerLog.removeEntry(logEntry);
137:                } catch (DeployerLogException edle) {
138:                    throw new CleanerException("Can't remove an entry"
139:                            + edle.getMessage());
140:                }
141:
142:            }
143:
144:            /**
145:             * Gets the log entries
146:             * @return the log entries
147:             */
148:            protected Vector getLogEntries() {
149:                return earDeployerLog.getEntries();
150:            }
151:
152:            /**
153:             * Check if the package pointed by the log entry is currently deploy
154:             * @param logEntry entry in a deploy log
155:             * @return true if the package pointed by the log entry is currently deployed
156:             * @throws CleanerException if it fails
157:             */
158:            protected boolean isDeployLogEntry(LogEntry logEntry)
159:                    throws CleanerException {
160:
161:                // get the ear service
162:                ServiceManager sm = null;
163:
164:                try {
165:                    sm = ServiceManager.getInstance();
166:                } catch (Exception e) {
167:                    throw new CleanerException(
168:                            "Cannot get ServiceManager instance");
169:                }
170:                EarService earService = (EarService) sm.getEarService();
171:
172:                // check if the ear file is deployed
173:                return earService.isEarDeployedByUnpackName(logEntry.getCopy()
174:                        .getName());
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.