[jboss-cvs] JBossAS SVN: r75803 - in projects/demos/trunk: jmx/src/resources and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 14 16:15:41 EDT 2008


Author: alesj
Date: 2008-07-14 16:15:41 -0400 (Mon, 14 Jul 2008)
New Revision: 75803

Modified:
   projects/demos/trunk/bootstrap/src/main/org/jboss/demos/boostrap/HDScanner.java
   projects/demos/trunk/bootstrap/src/main/org/jboss/demos/boostrap/MainDeployerHelper.java
   projects/demos/trunk/jmx/src/resources/varia-deployers-beans.xml
Log:
Keep file's timestamp.
Add @JMX annotation plugin.

Modified: projects/demos/trunk/bootstrap/src/main/org/jboss/demos/boostrap/HDScanner.java
===================================================================
--- projects/demos/trunk/bootstrap/src/main/org/jboss/demos/boostrap/HDScanner.java	2008-07-14 20:12:03 UTC (rev 75802)
+++ projects/demos/trunk/bootstrap/src/main/org/jboss/demos/boostrap/HDScanner.java	2008-07-14 20:15:41 UTC (rev 75803)
@@ -23,9 +23,9 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.HashSet;
+import java.util.HashMap;
 import java.util.List;
-import java.util.Set;
+import java.util.Map;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
@@ -50,12 +50,12 @@
 
    private MainDeployerHelper helper;
    private VirtualFile root;
-   private Set<VirtualFile> files = new HashSet<VirtualFile>();
+   private Map<String, Long> files = new HashMap<String, Long>();
 
    public HDScanner(MainDeployerHelper helper, File file) throws IOException
    {
       this.helper = helper;
-      this.root = VFS.getRoot(file.toURL());
+      this.root = VFS.getRoot(file.toURI());
    }
 
    public void setScanThreadName(String scanThreadName)
@@ -114,34 +114,35 @@
 
    protected void scan() throws Throwable
    {
-      Set<VirtualFile> tmp = new HashSet<VirtualFile>();
+      Map<String, Long> tmp = new HashMap<String, Long>();
       List<VirtualFile> children = root.getChildren();
       for (VirtualFile file : children)
       {
-         if (files.contains(file) == false)
+         String fileName = file.getName();
+         if (files.containsKey(fileName) == false)
          {
             helper.deploy(file);
             log.info("Deploy: " + file);
-            tmp.add(file);
          }
          else
          {
-            if (file.hasBeenModified())
+            long timestamp = files.get(fileName);
+            if (timestamp < file.getLastModified())
             {
                helper.redeploy(file);
                log.info("Redeploy: " + file);
             }
-            files.remove(file);
-            tmp.add(file);
+            files.remove(fileName);
          }
+         tmp.put(fileName, file.getLastModified());
       }
-      for (VirtualFile file : files)
+      for (String fileName : files.keySet())
       {
-         helper.undeploy(file);
-         log.info("Undeploy: " + file);
+         helper.undeploy(fileName);
+         log.info("Undeploy: " + fileName);
       }
       files.clear();
-      files.addAll(tmp);
+      files.putAll(tmp);
       log.info("Process deployments...");
       helper.process();
    }

Modified: projects/demos/trunk/bootstrap/src/main/org/jboss/demos/boostrap/MainDeployerHelper.java
===================================================================
--- projects/demos/trunk/bootstrap/src/main/org/jboss/demos/boostrap/MainDeployerHelper.java	2008-07-14 20:12:03 UTC (rev 75802)
+++ projects/demos/trunk/bootstrap/src/main/org/jboss/demos/boostrap/MainDeployerHelper.java	2008-07-14 20:15:41 UTC (rev 75803)
@@ -21,9 +21,11 @@
 */
 package org.jboss.demos.boostrap;
 
+import java.util.Map;
+import java.util.HashMap;
+
 import org.jboss.deployers.client.spi.DeployerClient;
 import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.client.spi.DeploymentFactory;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.virtual.VirtualFile;
@@ -35,10 +37,12 @@
 {
    private DeployerClient deployerClient;
    private VFSDeploymentFactory factory;
+   private Map<String, Deployment> deployments;
 
    public MainDeployerHelper(DeployerClient deployerClient)
    {
       this.deployerClient = deployerClient;
+      this.deployments = new HashMap<String, Deployment>();
    }
 
    protected VFSDeploymentFactory getDeploymentFactory()
@@ -53,23 +57,28 @@
       return getDeploymentFactory().createVFSDeployment(file);
    }
 
-   public void deploy(VirtualFile file) throws DeploymentException
+   protected Deployment handleDeployment(VirtualFile file) throws DeploymentException
    {
       Deployment deployment = createDeployment(file);
       deployerClient.addDeployment(deployment);
+      return deployments.put(file.getName(), deployment);
    }
 
+   public void deploy(VirtualFile file) throws DeploymentException
+   {
+      handleDeployment(file);
+   }
+
    public void redeploy(VirtualFile file) throws DeploymentException
    {
-      Deployment deployment = createDeployment(file);
-      deployerClient.addDeployment(deployment);
-
+      handleDeployment(file);
    }
 
-   public void undeploy(VirtualFile file) throws DeploymentException
+   public void undeploy(String fileName) throws DeploymentException
    {
-      Deployment deployment = createDeployment(file);
-      deployerClient.removeDeployment(deployment);
+      Deployment deployment = deployments.get(fileName);
+      if (deployment != null)
+         deployerClient.removeDeployment(deployment);
    }
 
    public void process() throws DeploymentException

Modified: projects/demos/trunk/jmx/src/resources/varia-deployers-beans.xml
===================================================================
--- projects/demos/trunk/jmx/src/resources/varia-deployers-beans.xml	2008-07-14 20:12:03 UTC (rev 75802)
+++ projects/demos/trunk/jmx/src/resources/varia-deployers-beans.xml	2008-07-14 20:15:41 UTC (rev 75803)
@@ -18,4 +18,8 @@
   <!-- Adding @Spring annotation handler -->
   <bean name="SpringAnnotationPlugin" class="org.jboss.spring.annotations.SpringBeanAnnotationPlugin" />
 
+  <!-- Adding @JMX annotation handler -->
+  <bean name="JmxFieldAnnotationPlugin" class="org.jboss.system.microcontainer.jmx.JMXFieldAnnotationPlugin" />
+  <bean name="JmxPropertyAnnotationPlugin" class="org.jboss.system.microcontainer.jmx.JMXPropertyAnnotationPlugin" />
+
 </deployment>




More information about the jboss-cvs-commits mailing list