You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/06/04 00:22:35 UTC
svn commit: r1131267 - in /tomcat/trunk: java/org/apache/catalina/ant/
webapps/docs/
Author: markt
Date: Fri Jun 3 22:22:35 2011
New Revision: 1131267
URL: http://svn.apache.org/viewvc?rev=1131267&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51251
Add web application version support to the Ant tasks.
Based on a patch provided by Eiji Takahashi.
Added:
tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java (with props)
Modified:
tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java
tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java
tomcat/trunk/java/org/apache/catalina/ant/StartTask.java
tomcat/trunk/java/org/apache/catalina/ant/StopTask.java
tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java
tomcat/trunk/webapps/docs/changelog.xml
Added: tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java?rev=1131267&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java (added)
+++ tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java Fri Jun 3 22:22:35 2011
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.ant;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.tools.ant.BuildException;
+
+public abstract class AbstractCatalinaCommandTask extends
+ AbstractCatalinaTask {
+
+ /**
+ * The context path of the web application we are managing.
+ */
+ protected String path = null;
+
+ public String getPath() {
+ return (this.path);
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ /**
+ * The context version of the web application we are managing.
+ */
+ protected String version = null;
+
+ public String getVersion() {
+ return (this.version);
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ // --------------------------------------------------------- Public Methods
+
+ /**
+ * Create query string for the specified command.
+ *
+ * @param command Command to be executed
+ *
+ * @exception BuildException if an error occurs
+ */
+ public StringBuilder createQueryString(String command) throws BuildException {
+ StringBuilder buffer = new StringBuilder();
+
+ try {
+ buffer.append(command);
+ if (path == null) {
+ throw new BuildException("Must specify 'path' attribute");
+ } else {
+ buffer.append("?path=");
+ buffer.append(URLEncoder.encode(this.path, getCharset()));
+ if (this.version != null) {
+ buffer.append("&version=");
+ buffer.append(URLEncoder.encode(this.version, getCharset()));
+ }
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw new BuildException
+ ("Invalid 'charset' attribute: " + getCharset());
+ }
+ return buffer;
+ }
+
+}
\ No newline at end of file
Propchange: tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java Fri Jun 3 22:22:35 2011
@@ -19,8 +19,6 @@
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import org.apache.tools.ant.BuildException;
@@ -33,28 +31,7 @@ import org.apache.tools.ant.BuildExcepti
* @version $Id$
* @since 4.1
*/
-public class ReloadTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
+public class ReloadTask extends AbstractCatalinaCommandTask {
/**
* Execute the requested operation.
@@ -65,17 +42,7 @@ public class ReloadTask extends Abstract
public void execute() throws BuildException {
super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- try {
- execute("/reload?path=" + URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
-
+ execute(createQueryString("/reload").toString());
}
Modified: tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java Fri Jun 3 22:22:35 2011
@@ -19,9 +19,6 @@
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
import org.apache.tools.ant.BuildException;
@@ -32,25 +29,29 @@ import org.apache.tools.ant.BuildExcepti
* @author Vivek Chopra
* @version $Revision$
*/
-public class SessionsTask extends AbstractCatalinaTask {
-
- // Properties
+public class SessionsTask extends AbstractCatalinaCommandTask {
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
- public String getPath() {
- return (this.path);
+ protected String idle = null;
+
+ public String getIdle() {
+ return this.idle;
}
-
- public void setPath(String path) {
- this.path = path;
+
+ public void setIdle(String idle) {
+ this.idle = idle;
}
-
- // Public Methods
-
+
+ @Override
+ public StringBuilder createQueryString(String command) {
+ StringBuilder buffer = super.createQueryString(command);
+ if (path != null && idle != null) {
+ buffer.append("&idle=");
+ buffer.append(this.idle);
+ }
+ return buffer;
+ }
+
/**
* Execute the requested operation.
*
@@ -60,17 +61,7 @@ public class SessionsTask extends Abstra
public void execute() throws BuildException {
super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
-
- try {
- execute("/sessions?path=" + URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
+ execute(createQueryString("/sessions").toString());
}
Modified: tomcat/trunk/java/org/apache/catalina/ant/StartTask.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/StartTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ant/StartTask.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ant/StartTask.java Fri Jun 3 22:22:35 2011
@@ -19,9 +19,6 @@
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
import org.apache.tools.ant.BuildException;
@@ -33,28 +30,7 @@ import org.apache.tools.ant.BuildExcepti
* @version $Id$
* @since 4.1
*/
-public class StartTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
+public class StartTask extends AbstractCatalinaCommandTask {
/**
* Execute the requested operation.
@@ -65,16 +41,7 @@ public class StartTask extends AbstractC
public void execute() throws BuildException {
super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- try {
- execute("/start?path=" + URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
+ execute(createQueryString("/start").toString());
}
Modified: tomcat/trunk/java/org/apache/catalina/ant/StopTask.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/StopTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ant/StopTask.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ant/StopTask.java Fri Jun 3 22:22:35 2011
@@ -19,9 +19,6 @@
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
import org.apache.tools.ant.BuildException;
@@ -33,28 +30,7 @@ import org.apache.tools.ant.BuildExcepti
* @version $Id$
* @since 4.1
*/
-public class StopTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
+public class StopTask extends AbstractCatalinaCommandTask {
/**
* Execute the requested operation.
@@ -65,18 +41,9 @@ public class StopTask extends AbstractCa
public void execute() throws BuildException {
super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- try {
- execute("/stop?path=" + URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
+ execute(createQueryString("/stop").toString());
}
-
+
}
Modified: tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java Fri Jun 3 22:22:35 2011
@@ -19,9 +19,6 @@
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
import org.apache.tools.ant.BuildException;
@@ -33,27 +30,7 @@ import org.apache.tools.ant.BuildExcepti
* @version $Id$
* @since 4.1
*/
-public class UndeployTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
+public class UndeployTask extends AbstractCatalinaCommandTask {
/**
* Execute the requested operation.
@@ -64,18 +41,8 @@ public class UndeployTask extends Abstra
public void execute() throws BuildException {
super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
-
- try {
- execute("/undeploy?path=" +
- URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
+ execute(createQueryString("/undeploy").toString());
+
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1131267&r1=1131266&r2=1131267&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Jun 3 22:22:35 2011
@@ -147,6 +147,10 @@
Patch provided by Eiji Takahashi. (markt)
</fix>
<fix>
+ <bug>51251</bug>: Add web application version support to the Ant tasks.
+ Based on a patch provided by Eiji Takahashi. (markt)
+ </fix>
+ <fix>
<bug>51294</bug>: Clarify behaviour of unpackWAR attribute of
StandardContext components. (markt)
</fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org