You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dw...@apache.org on 2007/05/17 23:45:26 UTC
svn commit: r539130 - in
/geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot:
DirectoryHotDeployer.java DirectoryMonitor.java
Author: dwoods
Date: Thu May 17 14:45:24 2007
New Revision: 539130
URL: http://svn.apache.org/viewvc?view=rev&rev=539130
Log:
GERONIMO-1431 Make deploy tool and hot deploy directory work better together. Rakesh, thanks for the patch.
Modified:
geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java
Modified: geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java?view=diff&rev=539130&r1=539129&r2=539130
==============================================================================
--- geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java (original)
+++ geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java Thu May 17 14:45:24 2007
@@ -181,11 +181,29 @@
}
public boolean isFileDeployed(File file, String configId) {
+ DeploymentManager mgr = null;
try {
- DeployUtils.identifyTargetModuleIDs(startupModules, configId, true).toArray(new TargetModuleID[0]);
+ if (startupModules != null) {
+ DeployUtils.identifyTargetModuleIDs(startupModules, configId, true).toArray(new TargetModuleID[0]);
+ }
+ else {
+ mgr = getDeploymentManager();
+ Target[] targets = mgr.getTargets();
+ TargetModuleID[] ids = mgr.getAvailableModules(null, targets);
+ DeployUtils.identifyTargetModuleIDs(ids, configId, true).toArray(new TargetModuleID[0]);
+ mgr.release();
+ mgr = null;
+ }
return true;
} catch (DeploymentException e) {
log.debug("Found new file in deploy directory on startup with ID " + configId);
+ } catch (Exception e) {
+ log.error("Unable to check status", e);
+ } finally {
+ if (mgr != null) {
+ mgr.release();
+ mgr = null;
+ }
return false;
}
}
Modified: geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java?view=diff&rev=539130&r1=539129&r2=539130
==============================================================================
--- geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java (original)
+++ geronimo/server/trunk/modules/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryMonitor.java Thu May 17 14:45:24 2007
@@ -19,6 +19,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import org.apache.geronimo.deployment.cli.DeployUtils;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.config.IOUtil;
@@ -55,8 +56,7 @@
boolean isServerRunning();
/**
- * Called during initialization on all files in the hot deploy
- * directory.
+ * Checks if the file with same configID is already deployed
*
* @return true if the file in question is already available in the
* server, false if it should be deployed on the next pass.
@@ -327,15 +327,56 @@
}
workingOnConfigId = null;
} else if (action.action == FileAction.NEW_FILE) {
- String result = listener.fileAdded(action.child);
- if (result != null) {
- if (!result.equals("")) {
- action.info.setConfigId(result);
- } else {
- action.info.setConfigId(calculateModuleId(action.child));
+ if (listener.isFileDeployed(action.child, calculateModuleId(action.child))) {
+ workingOnConfigId = calculateModuleId(action.child);
+ String result = listener.fileUpdated(action.child, workingOnConfigId);
+ if (result != null) {
+ if (!result.equals("")) {
+ action.info.setConfigId(result);
+ }
+ else {
+ action.info.setConfigId(calculateModuleId(action.child));
+ }
+ }
+ // remove the previous jar or directory if duplicate
+ File[] childs = directory.listFiles();
+ for (int i = 0; i < childs.length; i++) {
+ String path = childs[i].getAbsolutePath();
+ String configId = ((FileInfo)files.get(path)).configId;
+ if (configId != null && configId.equals(workingOnConfigId) && !action.child.getAbsolutePath().equals(path)) {
+ File fd = new File(path);
+ if (fd.isDirectory()) {
+ log.info("Deleting the Directory: "+path);
+ if (DeploymentUtil.recursiveDelete(fd))
+ log.debug("Successfully deleted the Directory: "+path);
+ else
+ log.error("Couldn't delete the hot deployed directory="+path);
+ }
+ else if (fd.isFile()) {
+ log.info("Deleting the File: "+path);
+ if (fd.delete()) {
+ log.debug("Successfully deleted the File: "+path);
+ }
+ else
+ log.error("Couldn't delete the hot deployed file="+path);
+ }
+ files.remove(path);
+ }
+ }
+ workingOnConfigId = null;
+ }
+ else {
+ String result = listener.fileAdded(action.child);
+ if (result != null) {
+ if (!result.equals("")) {
+ action.info.setConfigId(result);
+ }
+ else {
+ action.info.setConfigId(calculateModuleId(action.child));
+ }
}
- action.info.setNewFile(false);
}
+ action.info.setNewFile(false);
} else if (action.action == FileAction.UPDATED_FILE) {
workingOnConfigId = action.info.getConfigId();
String result = listener.fileUpdated(action.child, action.info.getConfigId());