01: /*
02: * Copyright 2002,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.catalina.ant;
18:
19: import java.net.URLEncoder;
20:
21: import org.apache.tools.ant.BuildException;
22:
23: /**
24: * Ant task that implements the <code>/sessions</code> command
25: * supported by the Tomcat manager application.
26: *
27: * @author Vivek Chopra
28: * @version $Revision: 1.3 $
29: */
30: public class SessionsTask extends AbstractCatalinaTask {
31:
32: // Properties
33:
34: /**
35: * The context path of the web application we are managing.
36: */
37: protected String path = null;
38:
39: public String getPath() {
40: return (this .path);
41: }
42:
43: public void setPath(String path) {
44: this .path = path;
45: }
46:
47: // Public Methods
48:
49: /**
50: * Execute the requested operation.
51: *
52: * @exception BuildException if an error occurs
53: */
54: public void execute() throws BuildException {
55:
56: super .execute();
57: if (path == null) {
58: throw new BuildException("Must specify 'path' attribute");
59: }
60: execute("/sessions?path=" + URLEncoder.encode(this.path));
61: }
62:
63: }
|