source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/ServerDeploy.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 5.3 KB
Line 
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
18package org.apache.tools.ant.taskdefs.optional.j2ee;
19
20import java.io.File;
21import java.util.Enumeration;
22import java.util.Vector;
23import org.apache.tools.ant.BuildException;
24import org.apache.tools.ant.Task;
25
26/**
27 * Controls hot deployment tools for J2EE servers.
28 *
29 * This class is used as a framework for the creation of vendor specific
30 * hot deployment tools.
31 *
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 */
38public class ServerDeploy extends Task {
39 /** The action to be performed. IE: "deploy", "delete", etc... **/
40 private String action;
41
42 /** The source (fully-qualified path) to the component being deployed **/
43 private File source;
44
45 /** The vendor specific tool for deploying the component **/
46 private Vector vendorTools = new Vector();
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 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 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 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 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 source) {
149 this.source = source;
150 }
151}
152
Note: See TracBrowser for help on using the repository browser.