User: starksm
Date: 01/12/28 16:06:50
Modified: src/main/org/jboss/deployment Tag: Branch_2_4
AutoDeployer.java
Log:
Fix problem with double deployment of unpackage archives when the archive
is explictly listed in the deployer url list and a child directory in
a directoy of the url list.
Revision Changes Path
No revision
No revision
1.7.2.2 +30 -36 jboss/src/main/org/jboss/deployment/AutoDeployer.java
Index: AutoDeployer.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/deployment/AutoDeployer.java,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- AutoDeployer.java 2001/12/10 02:35:36 1.7.2.1
+++ AutoDeployer.java 2001/12/29 00:06:50 1.7.2.2
@@ -46,7 +46,7 @@
* @author Rickard �berg ([EMAIL PROTECTED])
* @author Toby Allsopp ([EMAIL PROTECTED])
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.7.2.1 $
+ * @version $Revision: 1.7.2.2 $
*/
public class AutoDeployer
extends ServiceMBeanSupport
@@ -73,11 +73,8 @@
// Watch these directories for new files
ArrayList watchedDirectories = new ArrayList();
- // These URL's have been deployed. Check for new timestamp
- HashMap deployedURLs = new HashMap();
-
// These URL's are being watched
- ArrayList watchedURLs = new ArrayList();
+ HashMap watchedURLs = new HashMap();
// URL list
String urlList = "";
@@ -166,56 +163,53 @@
File[] files = dir.listFiles();
for (int idx = 0; idx < files.length; idx++)
{
- URL fileUrl = files[idx].toURL();
+ URL fileURL = files[idx].toURL();
// Check if it's a deployable file
for (int j=0; j<deployerNames.length; ++j)
{
- if (!deployableFilters[j].accept(null, fileUrl.getFile()))
+ if (!deployableFilters[j].accept(null, fileURL.getFile()))
continue; // Was not deployable - skip it...
-
- if (deployedURLs.get(fileUrl) == null)
- {
- // This file has not been seen before
- // Add to list of files to deploy automatically
- watchedURLs.add(new DeploymentInfo(fileUrl));
- deployedURLs.put(fileUrl, fileUrl);
- }
+ if( watchedURLs.containsKey(fileURL) == false )
+ watchedURLs.put(fileURL, new DeploymentInfo(fileURL));
}
}
}
// undeploy removed jars
- Iterator iterator = watchedURLs.iterator();
+ Iterator iterator = watchedURLs.values().iterator();
- while (iterator.hasNext()) {
- DeploymentInfo deployment = (DeploymentInfo)iterator.next();
+ while (iterator.hasNext())
+ {
+ DeploymentInfo deployment = (DeploymentInfo) iterator.next();
URL url = deployment.url;
// if the url is a file that doesn't exist
// TODO: real urls
- if (url.getProtocol().startsWith("file") && ! new
File(url.getFile()).exists()) {
-
+ if (url.getProtocol().startsWith("file") && ! new
File(url.getFile()).exists())
+ {
// the file does not exist anymore. undeploy
log.info("Auto undeploy of "+url);
- try {
+ try
+ {
undeploy(url.toString(), deployment.deployerName);
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error("Undeployment failed", e);
}
- deployedURLs.remove(url);
// this should be the safe way to call watchedURLS.remove
iterator.remove();
}
}
-
// Check watched URLs
- for (int i = 0; i < watchedURLs.size(); i++)
+ iterator = watchedURLs.values().iterator();
+ while (iterator.hasNext())
{
- DeploymentInfo deployment = (DeploymentInfo)watchedURLs.get(i);
+ DeploymentInfo deployment = (DeploymentInfo) iterator.next();
// Get last modified timestamp
long lm;
@@ -308,9 +302,8 @@
};
}
}
-
- StringTokenizer urls = new StringTokenizer(urlList, ",");
+ StringTokenizer urls = new StringTokenizer(urlList, ",");
// Add URLs to list
while (urls.hasMoreTokens())
{
@@ -326,9 +319,10 @@
if( Util.hasDeploymentDescriptor(modFile) >= 0 )
{
// This is an unpackaged J2EE module
- DeploymentInfo info = new DeploymentInfo(modFile.toURL());
- watchedURLs.add(info);
- log.info("Auto-deploying module directory: "+modFile);
+ URL modURL = modFile.toURL();
+ DeploymentInfo info = new DeploymentInfo(modURL);
+ watchedURLs.put(modURL, info);
+ log.info("Watching module directory: "+modFile);
}
else
{
@@ -348,8 +342,9 @@
try
{
File modFile = urlFile.getCanonicalFile();
- DeploymentInfo info = new DeploymentInfo(modFile.toURL());
- watchedURLs.add(info);
+ URL modURL = modFile.toURL();
+ DeploymentInfo info = new DeploymentInfo(modURL);
+ watchedURLs.put(modURL, info);
log.info("Auto-deploying module archive: "+modFile);
}
catch (Exception e)
@@ -361,7 +356,8 @@
{
try
{
- watchedURLs.add(new DeploymentInfo(new URL(url)));
+ URL infoURL = new URL(url);
+ watchedURLs.put(infoURL, new DeploymentInfo(infoURL));
} catch (MalformedURLException e)
{
// Didn't work
@@ -387,7 +383,6 @@
// Clear lists
watchedDirectories.clear();
watchedURLs.clear();
- deployedURLs.clear();
}
// Protected -----------------------------------------------------
@@ -459,7 +454,6 @@
if( protocol.equals("file") && watchDir.isDirectory() )
{
String path = Util.getDeploymentDescriptor(watchDir);
-System.out.println("Watch DD = "+watchDir+" / "+path);
watch = new URL(watch, path);
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development