geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r332243 - in /geronimo/trunk/modules: assembly/ assembly/src/plan/ assembly/src/var/config/ deploy-tool/src/java/org/apache/geronimo/deployment/cli/ hot-deploy/ hot-deploy/src/ hot-deploy/src/java/ hot-deploy/src/java/org/ hot-deploy/src/ja...
Date Thu, 10 Nov 2005 07:57:32 GMT
Author: ammulder
Date: Wed Nov  9 23:57:19 2005
New Revision: 332243

URL: http://svn.apache.org/viewcvs?rev=332243&view=rev
Log:
Add directory scanning hot deployer (GERONIMO-686)

Added:
    geronimo/trunk/modules/assembly/src/plan/j2ee-hot-deploy-plan.xml   (with props)
    geronimo/trunk/modules/hot-deploy/   (with props)
    geronimo/trunk/modules/hot-deploy/LICENSE.txt   (with props)
    geronimo/trunk/modules/hot-deploy/NOTICE.txt   (with props)
    geronimo/trunk/modules/hot-deploy/maven.xml   (with props)
    geronimo/trunk/modules/hot-deploy/project.properties   (with props)
    geronimo/trunk/modules/hot-deploy/project.xml   (with props)
    geronimo/trunk/modules/hot-deploy/src/
    geronimo/trunk/modules/hot-deploy/src/java/
    geronimo/trunk/modules/hot-deploy/src/java/org/
    geronimo/trunk/modules/hot-deploy/src/java/org/apache/
    geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/
    geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/
    geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/
    geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java   (with props)
    geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java   (with props)
    geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/HotDeployer.java   (with props)
Modified:
    geronimo/trunk/modules/assembly/maven.xml
    geronimo/trunk/modules/assembly/project.xml
    geronimo/trunk/modules/assembly/src/plan/j2ee-runtime-deployer-plan.xml
    geronimo/trunk/modules/assembly/src/var/config/config.jetty.xml
    geronimo/trunk/modules/assembly/src/var/config/config.tomcat.xml
    geronimo/trunk/modules/assembly/src/var/config/config.xml
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java

Modified: geronimo/trunk/modules/assembly/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/maven.xml?rev=332243&r1=332242&r2=332243&view=diff
==============================================================================
--- geronimo/trunk/modules/assembly/maven.xml (original)
+++ geronimo/trunk/modules/assembly/maven.xml Wed Nov  9 23:57:19 2005
@@ -650,6 +650,12 @@
                 plan="${basedir}/target/plan/uddi-server-tomcat-plan.xml"
                 module="${maven.repo.local}/geronimo/wars/geronimo-uddi-server-${pom.currentVersion}.war"/>
 
+            <deploy:distribute
+                uri="deployer:geronimo:jmx:rmi://localhost/jndi/rmi:/JMXConnector"
+                username="system"
+                password="manager"
+                plan="${basedir}/target/plan/j2ee-hot-deploy-plan.xml" />
+
             <!-- create SystemDatabase -->
             <!--            <attainGoal name="init-database"/>-->
 

Modified: geronimo/trunk/modules/assembly/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/project.xml?rev=332243&r1=332242&r2=332243&view=diff
==============================================================================
--- geronimo/trunk/modules/assembly/project.xml (original)
+++ geronimo/trunk/modules/assembly/project.xml Wed Nov  9 23:57:19 2005
@@ -195,6 +195,15 @@
 
         <dependency>
             <groupId>geronimo</groupId>
+            <artifactId>geronimo-hot-deploy</artifactId>
+            <version>${pom.currentVersion}</version>
+            <properties>
+                <repository>true</repository>
+            </properties>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
             <artifactId>geronimo-deploy-jsr88</artifactId>
             <version>${pom.currentVersion}</version>
             <properties>

Added: geronimo/trunk/modules/assembly/src/plan/j2ee-hot-deploy-plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/j2ee-hot-deploy-plan.xml?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-hot-deploy-plan.xml (added)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-hot-deploy-plan.xml Wed Nov  9 23:57:19 2005
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Copyright 2004-2005 The Apache Software Foundation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<!-- $Rev: 57116 $ $Date: 2004-11-09 17:34:38 -0800 (Tue, 09 Nov 2004) $ -->
+
+<!--
+Child of the org/apache/geronimo/Server configuration that includes deployment services
+-->
+<configuration
+    xmlns="http://geronimo.apache.org/xml/ns/deployment-1.0"
+    configId="org/apache/geronimo/HotDeployer"
+    parentId="org/apache/geronimo/RuntimeDeployer"
+    >
+
+    <dependency>
+        <uri>geronimo/jars/geronimo-hot-deploy-${geronimo_version}.jar</uri>
+    </dependency>
+    <dependency>
+        <uri>geronimo/jars/geronimo-deploy-tool-${geronimo_version}.jar</uri>
+    </dependency>
+    <dependency>
+        <uri>geronimo/jars/geronimo-deploy-jsr88-${geronimo_version}.jar</uri>
+    </dependency>
+
+    <gbean name="HotDeployer" class="org.apache.geronimo.deployment.hot.DirectoryHotDeployer">
+        <reference name="ServerInfo">
+            <module>org/apache/geronimo/System</module>
+            <name>ServerInfo</name>
+        </reference>
+		<attribute name="path">deploy/</attribute>
+        <attribute name="pollIntervalMillis">2000</attribute>
+        <dependency>
+            <module>org/apache/geronimo/RuntimeDeployer</module>
+            <type>ConfigBuilder</type>
+            <name>EARBuilder</name>
+        </dependency>
+    </gbean>
+</configuration>
\ No newline at end of file

Propchange: geronimo/trunk/modules/assembly/src/plan/j2ee-hot-deploy-plan.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/trunk/modules/assembly/src/plan/j2ee-runtime-deployer-plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/j2ee-runtime-deployer-plan.xml?rev=332243&r1=332242&r2=332243&view=diff
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-runtime-deployer-plan.xml (original)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-runtime-deployer-plan.xml Wed Nov  9 23:57:19 2005
@@ -240,5 +240,4 @@
             <gbean-name>*:name=Repository,*</gbean-name>
         </reference>
     </gbean>
-
 </configuration>

Modified: geronimo/trunk/modules/assembly/src/var/config/config.jetty.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/var/config/config.jetty.xml?rev=332243&r1=332242&r2=332243&view=diff
==============================================================================
--- geronimo/trunk/modules/assembly/src/var/config/config.jetty.xml (original)
+++ geronimo/trunk/modules/assembly/src/var/config/config.jetty.xml Wed Nov  9 23:57:19 2005
@@ -78,4 +78,10 @@
     <configuration name="org/apache/geronimo/JettyRuntimeDeployer"/>
     <configuration name="org/apache/geronimo/applications/Welcome/Jetty"/>
     <configuration name="org/apache/geronimo/Console/Jetty"/>
+    <configuration name="org/apache/geronimo/HotDeployer">
+        <gbean name="HotDeployer">
+            <attribute name="path">deploy</attribute>
+            <attribute name="pollIntervalMillis">2000</attribute>
+        </gbean>
+    </configuration>
 </attributes>

Modified: geronimo/trunk/modules/assembly/src/var/config/config.tomcat.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/var/config/config.tomcat.xml?rev=332243&r1=332242&r2=332243&view=diff
==============================================================================
--- geronimo/trunk/modules/assembly/src/var/config/config.tomcat.xml (original)
+++ geronimo/trunk/modules/assembly/src/var/config/config.tomcat.xml Wed Nov  9 23:57:19 2005
@@ -83,4 +83,10 @@
     <configuration name="org/apache/geronimo/TomcatRuntimeDeployer"/>
     <configuration name="org/apache/geronimo/applications/Welcome/Tomcat"/>
     <configuration name="org/apache/geronimo/Console/Tomcat"/>
+    <configuration name="org/apache/geronimo/HotDeployer">
+        <gbean name="HotDeployer">
+            <attribute name="path">deploy</attribute>
+            <attribute name="pollIntervalMillis">2000</attribute>
+        </gbean>
+    </configuration>
 </attributes>

Modified: geronimo/trunk/modules/assembly/src/var/config/config.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/var/config/config.xml?rev=332243&r1=332242&r2=332243&view=diff
==============================================================================
--- geronimo/trunk/modules/assembly/src/var/config/config.xml (original)
+++ geronimo/trunk/modules/assembly/src/var/config/config.xml Wed Nov  9 23:57:19 2005
@@ -92,7 +92,13 @@
         </gbean>
     </configuration>
     <configuration name="org/apache/geronimo/JettyRuntimeDeployer"/>
-    <configuration name="org/apache/geronimo/TomcatRuntimeDeployer"/>
+    <configuration name="org/apache/geronimo/TomcatRuntimeDeployer"/> 
     <configuration name="org/apache/geronimo/applications/Welcome/${PlanWebServerName}"/>
     <configuration name="org/apache/geronimo/Console/${PlanWebServerName}"/>
+    <configuration name="org/apache/geronimo/HotDeployer">
+        <gbean name="HotDeployer">
+            <attribute name="path">deploy</attribute>
+            <attribute name="pollIntervalMillis">2000</attribute>
+        </gbean>
+    </configuration>
 </attributes>

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java?rev=332243&r1=332242&r2=332243&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java (original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java Wed Nov  9 23:57:19 2005
@@ -144,35 +144,8 @@
         return tlist;
     }
 
+    //todo: remove this method
     protected static Collection identifyTargetModuleIDs(TargetModuleID[] allModules, String name) throws DeploymentException {
-        List list = new LinkedList();
-        int pos;
-        if((pos = name.indexOf('|')) > -1) {
-            String target = name.substring(0, pos);
-            String module = name.substring(pos+1);
-            // First pass: exact match
-            for(int i=0; i<allModules.length; i++) {
-                if(allModules[i].getTarget().getName().equals(target) && allModules[i].getModuleID().equals(module)) {
-                    list.add(allModules[i]);
-                }
-            }
-        }
-        if(!list.isEmpty()) {
-            return list;
-        }
-        // second pass: module matches
-        for(int i = 0; i < allModules.length; i++) {
-            if(allModules[i].getModuleID().equals(name)) {
-                list.add(allModules[i]);
-            }
-        }
-        if(list.isEmpty()) {
-            throw new DeploymentException(name+" does not appear to be a the name of a module " +
-                    "available on the selected server. Perhaps it has already been " +
-                    "stopped or undeployed?  If you're trying to specify a " +
-                    "TargetModuleID, use the syntax TargetName|ModuleName instead. " +
-                    "If you're not sure what's running, try the list-modules command.");
-        }
-        return list;
+        return DeployUtils.identifyTargetModuleIDs(allModules, name);
     }
 }

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java?rev=332243&r1=332242&r2=332243&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java (original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/DeployUtils.java Wed Nov  9 23:57:19 2005
@@ -20,6 +20,9 @@
 import java.io.*;
 import java.util.jar.JarFile;
 import java.util.jar.JarEntry;
+import java.util.Collection;
+import java.util.List;
+import java.util.LinkedList;
 
 import org.apache.geronimo.common.DeploymentException;
 import org.xml.sax.InputSource;
@@ -30,6 +33,7 @@
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.enterprise.deploy.spi.TargetModuleID;
 
 /**
  * Various helpers for deployment.
@@ -96,6 +100,45 @@
         }
         return buf.toString();
     }
+
+
+    /**
+     * Given a list of all available TargetModuleIDs and the name of a module,
+     * find the TargetModuleIDs that represent that module.
+     * @throws DeploymentException If no TargetModuleIDs have that module.
+     */
+    public static Collection identifyTargetModuleIDs(TargetModuleID[] allModules, String name) throws DeploymentException {
+        List list = new LinkedList();
+        int pos;
+        if((pos = name.indexOf('|')) > -1) {
+            String target = name.substring(0, pos);
+            String module = name.substring(pos+1);
+            // First pass: exact match
+            for(int i=0; i<allModules.length; i++) {
+                if(allModules[i].getTarget().getName().equals(target) && allModules[i].getModuleID().equals(module)) {
+                    list.add(allModules[i]);
+                }
+            }
+        }
+        if(!list.isEmpty()) {
+            return list;
+        }
+        // second pass: module matches
+        for(int i = 0; i < allModules.length; i++) {
+            if(allModules[i].getModuleID().equals(name)) {
+                list.add(allModules[i]);
+            }
+        }
+        if(list.isEmpty()) {
+            throw new DeploymentException(name+" does not appear to be a the name of a module " +
+                    "available on the selected server. Perhaps it has already been " +
+                    "stopped or undeployed?  If you're trying to specify a " +
+                    "TargetModuleID, use the syntax TargetName|ModuleName instead. " +
+                    "If you're not sure what's running, try the list-modules command.");
+        }
+        return list;
+    }
+
 
     /**
      * Try to determine whether a file is a JAR File (or, at least, a ZIP file).

Propchange: geronimo/trunk/modules/hot-deploy/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Nov  9 23:57:19 2005
@@ -0,0 +1,2 @@
+target
+*.iml

Added: geronimo/trunk/modules/hot-deploy/LICENSE.txt
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/hot-deploy/LICENSE.txt?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/hot-deploy/LICENSE.txt (added)
+++ geronimo/trunk/modules/hot-deploy/LICENSE.txt Wed Nov  9 23:57:19 2005
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Propchange: geronimo/trunk/modules/hot-deploy/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/trunk/modules/hot-deploy/NOTICE.txt
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/hot-deploy/NOTICE.txt?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/hot-deploy/NOTICE.txt (added)
+++ geronimo/trunk/modules/hot-deploy/NOTICE.txt Wed Nov  9 23:57:19 2005
@@ -0,0 +1,3 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Propchange: geronimo/trunk/modules/hot-deploy/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/trunk/modules/hot-deploy/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/hot-deploy/maven.xml?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/hot-deploy/maven.xml (added)
+++ geronimo/trunk/modules/hot-deploy/maven.xml Wed Nov  9 23:57:19 2005
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright 2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+  
+
+<!-- $Rev: 56771 $ $Date: 2004-11-06 14:58:54 -0500 (Sat, 06 Nov 2004) $ -->
+
+<project default="default">
+
+</project>

Propchange: geronimo/trunk/modules/hot-deploy/maven.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/trunk/modules/hot-deploy/project.properties
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/hot-deploy/project.properties?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/hot-deploy/project.properties (added)
+++ geronimo/trunk/modules/hot-deploy/project.properties Wed Nov  9 23:57:19 2005
@@ -0,0 +1,3 @@
+##
+## $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+##

Propchange: geronimo/trunk/modules/hot-deploy/project.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/trunk/modules/hot-deploy/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/hot-deploy/project.xml?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/hot-deploy/project.xml (added)
+++ geronimo/trunk/modules/hot-deploy/project.xml Wed Nov  9 23:57:19 2005
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev: 57362 $ $Date: 2004-11-10 15:40:05 -0500 (Wed, 10 Nov 2004) $ -->
+
+<project>
+    <pomVersion>3</pomVersion>
+    <extend>../../etc/project.xml</extend>
+
+    <!-- ===================== -->
+    <!-- Module Identification -->
+    <!-- ===================== -->
+
+    <name>Geronimo :: Deploy :: Hot Deployer</name>
+    <id>geronimo-hot-deploy</id>
+    <shortDescription>Geronimo Hot Deploy GBean</shortDescription>
+    <description>A GBean that implements a Hot Deploy directory.</description>
+    <url>http://incubator.apache.org/projects/geronimo/deployment/</url>
+    <siteDirectory>/www/incubator.apache.org/projects/geronimo/deployment</siteDirectory>
+    <distributionDirectory>/www/incubator.apache.org/projects/geronimo/builds/deployment/</distributionDirectory>
+
+    <package>org.apache.geronimo.deployment.hot</package>
+
+    <!-- ============ -->
+    <!-- Dependencies -->
+    <!-- ============ -->
+
+    <dependencies>
+        <dependency>
+            <groupId>xmlbeans</groupId>
+            <artifactId>xbean</artifactId>
+            <version>${xmlbeans_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>${stax_api_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-j2ee-deployment</artifactId>
+            <version>${geronimo_spec_j2ee_deployment_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-deploy-tool</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-deploy-jsr88</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-common</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-system</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>${commons_logging_version}</version>
+            <url>http://jakarta.apache.org/commons/logging/</url>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+        </resources>
+        <unitTest>
+            <includes>
+                <include>**/*Test.java</include>
+            </includes>
+        </unitTest>
+    </build>
+</project>

Propchange: geronimo/trunk/modules/hot-deploy/project.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java (added)
+++ geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java Wed Nov  9 23:57:19 2005
@@ -0,0 +1,270 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.deployment.hot;
+
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
+import org.apache.geronimo.deployment.cli.DeployUtils;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+import java.io.File;
+
+/**
+ * A directory-scanning hot deployer
+ *
+ * @version $Rev: 53762 $ $Date: 2004-10-04 18:54:53 -0400 (Mon, 04 Oct 2004) $
+ */
+public class DirectoryHotDeployer implements HotDeployer, GBeanLifecycle {
+    private static final Log log = LogFactory.getLog(DirectoryHotDeployer.class);
+    private DirectoryMonitor monitor;
+    private String path;
+    private ServerInfo serverInfo;
+    private int pollIntervalMillis;
+    private transient DeploymentFactory factory;
+    private transient TargetModuleID[] startupModules = null;
+
+    public DirectoryHotDeployer(String path, int pollIntervalMillis, ServerInfo serverInfo) {
+        this.path = path;
+        this.serverInfo = serverInfo;
+        this.pollIntervalMillis = pollIntervalMillis;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public ServerInfo getServerInfo() {
+        return serverInfo;
+    }
+
+    public void setServerInfo(ServerInfo serverInfo) {
+        this.serverInfo = serverInfo;
+    }
+
+    public int getPollIntervalMillis() {
+        return pollIntervalMillis;
+    }
+
+    public void setPollIntervalMillis(int pollIntervalMillis) {
+        this.pollIntervalMillis = pollIntervalMillis;
+    }
+
+    public void doStart() throws Exception {
+        if(factory == null) {
+            factory = new DeploymentFactoryImpl();
+        }
+        File dir = serverInfo.resolve(path);
+        if(!dir.exists()) {
+            if(!dir.mkdirs()) {
+                throw new IllegalStateException("Hot deploy directory "+dir.getAbsolutePath()+" does not exist and cannot be created!");
+            }
+        } else if(!dir.canRead() || !dir.isDirectory()) {
+            throw new IllegalStateException("Hot deploy directory "+dir.getAbsolutePath()+" is not a readable directory!");
+        }
+        DeploymentManager mgr = null;
+        try {
+            mgr = factory.getDeploymentManager("deployer:geronimo:inVM", null, null);
+            Target[] targets = mgr.getTargets();
+            startupModules = mgr.getAvailableModules(null, targets);
+            mgr.release();
+            mgr = null;
+            monitor = new DirectoryMonitor(dir, this, pollIntervalMillis);
+            monitor.initialize();
+            startupModules = null;
+            log.debug("Hot deploy scanner intialized; starting main loop.");
+            Thread t = new Thread(monitor, "Geronimo hot deploy scanner");
+            t.setDaemon(true);
+            t.start();
+        } finally {
+            if(mgr != null) mgr.release();
+        }
+    }
+
+    public void doStop() throws Exception {
+        monitor.close();
+    }
+
+    public void doFail() {
+        if(monitor != null) {
+            monitor.close();
+        }
+    }
+
+    public boolean isFileDeployed(File file, String configId) {
+        try {
+            DeployUtils.identifyTargetModuleIDs(startupModules, configId).toArray(new TargetModuleID[0]);
+            return true;
+        } catch (DeploymentException e) {
+            log.info("Found new file in deploy directory on startup with ID "+configId);
+            return false;
+        }
+    }
+
+    public boolean isServerRunning() {
+        return true; //todo: figure out whether it's safe to do deploy operations
+    }
+
+    public long getDeploymentTime(File file, String configId) {
+        return file.lastModified(); //todo: how can we find out when a module was deployed?
+    }
+
+    public boolean fileAdded(File file) {
+        DeploymentManager mgr = null;
+        try {
+            mgr = factory.getDeploymentManager("deployer:geronimo:inVM", null, null);
+            Target[] targets = mgr.getTargets();
+            ProgressObject po = mgr.distribute(targets, file, null);
+            waitForProgress(po);
+            if(po.getDeploymentStatus().isCompleted()) {
+                TargetModuleID[] modules = po.getResultTargetModuleIDs();
+                po = mgr.start(modules);
+                waitForProgress(po);
+                if(!po.getDeploymentStatus().isCompleted()) {
+                    log.warn("Unable to start some modules for "+file.getAbsolutePath());
+                }
+                modules = po.getResultTargetModuleIDs();
+                for (int i = 0; i < modules.length; i++) {
+                    TargetModuleID result = modules[i];
+                    System.out.println(DeployUtils.reformat("Deployed "+result.getModuleID()+(targets.length > 1 ? " to "+result.getTarget().getName() : "")+(result.getWebURL() == null ? "" : " @ "+result.getWebURL()), 4, 72));
+                    if(result.getChildTargetModuleID() != null) {
+                        for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
+                            TargetModuleID child = result.getChildTargetModuleID()[j];
+                            System.out.println(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL() == null ? "" : " @ "+child.getWebURL()),4, 72));
+                        }
+                    }
+                }
+            } else {
+                log.error("Unable to deploy: "+po.getDeploymentStatus().getMessage(), new DeploymentException());
+                return false;
+            }
+        } catch (DeploymentManagerCreationException e) {
+            log.error("Unable to open deployer", e);
+            return false;
+        } finally {
+            if(mgr != null) mgr.release();
+        }
+        return true;
+    }
+
+    public boolean fileRemoved(File file, String configId) {
+        DeploymentManager mgr = null;
+        try {
+            mgr = factory.getDeploymentManager("deployer:geronimo:inVM", null, null);
+            Target[] targets = mgr.getTargets();
+            TargetModuleID[] ids = mgr.getAvailableModules(null, targets);
+            ids = (TargetModuleID[]) DeployUtils.identifyTargetModuleIDs(ids, configId).toArray(new TargetModuleID[0]);
+            ProgressObject po = mgr.undeploy(ids);
+            waitForProgress(po);
+            if(po.getDeploymentStatus().isCompleted()) {
+                TargetModuleID[] modules = po.getResultTargetModuleIDs();
+                for (int i = 0; i < modules.length; i++) {
+                    TargetModuleID result = modules[i];
+                    System.out.println(DeployUtils.reformat("Undeployed "+result.getModuleID()+(targets.length > 1 ? " to "+result.getTarget().getName() : ""), 4, 72));
+                }
+            } else {
+                log.error("Unable to undeploy "+file.getAbsolutePath()+"("+configId+")"+po.getDeploymentStatus().getMessage());
+                return false;
+            }
+        } catch (DeploymentManagerCreationException e) {
+            log.error("Unable to open deployer", e);
+            return false;
+        } catch (Exception e) {
+            log.error("Unable to undeploy", e);
+            return false;
+        } finally {
+            if(mgr != null) mgr.release();
+        }
+        return true;
+    }
+
+    public void fileUpdated(File file, String configId) {
+        DeploymentManager mgr = null;
+        try {
+            mgr = factory.getDeploymentManager("deployer:geronimo:inVM", null, null);
+            Target[] targets = mgr.getTargets();
+            TargetModuleID[] ids = mgr.getAvailableModules(null, targets);
+            ids = (TargetModuleID[]) DeployUtils.identifyTargetModuleIDs(ids, configId).toArray(new TargetModuleID[0]);
+            ProgressObject po = mgr.redeploy(ids, file, null);
+            waitForProgress(po);
+            if(po.getDeploymentStatus().isCompleted()) {
+                TargetModuleID[] modules = po.getResultTargetModuleIDs();
+                for (int i = 0; i < modules.length; i++) {
+                    TargetModuleID result = modules[i];
+                    System.out.println(DeployUtils.reformat("Redeployed "+result.getModuleID()+(targets.length > 1 ? " to "+result.getTarget().getName() : "")+(result.getWebURL() == null ? "" : " @ "+result.getWebURL()), 4, 72));
+                    if(result.getChildTargetModuleID() != null) {
+                        for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
+                            TargetModuleID child = result.getChildTargetModuleID()[j];
+                            System.out.println(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL() == null ? "" : " @ "+child.getWebURL()),4, 72));
+                        }
+                    }
+                }
+            } else {
+                log.error("Unable to undeploy "+file.getAbsolutePath()+"("+configId+")"+po.getDeploymentStatus().getMessage());
+            }
+        } catch (DeploymentManagerCreationException e) {
+            log.error("Unable to open deployer", e);
+        } catch (Exception e) {
+            log.error("Unable to undeploy", e);
+        } finally {
+            if(mgr != null) mgr.release();
+        }
+    }
+
+    private void waitForProgress(ProgressObject po) {
+        while(po.getDeploymentStatus().isRunning()) {
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(DirectoryHotDeployer.class);
+
+        infoFactory.addAttribute("path", String.class, true);
+        infoFactory.addAttribute("pollIntervalMillis", int.class, true);
+        infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
+        infoFactory.addInterface(HotDeployer.class);
+
+        infoFactory.setConstructor(new String[]{"path", "pollIntervalMillis", "ServerInfo"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Propchange: geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java (added)
+++ geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java Wed Nov  9 23:57:19 2005
@@ -0,0 +1,334 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.deployment.hot;
+
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
+import org.apache.geronimo.deployment.cli.DeployUtils;
+import java.io.File;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * Meant to be run as a Thread that tracks the contents of a directory.
+ * It sends notifications for changes to its immediate children (it
+ * will look into subdirs for changes, but will not send notifications
+ * for files within subdirectories).  If a file continues to change on
+ * every pass, this will wait until it stabilizes before sending an
+ * add or update notification (to handle slow uploads, etc.).
+ *
+ * @version $Rev: 53762 $ $Date: 2004-10-04 18:54:53 -0400 (Mon, 04 Oct 2004) $
+ */
+public class DirectoryMonitor implements Runnable {
+    private static final Log log = LogFactory.getLog(DirectoryMonitor.class);
+    public static interface Listener {
+        /**
+         * The directory monitor doesn't take any action unless this method
+         * returns true (to avoid deploying before the deploy GBeans are
+         * running, etc.).
+         */
+        boolean isServerRunning();
+        /**
+         * Called during initialization on all files in the hot deploy
+         * directory.
+         *
+         * @return true if the file in question is already available in the
+         *         server, false if it should be deployed on the next pass.
+         */
+        boolean isFileDeployed(File file, String configId);
+
+        /**
+         * Called during initialization on previously deployed files.
+         *
+         * @return The time that the file was deployed.  If the current
+         *         version in the directory is newer, the file will be
+         *         updated on the first pass.
+         */
+        long getDeploymentTime(File file, String configId);
+
+        /**
+         * @return true if the addition was processed successfully.  If not
+         *         the file will be added again next time it changes.
+         */
+        boolean fileAdded(File file);
+        /**
+         * @return true if the removal was processed successfully.  If not
+         *         the file will be removed again on the next pass.
+         */
+        boolean fileRemoved(File file, String configId);
+
+        void fileUpdated(File file, String configId);
+    }
+
+    private int pollIntervalMillis;
+    private File directory;
+    private boolean done = false;
+    private Listener listener; // a little cheesy, but do we really need multiple listeners?
+    private Map files = new HashMap();
+
+    public DirectoryMonitor(File directory, Listener listener, int pollIntervalMillis) {
+        this.directory = directory;
+        this.listener = listener;
+        this.pollIntervalMillis = pollIntervalMillis;
+    }
+
+    public int getPollIntervalMillis() {
+        return pollIntervalMillis;
+    }
+
+    public void setPollIntervalMillis(int pollIntervalMillis) {
+        this.pollIntervalMillis = pollIntervalMillis;
+    }
+
+    public Listener getListener() {
+        return listener;
+    }
+
+    public void setListener(Listener listener) {
+        this.listener = listener;
+    }
+
+    public File getDirectory() {
+        return directory;
+    }
+
+    /**
+     * Warning: changing the directory at runtime will cause all files in the
+     * old directory to be removed and all files in the new directory to be
+     * added, next time the thread awakens.
+     */
+    public void setDirectory(File directory) {
+        if(!directory.isDirectory() || !directory.canRead()) {
+            throw new IllegalArgumentException("Cannot monitor directory "+directory.getAbsolutePath());
+        }
+        this.directory = directory;
+    }
+
+    public synchronized boolean isDone() {
+        return done;
+    }
+
+    public synchronized void close() {
+        this.done = true;
+    }
+
+    public void run() {
+        while(!done) {
+            try {
+                Thread.sleep(pollIntervalMillis);
+            } catch (InterruptedException e) {
+                continue;
+            }
+            if(listener == null || listener.isServerRunning()) {
+                scanDirectory();
+            }
+        }
+    }
+
+    public void initialize() {
+        File parent = directory;
+        File[] children = parent.listFiles();
+        for (int i = 0; i < children.length; i++) {
+            File child = children[i];
+            if(!child.canRead()) {
+                continue;
+            }
+            FileInfo now = child.isDirectory() ? getDirectoryInfo(child) : getFileInfo(child);
+            now.setChanging(false);
+            try {
+                now.setConfigId(DeployUtils.extractModuleIdFromArchive(child));
+                if(listener == null || listener.isFileDeployed(child, now.getConfigId())) {
+                    if(listener != null) {
+                        now.setModified(listener.getDeploymentTime(child, now.getConfigId()));
+                    }
+                    files.put(now.getPath(), now);
+                }
+            } catch (Exception e) {
+                log.error("Unable to scan file "+child.getAbsolutePath()+" during initialization");
+            }
+        }
+    }
+
+    /**
+     * Looks for changes to the immediate contents of the directory we're watching.
+     */
+    private void scanDirectory() {
+        File parent = directory;
+        File[] children = parent.listFiles();
+        HashSet oldList = new HashSet(files.keySet());
+        for (int i = 0; i < children.length; i++) {
+            File child = children[i];
+            if(!child.canRead()) {
+                continue;
+            }
+            FileInfo now = child.isDirectory() ? getDirectoryInfo(child) : getFileInfo(child);
+            FileInfo then = (FileInfo) files.get(now.getPath());
+            if(then == null) { // Brand new, wait a bit to make sure it's not still changing
+                now.setNewFile(true);
+                files.put(now.getPath(), now);
+                log.debug("New File: "+now.getPath());
+            } else {
+                oldList.remove(then.getPath());
+                if(now.isSame(then)) { // File is the same as the last time we scanned it
+                    if(then.isChanging()) {
+                        try {
+                            log.debug("File finished changing: "+now.getPath());
+                            // Used to be changing, now in (hopefully) its final state
+                            if(then.isNewFile()) {
+                                then.setConfigId(DeployUtils.extractModuleIdFromArchive(child));
+                                if(listener == null || listener.fileAdded(child)) {
+                                    then.setNewFile(false);
+                                }
+                            } else {
+                                if(listener != null) listener.fileUpdated(child, then.getConfigId());
+                            }
+                            then.setChanging(false);
+                        } catch (Exception e) {
+                            log.error("Unable to deploy file "+child.getAbsolutePath(), e);
+                        }
+                    } // else it's just totally unchanged and we ignore it this pass
+                } else {
+                    // The two records are different -- record the latest as a file that's changing
+                    // and later when it stops changing we'll do the add or update as appropriate.
+                    now.setConfigId(then.getConfigId());
+                    now.setNewFile(then.isNewFile());
+                    files.put(now.getPath(), now);
+                    log.debug("File Changed: "+now.getPath());
+                }
+            }
+        }
+        // Look for any files we used to know about but didn't find in this pass
+        for (Iterator it = oldList.iterator(); it.hasNext();) {
+            String name = (String) it.next();
+            FileInfo info = (FileInfo) files.get(name);
+            log.debug("File removed: "+name);
+            if(info.isNewFile() || listener == null || listener.fileRemoved(new File(name), info.getConfigId())) {
+                files.remove(name);
+            }
+        }
+    }
+
+    /**
+     * We don't pay attention to the size of the directory or files in the
+     * directory, only the highest last modified time of anything in the
+     * directory.  Hopefully this is good enough.
+     */
+    private FileInfo getDirectoryInfo(File dir) {
+        FileInfo info = new FileInfo(dir.getAbsolutePath());
+        info.setSize(0);
+        info.setModified(getLastModifiedInDir(dir));
+        return info;
+    }
+
+    private long getLastModifiedInDir(File dir) {
+        long value = dir.lastModified();
+        File[] children = dir.listFiles();
+        long test;
+        for (int i = 0; i < children.length; i++) {
+            File child = children[i];
+            if(!child.canRead()) {
+                continue;
+            }
+            if(child.isDirectory()) {
+                test = getLastModifiedInDir(child);
+            } else {
+                test = child.lastModified();
+            }
+            if(test > value) {
+                value = test;
+            }
+        }
+        return value;
+    }
+
+    private FileInfo getFileInfo(File child) {
+        FileInfo info = new FileInfo(child.getAbsolutePath());
+        info.setSize(child.length());
+        info.setModified(child.lastModified());
+        return info;
+    }
+
+
+    private static class FileInfo implements Serializable {
+        private String path;
+        private long size;
+        private long modified;
+        private boolean newFile;
+        private boolean changing;
+        private String configId;
+
+        public FileInfo(String path) {
+            this.path = path;
+            newFile = false;
+            changing = true;
+        }
+
+        public String getPath() {
+            return path;
+        }
+
+        public long getSize() {
+            return size;
+        }
+
+        public void setSize(long size) {
+            this.size = size;
+        }
+
+        public long getModified() {
+            return modified;
+        }
+
+        public void setModified(long modified) {
+            this.modified = modified;
+        }
+
+        public boolean isNewFile() {
+            return newFile;
+        }
+
+        public void setNewFile(boolean newFile) {
+            this.newFile = newFile;
+        }
+
+        public boolean isChanging() {
+            return changing;
+        }
+
+        public void setChanging(boolean changing) {
+            this.changing = changing;
+        }
+
+        public String getConfigId() {
+            return configId;
+        }
+
+        public void setConfigId(String configId) {
+            this.configId = configId;
+        }
+
+        public boolean isSame(FileInfo info) {
+            if(!path.equals(info.path)) {
+                throw new IllegalArgumentException("Should only be used to compare two files representing the same path!");
+            }
+            return size == info.size && modified == info.modified;
+        }
+    }
+}

Propchange: geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/HotDeployer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/HotDeployer.java?rev=332243&view=auto
==============================================================================
--- geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/HotDeployer.java (added)
+++ geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/HotDeployer.java Wed Nov  9 23:57:19 2005
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.deployment.hot;
+
+/**
+ * Management interface for a hot deployer
+ *
+ * @version $Rev: 53762 $ $Date: 2004-10-04 18:54:53 -0400 (Mon, 04 Oct 2004) $
+ */
+public interface HotDeployer extends DirectoryMonitor.Listener {
+    public int getPollIntervalMillis();
+    public void setPollIntervalMillis(int millis);
+}

Propchange: geronimo/trunk/modules/hot-deploy/src/java/org/apache/geronimo/deployment/hot/HotDeployer.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message