--- /dev/null
+/*
+ * 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
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
import org.apache.tools.ant.BuildException;
* @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.
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());
}
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
import org.apache.tools.ant.BuildException;
* @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.
*
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());
}
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
import org.apache.tools.ant.BuildException;
* @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.
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());
}
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
import org.apache.tools.ant.BuildException;
* @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.
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());
}
-
+
}
package org.apache.catalina.ant;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
import org.apache.tools.ant.BuildException;
* @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.
public void execute() throws BuildException {
super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
+ execute(createQueryString("/undeploy").toString());
- try {
- execute("/undeploy?path=" +
- URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
}
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>