KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > j2ee > ServerDeploy


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.tools.ant.taskdefs.optional.j2ee;
20
21 import java.io.File JavaDoc;
22 import java.util.Enumeration JavaDoc;
23 import java.util.Vector JavaDoc;
24 import org.apache.tools.ant.BuildException;
25 import org.apache.tools.ant.Task;
26
27 /**
28  * Controls hot deployment tools for J2EE servers.
29  *
30  * This class is used as a framework for the creation of vendor specific
31  * hot deployment tools.
32  *
33  * @see org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
34  * @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool
35  * @see org.apache.tools.ant.taskdefs.optional.j2ee.GenericHotDeploymentTool
36  * @see org.apache.tools.ant.taskdefs.optional.j2ee.WebLogicHotDeploymentTool
37  */

38 public class ServerDeploy extends Task {
39     /** The action to be performed. IE: "deploy", "delete", etc... **/
40     private String JavaDoc action;
41
42     /** The source (fully-qualified path) to the component being deployed **/
43     private File JavaDoc source;
44
45     /** The vendor specific tool for deploying the component **/
46     private Vector JavaDoc vendorTools = new Vector JavaDoc();
47
48     ///////////////////////////////////////////////////////////////////////////
49
//
50
// Place vendor specific tool creations here.
51
//
52
///////////////////////////////////////////////////////////////////////////
53

54     /**
55      * Creates a generic deployment tool.
56      * <p>Ant calls this method on creation to handle embedded "generic" elements
57      * in the ServerDeploy task.
58      * @param tool An instance of GenericHotDeployment tool, passed in by Ant.
59      */

60     public void addGeneric(GenericHotDeploymentTool tool) {
61         tool.setTask(this);
62         vendorTools.addElement(tool);
63     }
64
65     /**
66      * Creates a WebLogic deployment tool, for deployment to WebLogic servers.
67      * <p>Ant calls this method on creation to handle embedded "weblogic" elements
68      * in the ServerDeploy task.
69      * @param tool An instance of WebLogicHotDeployment tool, passed in by Ant.
70      */

71     public void addWeblogic(WebLogicHotDeploymentTool tool) {
72         tool.setTask(this);
73         vendorTools.addElement(tool);
74     }
75
76     /**
77      * Creates a JOnAS deployment tool, for deployment to JOnAS servers.
78      * <p>Ant calls this method on creation to handle embedded "jonas" elements
79      * in the ServerDeploy task.
80      * @param tool An instance of JonasHotDeployment tool, passed in by Ant.
81      */

82     public void addJonas(JonasHotDeploymentTool tool) {
83         tool.setTask(this);
84         vendorTools.addElement(tool);
85     }
86
87
88     ///////////////////////////////////////////////////////////////////////////
89
//
90
// Execute method
91
//
92
///////////////////////////////////////////////////////////////////////////
93

94     /**
95      * Execute the task.
96      * <p>This method calls the deploy() method on each of the vendor-specific tools
97      * in the <code>vendorTools</code> collection. This performs the actual
98      * process of deployment on each tool.
99      * @exception org.apache.tools.ant.BuildException if the attributes
100      * are invalid or incomplete, or a failure occurs in the deployment process.
101      */

102     public void execute() throws BuildException {
103         for (Enumeration JavaDoc e = vendorTools.elements();
104              e.hasMoreElements();) {
105             HotDeploymentTool tool = (HotDeploymentTool) e.nextElement();
106             tool.validateAttributes();
107             tool.deploy();
108         }
109     }
110
111     ///////////////////////////////////////////////////////////////////////////
112
//
113
// Set/get methods
114
//
115
///////////////////////////////////////////////////////////////////////////
116

117     /**
118      * Returns the action field.
119      * @return A string representing the "action" attribute.
120      */

121     public String JavaDoc getAction() {
122         return action;
123     }
124
125     /**
126      * The action to be performed, usually "deploy"; required.
127      * Some tools support additional actions, such as "delete", "list", "undeploy", "update"...
128      * @param action A String representing the "action" attribute.
129      */

130     public void setAction(String JavaDoc action) {
131         this.action = action;
132     }
133
134     /**
135      * Returns the source field (the path/filename of the component to be
136      * deployed.
137      * @return A File object representing the "source" attribute.
138      */

139     public File JavaDoc getSource() {
140         return source;
141     }
142
143     /**
144      * The filename of the component to be deployed; optional
145      * depending upon the tool and the action.
146      * @param source String representing the "source" attribute.
147      */

148     public void setSource(File JavaDoc source) {
149         this.source = source;
150     }
151 }
152
153
Popular Tags