Author: kfujino
Date: Tue Apr 16 06:17:32 2013
New Revision: 1468311
URL: http://svn.apache.org/r1468311
Log:
Add support for specifying a pathname that is relative to the $CATALINA_BASE
directory.
Modified:
tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
tomcat/trunk/webapps/docs/config/cluster-deployer.xml
Modified: tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java?rev=1468311&r1=1468310&r2=1468311&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java Tue
Apr 16 06:17:32 2013
@@ -72,11 +72,23 @@ public class FarmWarDeployer extends Clu
protected final HashMap<String, FileMessageFactory> fileFactories =
new HashMap<>();
+ /**
+ * Deployment directory.
+ */
protected String deployDir;
+ private File deployDirFile = null;
+ /**
+ * Temporary directory.
+ */
protected String tempDir;
+ private File tempDirFile = null;
+ /**
+ * Watch directory.
+ */
protected String watchDir;
+ private File watchDirFile = null;
protected boolean watchEnabled = false;
@@ -149,7 +161,7 @@ public class FarmWarDeployer extends Clu
return;
}
if (watchEnabled) {
- watcher = new WarWatcher(this, new File(getWatchDir()));
+ watcher = new WarWatcher(this, getWatchDirFile());
if (log.isInfoEnabled()) {
log.info(sm.getString(
"farmWarDeployer.watchDir", getWatchDir()));
@@ -213,7 +225,7 @@ public class FarmWarDeployer extends Clu
String name = factory.getFile().getName();
if (!name.endsWith(".war"))
name = name + ".war";
- File deployable = new File(getDeployDir(), name);
+ File deployable = new File(getDeployDirFile(), name);
try {
String contextName = fmsg.getContextName();
if (!isServiced(contextName)) {
@@ -284,7 +296,7 @@ public class FarmWarDeployer extends Clu
*/
public synchronized FileMessageFactory getFactory(FileMessage msg)
throws java.io.FileNotFoundException, java.io.IOException {
- File writeToFile = new File(getTempDir(), msg.getFileName());
+ File writeToFile = new File(getTempDirFile(), msg.getFileName());
FileMessageFactory factory = fileFactories.get(msg.getFileName());
if (factory == null) {
factory = FileMessageFactory.getInstance(writeToFile, true);
@@ -431,7 +443,7 @@ public class FarmWarDeployer extends Clu
@Override
public void fileModified(File newWar) {
try {
- File deployWar = new File(getDeployDir(), newWar.getName());
+ File deployWar = new File(getDeployDirFile(), newWar.getName());
copy(newWar, deployWar);
ContextName cn = new ContextName(deployWar.getName());
if (log.isInfoEnabled())
@@ -593,6 +605,14 @@ public class FarmWarDeployer extends Clu
return deployDir;
}
+ public File getDeployDirFile() {
+ if (deployDirFile != null) return deployDirFile;
+
+ File dir = getAbsolutePath(getDeployDir());
+ this.deployDirFile = dir;
+ return dir;
+ }
+
public void setDeployDir(String deployDir) {
this.deployDir = deployDir;
}
@@ -601,6 +621,14 @@ public class FarmWarDeployer extends Clu
return tempDir;
}
+ public File getTempDirFile() {
+ if (tempDirFile != null) return tempDirFile;
+
+ File dir = getAbsolutePath(getTempDir());
+ this.tempDirFile = dir;
+ return dir;
+ }
+
public void setTempDir(String tempDir) {
this.tempDir = tempDir;
}
@@ -609,6 +637,14 @@ public class FarmWarDeployer extends Clu
return watchDir;
}
+ public File getWatchDirFile() {
+ if (watchDirFile != null) return watchDirFile;
+
+ File dir = getAbsolutePath(getWatchDir());
+ this.watchDirFile = dir;
+ return dir;
+ }
+
public void setWatchDir(String watchDir) {
this.watchDir = watchDir;
}
@@ -682,4 +718,16 @@ public class FarmWarDeployer extends Clu
return true;
}
+ private File getAbsolutePath(String path) {
+ File dir = new File(path);
+ if (!dir.isAbsolute()) {
+ dir = new File(getCluster().getContainer().getCatalinaBase(),
+ dir.getPath());
+ }
+ try {
+ dir = dir.getCanonicalFile();
+ } catch (IOException e) {// ignore
+ }
+ return dir;
+ }
}
Modified: tomcat/trunk/webapps/docs/config/cluster-deployer.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/cluster-deployer.xml?rev=1468311&r1=1468310&r2=1468311&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/cluster-deployer.xml (original)
+++ tomcat/trunk/webapps/docs/config/cluster-deployer.xml Tue Apr 16 06:17:32
2013
@@ -53,17 +53,22 @@
</attribute>
<attribute name="deployDir" required="true">
Deployment directory. This is the pathname of a directory where deploy
- the web applications. In the current implementation, this attribute
must
- be the same value as the <strong>Host's appBase</strong>.
+ the web applications. You may specify an absolute pathname, or a
+ pathname that is relative to the $CATALINA_BASE directory. In the
+ current implementation, this attribute must be the same value as the
+ <strong>Host's appBase</strong>.
</attribute>
<attribute name="tempDir" required="true">
The temporaryDirectory to store binary data when downloading a war from
- the cluster.
+ the cluster. You may specify an absolute pathname, or a pathname that
is
+ relative to the $CATALINA_BASE directory.
</attribute>
<attribute name="watchDir" required="false">
This is the pathname of a directory where watch for
changes(add/modify/remove)
- of web applications. <strong>Note: </strong> if
<strong>watchEnabled</strong>
- is false, this attribute will have no effect.
+ of web applications. You may specify an absolute pathname, or a
pathname
+ that is relative to the $CATALINA_BASE directory.
+ <strong>Note: </strong> if <strong>watchEnabled</strong> is false, this
+ attribute will have no effect.
</attribute>
<attribute name="watchEnabled" required="false">
Set to true if you want to watch for changes of web applications.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]