KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > ant > ServerDeploy


1 /**
2  * Copyright 2002-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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
18 package org.objectweb.jonas.ant;
19
20 import java.io.File JavaDoc;
21 import java.util.Enumeration JavaDoc;
22 import java.util.Vector JavaDoc;
23 import org.apache.tools.ant.BuildException;
24 import org.apache.tools.ant.Task;
25 import org.apache.tools.ant.taskdefs.optional.j2ee.GenericHotDeploymentTool;
26 import org.apache.tools.ant.taskdefs.optional.j2ee.WebLogicHotDeploymentTool;
27
28 /**
29  * Controls hot deployment tools for J2EE servers. This class is used as a
30  * framework for the creation of vendor specific hot deployment tools.
31  * @see org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
32  * @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool
33  * @see org.apache.tools.ant.taskdefs.optional.j2ee.GenericHotDeploymentTool
34  * @see org.apache.tools.ant.taskdefs.optional.j2ee.WebLogicHotDeploymentTool
35  */

36 public class ServerDeploy extends Task {
37
38     /**
39      * The action to be performed. IE: "deploy", "delete", etc...
40      */

41     private String JavaDoc action;
42
43     /**
44      * The source (fully-qualified path) to the component being deployed
45      */

46     private File JavaDoc source;
47
48     /**
49      * The vendor specific tool for deploying the component
50      */

51     private Vector JavaDoc vendorTools = new Vector JavaDoc();
52
53     ///////////////////////////////////////////////////////////////////////////
54
//
55
// Place vendor specific tool creations here.
56
//
57
///////////////////////////////////////////////////////////////////////////
58

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

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

73     public void addWeblogic(WebLogicHotDeploymentTool tool) {
74     }
75
76     /**
77      * Creates a JOnAS deployment tool, for deployment to JOnAS servers. <p>Ant
78      * calls this method on creation to handle embedded "jonas" elements in the
79      * 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
// Execute method
90
//
91
///////////////////////////////////////////////////////////////////////////
92

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

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

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

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

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

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

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