[jboss-cvs] JBossAS SVN: r61134 - in trunk/system/src/main/org/jboss: profileservice/spi and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 6 03:45:12 EST 2007
Author: scott.stark at jboss.org
Date: 2007-03-06 03:45:11 -0500 (Tue, 06 Mar 2007)
New Revision: 61134
Added:
trunk/system/src/main/org/jboss/profileservice/spi/ModificationInfo.java
trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/
trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
Modified:
trunk/system/src/main/org/jboss/deployers/plugins/scanner/VFSDeploymentScannerImpl.java
trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
Log:
JBAS-4055, initial hot deployment implementation based on the profile service.
Modified: trunk/system/src/main/org/jboss/deployers/plugins/scanner/VFSDeploymentScannerImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/plugins/scanner/VFSDeploymentScannerImpl.java 2007-03-06 08:28:44 UTC (rev 61133)
+++ trunk/system/src/main/org/jboss/deployers/plugins/scanner/VFSDeploymentScannerImpl.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -63,8 +63,7 @@
/**
- * A DeploymentScanner build on top of the VFS and MainDeployer. This is a
- * first pass to flesh out the APIs/concepts.
+ * A DeploymentScanner built on the ProfileService and MainDeployer.
*
* @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
* @author Scott.Stark at jboss.org
@@ -76,9 +75,6 @@
private static final Logger log = Logger.getLogger(VFSDeploymentScannerImpl.class);
// Private Data --------------------------------------------------
private MainDeployer mainDeployer;
- /** The structure builder that translates structure metadata to deployments */
- private StructureBuilder structureBuilder;
- private StructuredDeployers structureDeployers = new BasicStructuredDeployers();
/** */
private VirtualFileFilter filter;
@@ -118,17 +114,6 @@
this.mainDeployer = deployer;
}
- /**
- * Get the structure deployers
- *
- * @return the structure deployers
- */
- public synchronized Set<StructureDeployer> getStructureDeployers()
- {
- SortedSet<StructureDeployer> sdeployers = structureDeployers.getDeployers();
- return sdeployers;
- }
-
public VirtualFileFilter getFilterInstance()
{
return filter;
Modified: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2007-03-06 08:28:44 UTC (rev 61133)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -106,6 +106,9 @@
public Collection<DeploymentContext> getDeployments()
throws Exception;
+ public Collection<ModificationInfo> getModifiedDeployments()
+ throws Exception;
+
// Managed object attachments for a deployment
public void addManagedObject(String vfsPath, Attachments edits)
throws Exception;
Added: trunk/system/src/main/org/jboss/profileservice/spi/ModificationInfo.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/ModificationInfo.java (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/ModificationInfo.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi;
+
+import java.io.Serializable;
+
+import org.jboss.deployers.spi.structure.DeploymentContext;
+
+/**
+ * Represents a modified deployment returned from the modified deployments scan.
+ *
+ * @see Profile#getModifiedDeployments()
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ModificationInfo implements Serializable
+{
+ private final static long serialVersionUID = 1;
+
+ public enum ModifyStatus {ADDED, MODIFIED, REMOVED};
+ private DeploymentContext ctx;
+ private long lastModified;
+ private ModifyStatus status;
+
+ public ModificationInfo(DeploymentContext ctx, long lastModified, ModifyStatus status)
+ {
+ super();
+ this.ctx = ctx;
+ this.lastModified = lastModified;
+ this.status = status;
+ }
+
+ public DeploymentContext getCtx()
+ {
+ return ctx;
+ }
+
+ public long getLastModified()
+ {
+ return lastModified;
+ }
+
+ public ModifyStatus getStatus()
+ {
+ return status;
+ }
+
+}
Property changes on: trunk/system/src/main/org/jboss/profileservice/spi/ModificationInfo.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: trunk/system/src/main/org/jboss/profileservice/spi/Profile.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/Profile.java 2007-03-06 08:28:44 UTC (rev 61133)
+++ trunk/system/src/main/org/jboss/profileservice/spi/Profile.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -147,6 +147,27 @@
throws Exception;
/**
+ * Get the deployments that have been modified since the last
+ * check.
+ *
+ * @return the modified deployments, empty if none exist or
+ * the profile does not support hot deployments.
+ *
+ * @throws Exception - thrown on error scanning for deployments
+ */
+ public Collection<ModificationInfo> getModifiedDeployments()
+ throws Exception;
+
+ /**
+ * Enable/disable the getModifiedDeployments results. This can be
+ * used to disable the getModifiedDeployments results during
+ * periods such as bootstrap where changes should be delayed.
+ * @see #getModifiedDeployments
+ * @param flag - the enable/disable flag
+ */
+ public void enableModifiedDeploymentChecks(boolean flag);
+
+ /**
* Get the config
*
* @return the config
@@ -161,4 +182,5 @@
* @return true if the deployment is found or false otherwise
*/
public boolean hasDeployment(String name, DeploymentPhase phase);
+
}
Modified: trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java 2007-03-06 08:28:44 UTC (rev 61133)
+++ trunk/system/src/main/org/jboss/system/server/profile/basic/ProfileImpl.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -26,14 +26,18 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.jboss.deployers.plugins.structure.AbstractDeploymentContext;
import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.profileservice.spi.ModificationInfo;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.Profile;
-import org.jboss.profileservice.spi.Profile.DeploymentPhase;
+import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
import org.jboss.util.JBossObject;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -244,6 +248,79 @@
return Collections.unmodifiableCollection(deployments);
}
+ /**
+ * Go through the applications looking for modifications. This also
+ * picks the last application parent directory as the basis for
+ * scanning for new deployments.
+ * TODO: to handle multiple application/hotdeployment directories a
+ * set of parent dirs needs to be built.
+ */
+ public Collection<ModificationInfo> getModifiedDeployments()
+ throws Exception
+ {
+ ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
+ Collection<DeploymentContext> apps = getApplications();
+ boolean trace = log.isTraceEnabled();
+ if( trace )
+ log.trace("Checking applications for modifications");
+ VirtualFile applicationDir = null;
+ if( apps != null )
+ {
+ Iterator<DeploymentContext> iter = apps.iterator();
+ while( iter.hasNext() )
+ {
+ DeploymentContext ctx = iter.next();
+ VirtualFile root = ctx.getRoot();
+ // Save the containing parent dir to scan for new deployments
+ applicationDir = root.getParent();
+ Long rootLastModified = root.getLastModified();
+ String name = root.getPathName();
+ // Check for removal
+ if( root.exists() == false )
+ {
+ ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.REMOVED);
+ modified.add(info);
+ iter.remove();
+ if( trace )
+ log.trace(name+" was removed");
+ }
+ // Check for modification
+ else if( root.hasBeenModified() )
+ {
+ if( trace )
+ log.trace(name+" was modified: "+rootLastModified);
+ // Need to create a duplicate ctx
+ DeploymentContext ctx2 = new AbstractDeploymentContext(root);
+ ModificationInfo info = new ModificationInfo(ctx2, rootLastModified, ModifyStatus.MODIFIED);
+ modified.add(info);
+ }
+ // TODO: this could check metadata files modifications as well
+ }
+ // Now check for additions
+ VFS deployVFS = VFS.getVFS(applicationDir.toURI());
+ VirtualFile deployDir = deployVFS.getRoot();
+ List<VirtualFile> children = deployDir.getChildren();
+ for(VirtualFile vf : children)
+ {
+ if( applications.containsKey(vf.getPathName()) == false )
+ {
+ DeploymentContext ctx = new AbstractDeploymentContext(vf);
+ ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
+ modified.add(info);
+ applications.put(vf.getPathName(), ctx);
+ }
+ }
+ }
+ return modified;
+ }
+
+ /**
+ * Noop as basic profile does not support hot deployment currently
+ */
+ public void enableModifiedDeploymentChecks(boolean flag)
+ {
+ }
+
public Collection<DeploymentContext> getDeployments(DeploymentPhase phase)
{
Collection<DeploymentContext> ctxs = null;
Modified: trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java 2007-03-06 08:28:44 UTC (rev 61133)
+++ trunk/system/src/main/org/jboss/system/server/profile/repository/ProfileImpl.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -23,11 +23,13 @@
import java.net.URI;
import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.jboss.deployers.spi.structure.DeploymentContext;
import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.ModificationInfo;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.Profile;
import org.jboss.profileservice.spi.Profile.DeploymentPhase;
@@ -49,6 +51,8 @@
private String version;
/** The repository containing the deployment contents */
private DeploymentRepository repository;
+ /** Is hot deployment checking enabled */
+ private volatile boolean hotdeployEnabled;
/**
*
@@ -107,6 +111,26 @@
{
return repository.getDeployments();
}
+
+ /**
+ *
+ */
+ public Collection<ModificationInfo> getModifiedDeployments()
+ throws Exception
+ {
+ Collection<ModificationInfo> modified = Collections.emptyList();
+ if( hotdeployEnabled == true )
+ modified = repository.getModifiedDeployments();
+ return modified;
+ }
+ /**
+ * Enable/disable getModifiedDeployments results.
+ */
+ public synchronized void enableModifiedDeploymentChecks(boolean flag)
+ {
+ this.hotdeployEnabled = flag;
+ }
+
public void addDeployment(DeploymentContext d, DeploymentPhase phase)
throws Exception
{
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java 2007-03-06 08:28:44 UTC (rev 61133)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/ProfileServiceBootstrap.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -245,6 +245,10 @@
try
{
loadProfile(profileName);
+ // Mark the profile as ready for hotdeployment if supported
+ Profile profile = profileService.getActiveProfile();
+ if( profile != null )
+ profile.enableModifiedDeploymentChecks(true);
}
catch (IncompleteDeploymentException e)
{
Added: trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java (rev 0)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -0,0 +1,272 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.server.profileservice.hotdeploy;
+
+import java.util.Collection;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.deployers.spi.deployment.MainDeployer;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.logging.Logger;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.Profile;
+import org.jboss.profileservice.spi.ProfileService;
+
+
+/**
+ * A DeploymentScanner built on the ProfileService and MainDeployer.
+ *
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class HDScanner
+ implements Runnable
+{
+ private static final Logger log = Logger.getLogger(HDScanner.class);
+ // Private Data --------------------------------------------------
+ /** The MainDeployer used to deploy modifications */
+ private MainDeployer mainDeployer;
+ /** The ProfileService used to determine modified deployments */
+ private ProfileService profileService;
+
+ /** The ExecutorService/ThreadPool for performing scans */
+ private ScheduledExecutorService scanExecutor;
+ private ScheduledFuture activeScan;
+ private String scanThreadName = "HDScanner";
+
+ /** Period in ms between deployment scans */
+ private long scanPeriod = 5000;
+ private int scanCount;
+
+ // Constructor ---------------------------------------------------
+
+ public HDScanner()
+ {
+ // empty
+ }
+
+ // Attributes ----------------------------------------------------
+
+ public void setMainDeployer(MainDeployer deployer)
+ {
+ this.mainDeployer = deployer;
+ }
+
+ public ProfileService getProfileService()
+ {
+ return profileService;
+ }
+ public void setProfileService(ProfileService profileService)
+ {
+ this.profileService = profileService;
+ }
+
+ /**
+ * @return Returns the scanExecutor.
+ */
+ public ScheduledExecutorService getScanExecutor()
+ {
+ return this.scanExecutor;
+ }
+
+ /**
+ * @param scanExecutor The scanExecutor to set.
+ */
+ public void setScanExecutor(ScheduledExecutorService scanExecutor)
+ {
+ this.scanExecutor = scanExecutor;
+ }
+
+ public String getScanThreadName()
+ {
+ return scanThreadName;
+ }
+
+ public void setScanThreadName(String scanThreadName)
+ {
+ this.scanThreadName = scanThreadName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.deployment.scanner.VFSDeploymentScanner#getScanPeriod()
+ */
+ public long getScanPeriod()
+ {
+ return scanPeriod;
+ }
+ /* (non-Javadoc)
+ * @see org.jboss.deployment.scanner.VFSDeploymentScanner#setScanPeriod(long)
+ */
+ public void setScanPeriod(long period)
+ {
+ this.scanPeriod = period;
+ }
+
+ /** Are deployment scans enabled.
+ */
+ public boolean isScanEnabled()
+ {
+ return activeScan != null;
+ }
+
+ public synchronized int getScanCount()
+ {
+ return scanCount;
+ }
+ public synchronized void resetScanCount()
+ {
+ this.scanCount = 0;
+ }
+
+ /**
+ * Enable/disable deployment scans.
+ * @param scanEnabled true to enable scans, false to disable.
+ */
+ public synchronized void setScanEnabled(boolean scanEnabled)
+ {
+ if( scanEnabled == true && activeScan == null )
+ {
+ activeScan = this.scanExecutor.scheduleWithFixedDelay(this, 0,
+ scanPeriod, TimeUnit.MILLISECONDS);
+ }
+ else if( scanEnabled == false && activeScan != null )
+ {
+ activeScan.cancel(true);
+ activeScan = null;
+ }
+ }
+
+
+ // Operations ----------------------------------------------------
+
+ public void start() throws Exception
+ {
+ // Default to a single thread executor
+ if( scanExecutor == null )
+ {
+ scanExecutor = Executors.newSingleThreadScheduledExecutor(
+ new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ return new Thread(r, HDScanner.this.getScanThreadName());
+ }
+ }
+ );
+ }
+ activeScan = scanExecutor.scheduleWithFixedDelay(this, 0,
+ scanPeriod, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * Executes scan
+ *
+ */
+ public void run()
+ {
+ try
+ {
+ scan();
+ }
+ catch(Throwable e)
+ {
+ log.warn("Scan failed", e);
+ }
+ finally
+ {
+ incScanCount();
+ }
+ }
+
+ public void stop()
+ {
+ if( activeScan != null )
+ {
+ activeScan.cancel(true);
+ activeScan = null;
+ }
+ }
+
+ public synchronized void scan() throws Exception
+ {
+ boolean trace = log.isTraceEnabled();
+
+ // Query the ProfileService for deployments
+ if( trace )
+ log.trace("Begin deployment scan");
+
+
+ // Get the modified deployments
+ Profile activeProfile = profileService.getActiveProfile();
+ Collection<ModificationInfo> modified = activeProfile.getModifiedDeployments();
+ for(ModificationInfo info : modified)
+ {
+ DeploymentContext ctx = info.getCtx();
+ switch( info.getStatus() )
+ {
+ case ADDED:
+ mainDeployer.addDeploymentContext(ctx);
+ break;
+ case MODIFIED:
+ mainDeployer.addDeploymentContext(ctx);
+ break;
+ case REMOVED:
+ mainDeployer.removeDeploymentContext(ctx.getName());
+ break;
+ }
+ }
+
+ // Process the changes
+ try
+ {
+ if( modified.size() > 0 )
+ mainDeployer.process();
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to process changes", e);
+ // TODO: somehow need to ignore bad deployments to avoid repeated errors
+ return;
+ }
+
+ if( trace )
+ log.trace("End deployment scan");
+ }
+
+ /**
+ * Inc the scanCount and to a notifyAll.
+ *
+ */
+ protected synchronized void incScanCount()
+ {
+ scanCount ++;
+ notifyAll();
+ }
+
+ // Private -------------------------------------------------------
+
+}
Property changes on: trunk/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2007-03-06 08:28:44 UTC (rev 61133)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2007-03-06 08:45:11 UTC (rev 61134)
@@ -27,9 +27,11 @@
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.URI;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -42,9 +44,11 @@
import org.jboss.logging.Logger;
import org.jboss.profileservice.spi.AttachmentsSerializer;
import org.jboss.profileservice.spi.DeploymentRepository;
+import org.jboss.profileservice.spi.ModificationInfo;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
import org.jboss.profileservice.spi.Profile.DeploymentPhase;
import org.jboss.util.file.Files;
import org.jboss.virtual.VFS;
@@ -88,6 +92,7 @@
private LinkedHashMap<String,DeploymentContext> deployerCtxs = new LinkedHashMap<String,DeploymentContext>();
/** The application DeploymentContexts */
private LinkedHashMap<String,DeploymentContext> applicationCtxs = new LinkedHashMap<String,DeploymentContext>();
+ /** The {@link DeploymentContext#getTransientManagedObjects()} serializer */
private AttachmentsSerializer serializer;
public SerializableDeploymentRepository(File root, ProfileKey key)
@@ -275,6 +280,66 @@
deployments.addAll(this.applicationCtxs.values());
return Collections.unmodifiableCollection(deployments);
}
+
+ /**
+ * Scan the applications for changes.
+ */
+ public synchronized Collection<ModificationInfo> getModifiedDeployments()
+ throws Exception
+ {
+ ArrayList<ModificationInfo> modified = new ArrayList<ModificationInfo>();
+ Collection<DeploymentContext> apps = getApplications();
+ boolean trace = log.isTraceEnabled();
+ if( trace )
+ log.trace("Checking applications for modifications");
+ if( apps != null )
+ {
+ Iterator<DeploymentContext> iter = apps.iterator();
+ while( iter.hasNext() )
+ {
+ DeploymentContext ctx = iter.next();
+ VirtualFile root = ctx.getRoot();
+ Long rootLastModified = root.getLastModified();
+ String name = root.getPathName();
+ // Check for removal
+ if( root.exists() == false )
+ {
+ ModificationInfo info = new ModificationInfo(ctx, rootLastModified, ModifyStatus.REMOVED);
+ modified.add(info);
+ iter.remove();
+ if( trace )
+ log.trace(name+" was removed");
+ }
+ // Check for modification
+ else if( root.hasBeenModified() )
+ {
+ if( trace )
+ log.trace(name+" was modified: "+rootLastModified);
+ // Need to create a duplicate ctx
+ DeploymentContext ctx2 = loadDeploymentData(root);
+ ModificationInfo info = new ModificationInfo(ctx2, rootLastModified, ModifyStatus.MODIFIED);
+ modified.add(info);
+ }
+ // TODO: this could check metadata files modifications as well
+ }
+ // Now check for additions
+ VFS deployVFS = VFS.getVFS(applicationDir.toURI());
+ VirtualFile deployDir = deployVFS.getRoot();
+ List<VirtualFile> children = deployDir.getChildren();
+ for(VirtualFile vf : children)
+ {
+ if( applicationCtxs.containsKey(vf.getPathName()) == false )
+ {
+ DeploymentContext ctx = loadDeploymentData(vf);
+ ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
+ modified.add(info);
+ applicationCtxs.put(vf.getPathName(), ctx);
+ }
+ }
+ }
+ return modified;
+ }
+
public Collection<DeploymentContext> getDeployments(DeploymentPhase phase)
throws Exception
{
@@ -611,6 +676,11 @@
}
}
+ /**
+ * TODO: this could be dropped since the serialize aspect loads the data
+ * @param file
+ * @return
+ */
private DeploymentContext loadDeploymentData(VirtualFile file)
{
// Check for a persisted context
More information about the jboss-cvs-commits
mailing list