KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > ant > InstallTask


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina.ant;
20
21
22 import java.net.URLEncoder JavaDoc;
23
24 import org.apache.tools.ant.BuildException;
25
26
27 /**
28  * Ant task that implements the <code>/install</code> command, supported by the
29  * Tomcat manager application.
30  *
31  * @author Craig R. McClanahan
32  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
33  * @since 4.1
34  * @deprecated Replaced by DeployTask
35  */

36 public class InstallTask extends AbstractCatalinaTask {
37
38
39     // ------------------------------------------------------------- Properties
40

41
42     /**
43      * URL of the context configuration file for this application, if any.
44      */

45     protected String JavaDoc config = null;
46
47     public String JavaDoc getConfig() {
48         return (this.config);
49     }
50
51     public void setConfig(String JavaDoc config) {
52         this.config = config;
53     }
54
55
56     /**
57      * The context path of the web application we are managing.
58      */

59     protected String JavaDoc path = null;
60
61     public String JavaDoc getPath() {
62         return (this.path);
63     }
64
65     public void setPath(String JavaDoc path) {
66         this.path = path;
67     }
68
69
70     /**
71      * URL of the web application archive (WAR) file, or the unpacked directory
72      * containing this application, if any.
73      */

74     protected String JavaDoc war = null;
75
76     public String JavaDoc getWar() {
77         return (this.war);
78     }
79
80     public void setWar(String JavaDoc war) {
81         this.war = war;
82     }
83
84
85     // --------------------------------------------------------- Public Methods
86

87
88     /**
89      * Execute the requested operation.
90      *
91      * @exception BuildException if an error occurs
92      */

93     public void execute() throws BuildException {
94
95         super.execute();
96         if (path == null) {
97             throw new BuildException
98                 ("Must specify 'path' attribute");
99         }
100         if ((config == null) && (war == null)) {
101             throw new BuildException
102                 ("Must specify at least one of 'config' and 'war'");
103         }
104         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("/install?path=");
105         sb.append(URLEncoder.encode(this.path));
106         if (config != null) {
107             sb.append("&config=");
108             sb.append(URLEncoder.encode(config));
109         }
110         if (war != null) {
111             sb.append("&war=");
112             sb.append(URLEncoder.encode(war));
113         }
114         execute(sb.toString());
115
116     }
117
118
119 }
120
Popular Tags