[jboss-cvs] JBossAS SVN: r84583 - in projects/demos/microcontainer/trunk/bootstrap/src/main: resources/META-INF and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 20 17:36:31 EST 2009
Author: alesj
Date: 2009-02-20 17:36:31 -0500 (Fri, 20 Feb 2009)
New Revision: 84583
Modified:
projects/demos/microcontainer/trunk/bootstrap/src/main/java/org/jboss/demos/bootstrap/HDScanner.java
projects/demos/microcontainer/trunk/bootstrap/src/main/java/org/jboss/demos/bootstrap/MainDeployerHelper.java
projects/demos/microcontainer/trunk/bootstrap/src/main/resources/META-INF/bootstrap-beans.xml
Log:
Update HD scanner, add VFS cache.
Modified: projects/demos/microcontainer/trunk/bootstrap/src/main/java/org/jboss/demos/bootstrap/HDScanner.java
===================================================================
--- projects/demos/microcontainer/trunk/bootstrap/src/main/java/org/jboss/demos/bootstrap/HDScanner.java 2009-02-20 22:26:45 UTC (rev 84582)
+++ projects/demos/microcontainer/trunk/bootstrap/src/main/java/org/jboss/demos/bootstrap/HDScanner.java 2009-02-20 22:36:31 UTC (rev 84583)
@@ -23,9 +23,9 @@
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
-import java.util.Map;
+import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
@@ -50,7 +50,7 @@
private MainDeployerHelper helper;
private VirtualFile root;
- private Map<String, Long> files = new HashMap<String, Long>();
+ private Set<String> files = new HashSet<String>();
public HDScanner(MainDeployerHelper helper, String path) throws IOException
{
@@ -120,35 +120,34 @@
protected void scan() throws Throwable
{
- Map<String, Long> tmp = new HashMap<String, Long>();
+ Set<String> tmp = new HashSet<String>();
List<VirtualFile> children = root.getChildren();
for (VirtualFile file : children)
{
String fileName = file.getName();
- if (files.containsKey(fileName) == false)
+ if (files.contains(fileName) == false)
{
helper.deploy(file);
log.info("Deploy: " + file);
}
else
{
- long timestamp = files.get(fileName);
- if (timestamp < file.getLastModified())
+ if (helper.hasBeenModified(fileName))
{
helper.redeploy(file);
log.info("Redeploy: " + file);
}
files.remove(fileName);
}
- tmp.put(fileName, file.getLastModified());
+ tmp.add(fileName);
}
- for (String fileName : files.keySet())
+ for (String fileName : files)
{
helper.undeploy(fileName);
log.info("Undeploy: " + fileName);
}
files.clear();
- files.putAll(tmp);
+ files.addAll(tmp);
log.info("Process deployments...");
helper.process();
}
Modified: projects/demos/microcontainer/trunk/bootstrap/src/main/java/org/jboss/demos/bootstrap/MainDeployerHelper.java
===================================================================
--- projects/demos/microcontainer/trunk/bootstrap/src/main/java/org/jboss/demos/bootstrap/MainDeployerHelper.java 2009-02-20 22:26:45 UTC (rev 84582)
+++ projects/demos/microcontainer/trunk/bootstrap/src/main/java/org/jboss/demos/bootstrap/MainDeployerHelper.java 2009-02-20 22:36:31 UTC (rev 84583)
@@ -21,13 +21,15 @@
*/
package org.jboss.demos.bootstrap;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
+import java.io.IOException;
import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
import org.jboss.virtual.VirtualFile;
/**
@@ -37,12 +39,14 @@
{
private DeployerClient deployerClient;
private VFSDeploymentFactory factory;
- private Map<String, Deployment> deployments;
+ private StructureModificationChecker checker;
+ private Map<String, VFSDeployment> deployments;
+
public MainDeployerHelper(DeployerClient deployerClient)
{
this.deployerClient = deployerClient;
- this.deployments = new HashMap<String, Deployment>();
+ this.deployments = new HashMap<String, VFSDeployment>();
}
protected VFSDeploymentFactory getDeploymentFactory()
@@ -52,18 +56,24 @@
return factory;
}
- protected Deployment createDeployment(VirtualFile file)
+ protected VFSDeployment createDeployment(VirtualFile file)
{
return getDeploymentFactory().createVFSDeployment(file);
}
- protected Deployment handleDeployment(VirtualFile file) throws DeploymentException
+ protected VFSDeployment handleDeployment(VirtualFile file) throws DeploymentException
{
- Deployment deployment = createDeployment(file);
+ VFSDeployment deployment = createDeployment(file);
deployerClient.addDeployment(deployment);
return deployments.put(file.getName(), deployment);
}
+ public boolean hasBeenModified(String fileName) throws IOException
+ {
+ VFSDeployment deployment = deployments.get(fileName);
+ return deployment != null && checker.hasStructureBeenModified(deployment);
+ }
+
public void deploy(VirtualFile file) throws DeploymentException
{
handleDeployment(file);
@@ -76,7 +86,7 @@
public void undeploy(String fileName) throws DeploymentException
{
- Deployment deployment = deployments.get(fileName);
+ VFSDeployment deployment = deployments.get(fileName);
if (deployment != null)
deployerClient.removeDeployment(deployment);
}
@@ -86,4 +96,9 @@
deployerClient.process();
deployerClient.checkComplete();
}
+
+ public void setChecker(StructureModificationChecker checker)
+ {
+ this.checker = checker;
+ }
}
Modified: projects/demos/microcontainer/trunk/bootstrap/src/main/resources/META-INF/bootstrap-beans.xml
===================================================================
--- projects/demos/microcontainer/trunk/bootstrap/src/main/resources/META-INF/bootstrap-beans.xml 2009-02-20 22:26:45 UTC (rev 84582)
+++ projects/demos/microcontainer/trunk/bootstrap/src/main/resources/META-INF/bootstrap-beans.xml 2009-02-20 22:36:31 UTC (rev 84583)
@@ -1,5 +1,26 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- VFS -->
+
+ <bean name="VFSCache">
+ <constructor factoryClass="org.jboss.virtual.spi.cache.VFSCacheFactory" factoryMethod="getInstance">
+ <!-- Use the CombinedVFSCache implementation -->
+ <parameter>org.jboss.virtual.plugins.cache.CombinedVFSCache</parameter>
+ </constructor>
+ <start ignored="true"/>
+ <property name="permanentRoots">
+ <map keyClass="java.net.URL" valueClass="org.jboss.virtual.spi.ExceptionHandler">
+ <entry>
+ <key>${demos.home}/sandbox</key>
+ <value><null/></value>
+ </entry>
+ </map>
+ </property>
+ <property name="realCache">
+ <bean class="org.jboss.virtual.plugins.cache.IterableTimedVFSCache"/>
+ </property>
+ </bean>
+
<!-- The MainDeployer -->
<bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
<property name="structuralDeployers"><inject bean="StructuralDeployers"/></property>
@@ -10,11 +31,19 @@
<!-- The ManagedDeploymentCreator implementation -->
<bean name="ManagedDeploymentCreator" class="org.jboss.deployers.plugins.managed.DefaultManagedDeploymentCreator" />
+ <!-- ModificationType structure processor -->
+ <bean name="ModificationTypeStructureProcessor" class="org.jboss.deployers.vfs.plugins.structure.modify.ModificationTypeStructureProcessor">
+ <incallback method="addMatcher"/>
+ <uncallback method="removeMatcher"/>
+ </bean>
+
<!-- The holder for deployers that determine structure -->
<bean name="StructuralDeployers" class="org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl">
<property name="structureBuilder">
<!-- The consolidator of the structure information -->
- <bean name="StructureBuilder" class="org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder"/>
+ <bean name="StructureBuilder" class="org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder">
+ <property name="structureProcessor"><inject bean="ModificationTypeStructureProcessor"/></property>
+ </bean>
</property>
<!-- Accept any implementor of structure deployer -->
<incallback method="addDeployer"/>
@@ -103,12 +132,27 @@
<property name="system"><inject bean="ClassLoaderSystem"/></property>
</bean>
+ <!-- The structure modification cache and checker -->
+
+ <bean name="StructureModCache" class="org.jboss.deployers.vfs.spi.structure.modified.TreeStructureCache">
+ <destroy method="flush"/>
+ </bean>
+
+ <bean name="StructureModificationChecker" class="org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker">
+ <constructor>
+ <parameter><inject bean="MainDeployer" /></parameter>
+ </constructor>
+ <property name="cache"><inject bean="StructureModCache" /></property>
+ <property name="filter"><bean class="org.jboss.system.server.profile.basic.XmlIncludeVirtualFileFilter" /></property>
+ </bean>
+
<!-- HD scanner -->
<bean name="MainDeployerHelper" class="org.jboss.demos.bootstrap.MainDeployerHelper">
<constructor>
<parameter><inject bean="MainDeployer"/></parameter>
</constructor>
+ <property name="checker"><inject bean="StructureModificationChecker"/></property>
</bean>
<bean name="HDScanner" class="org.jboss.demos.bootstrap.HDScanner">
More information about the jboss-cvs-commits
mailing list