KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > iplanet > UndeployTask


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package org.apache.tools.ant.taskdefs.optional.iplanet;
25
26 import org.apache.tools.ant.BuildException;
27
28 public class UndeployTask extends ComponentAdmin {
29     private static final String JavaDoc UNDEPLOY_COMMAND = "undeploy";
30
31     protected void checkComponentConfig(Component comp) throws BuildException {
32         super.checkComponentConfig(comp);
33
34         // name must be valid string
35
String JavaDoc theName = comp.getName();
36         if ((theName == null) || (theName.length() == 0)) {
37             String JavaDoc msg = "The component name (\"" + theName + "\") is not valid";
38             throw new BuildException(msg, getLocation());
39         }
40     }
41
42     protected String JavaDoc getCommandString(Server server, Component comp) {
43         StringBuffer JavaDoc cmdString = new StringBuffer JavaDoc(UNDEPLOY_COMMAND);
44         cmdString.append(server.getCommandParameters(true));
45         if (comp.getType() != null) {
46             cmdString.append(" --type ").append(comp.getType());
47         }
48         cmdString.append(" ").append(comp.getName());
49
50         return cmdString.toString();
51     }
52 }
Popular Tags