ehatcher 02/03/27 06:32:19
Modified: . WHATSNEW
docs/manual/OptionalTasks ejb.html
src/main/org/apache/tools/ant/taskdefs defaults.properties
docs/manual optionaltasklist.html
Added: docs/manual/OptionalTasks serverdeploy.html
src/main/org/apache/tools/ant/taskdefs/optional/j2ee
AbstractHotDeploymentTool.java
GenericHotDeploymentTool.java
HotDeploymentTool.java ServerDeploy.java
WebLogicHotDeploymentTool.java
Removed: docs/manual/OptionalTasks ejbdeploy.html
src/main/org/apache/tools/ant/taskdefs/optional/ejb
AbstractEjbHotDeploymentTool.java EjbDeploy.java
EjbHotDeploymentTool.java
WebLogicHotDeploymentTool.java
Log:
Refactoring of server deployment task. Renamed from <ejbdeploy> to
<serverdeploy>. Moved to new j2ee package so its not EJB-centric. Submitted by
Christopher A. Longo - [EMAIL PROTECTED]
Revision Changes Path
1.235 +1 -1 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.234
retrieving revision 1.235
diff -u -r1.234 -r1.235
--- WHATSNEW 26 Mar 2002 22:52:42 -0000 1.234
+++ WHATSNEW 27 Mar 2002 14:32:18 -0000 1.235
@@ -242,7 +242,7 @@
"site chmod", as well as set the umask before transferring files, if
the server supports "site umask".
-* New <ejbdeploy> "optional" task.
+* New <serverdeploy> "optional" task.
* <patternset> now supports nested patternsets.
1.20 +1 -2 jakarta-ant/docs/manual/OptionalTasks/ejb.html
Index: ejb.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/OptionalTasks/ejb.html,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ejb.html 24 Mar 2002 14:51:03 -0000 1.19
+++ ejb.html 27 Mar 2002 14:32:18 -0000 1.20
@@ -22,7 +22,7 @@
</ul>
<p>Version @VERSION@<br>
-$Id: ejb.html,v 1.19 2002/03/24 14:51:03 ehatcher Exp $
+$Id: ejb.html,v 1.20 2002/03/27 14:32:18 ehatcher Exp $
</p>
<hr>
<h2>Table of Contents</h2>
@@ -62,7 +62,6 @@
<tr><td><a href="BorlandGenerateClient.html">blgenclient</a></td><td
colspan="2">Borland Application Server 4.5</td></tr>
<tr><td><a href="#ddcreator">ddcreator</a></td><td colspan="2">Weblogic
4.5.1</td></tr>
<tr><td><a href="#ejbc">ejbc</a></td><td colspan="2">Weblogic
4.5.1</td></tr>
- <tr><td><a href="ejbdeploy.html">ejbdeploy</a></td><td colspan="2">EJB hot
server deployment</td>
<tr><td><a href="#iplanet-ejbc">iplanet-ejbc</a></td><td
colspan="2">iPlanet Application Server 6.0</td></tr>
<tr><td rowspan="7"><a href="#ejbjar">ejbjar</a></td><td colspan="2"
align="center"><b>Nested Elements</b></td></tr>
<tr><td><a href="BorlandEJBTasks.html">borland</a></td><td>Borland
Application Server 4.5</td></tr>
1.1 jakarta-ant/docs/manual/OptionalTasks/serverdeploy.html
Index: serverdeploy.html
===================================================================
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>ServerDeploy Task</title>
</head>
<body>
<h2><a name="serverdeploy">serverdeploy</a></h2>
<h3><b>Description:</b></h3>
<p>The <code>serverdeploy</code> task is used to run a "hot" deployment tool
for
vendor-specific J2EE server. The task requires nested elements which define
the attributes of the vendor-specific deployment tool being executed.
Vendor-specific deployment tools elements may enforce rules for which
attributes are required, depending on the tool.
</p>
<h3>Parameters:</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">action</td>
<td valign="top">This is the action to be performed. For most cases this
will be "deploy". Some tools support additional actions, such as
"delete", "list",
"undeploy", "update"...</td>
<td>Yes</td>
</tr>
<tr>
<td valign="top">source</td>
<td valign="top">A fully qualified path/filename of the component to be
deployed.
This may be an .ear, .jar, .war, or any other type that is supported by
the server.
</td>
<td>Tool dependant</td>
</tr>
</table>
<h3>Nested Elements</h3>
<p>The serverdeploy task supports a nested <code>classpath</code> element to
set the classpath.</p>
<h3>Vendor-specific nested elements</h3>
<h3>Parameters used for all tools:</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">classpath</td>
<td valign="top">The classpath to be passed to the JVM running the tool.
The classpath may also be supplied as a nested element.</td>
<td>Tool dependant</td>
</tr>
<tr>
<td valign="top">server</td>
<td valign="top">The address or URL for the server where the component
will be deployed.</td>
<td>Tool dependant</td>
</tr>
<tr>
<td valign="top">username</td>
<td valign="top">The user with privileges to deploy applications to the
server.</td>
<td>Tool dependant</td>
</tr>
<tr>
<td valign="top">password</td>
<td valign="top">The password of the user with privileges to deploy
applications to the server.</td>
<td>Tool dependant</td>
</tr>
</table>
<p>Also supported are nested vendor-specific elements.</p>
<h3>Generic element</h3>
This element is provided for generic Java-based deployment tools.
The generic task accepts (but does not require) nested <code>arg</code>
and <code>jvmarg</code> elements.
A JVM will be spawned with the provided attributes. It is recommended
that a vendor-specific element be used over the generic one if at all
possible.
<p>The following attributes are supported by the generic element.</p>
<p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">classname</td>
<td valign="top">This is the fully qualified classname of the Java based
deployment tool to execute.</td>
<td>Yes</td>
</tr>
</table>
</p>
<h3>Nested Elements</h3>
<p>The generic element supports nested <arg> and <jvmarg>
elements.</p>
<h3>Example</h3>
<p>This example shows the use of generic deploy element to deploy a component
using a Java based deploy tool:</p>
<pre>
<serverdeploy action="deploy"
source="${lib.dir}/ejb_myApp.ear">
<generic classname="com.yamato.j2ee.tools.deploy.DeployTool"
classpath="${classpath}"
username="${user.name}"
password="${user.password}">
<arg value="-component=WildStar"/>
<arg value="-force"/>
<jvmarg value="-ms64m"/>
<jvmarg value="-mx128m"/>
</generic>
</serverdeploy>
</pre>
<h3>WebLogic element</h3>
<p>
The WebLogic element contains additional attributes to run the
<code>weblogic.deploy</code> deployment tool.
<p>Valid actions for the tool are <code>deploy</code>, <code>undeploy</code>,
<code>list</code>, <code>update</code>, and <code>delete</code>.
<p>If the action is <code>deploy</code> or <code>update</code>,
the <code>application</code> and <code>source</code> attributes must be set.
If the action is <code>undeploy</code> or <code>delete</code>,
the <code>application</code> attribute must be set. If the
<code>username</code>
attribute is omitted, it defaults to "system". The <code>password</code>
attribute is
required for all actions.
<p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">application</td>
<td valign="top">This is the name of the application being deployed</td>
<td>Yes</td>
</tr>
<tr>
<td valign="top">component</td>
<td valign="top">This is the component string for deployment targets.
It is in the form
<code><component>:<target1>,<target2>...</code>
Where component is the archive name (minus the .jar, .ear, .war
extension). Targets are the servers where the components will be
deployed</td>
<td>Yes</td>
</tr>
<tr>
<td valign="top">debug</td>
<td valign="top">If set to true, additional information will be
printed during the deployment process.</td>
<td>No</td>
</tr>
</table>
<h3>Examples</h3>
<p>This example shows the use of serverdeploy to deploy a component to a
WebLogic server:</p>
<pre>
<serverdeploy action="deploy"
source="${lib.dir}/ejb_myApp.ear">
<weblogic application="myapp"
server="t3://myserver:7001"
classpath="${weblogic.home}/lib/weblogic.jar"
username="${user.name}"
password="${user.password}"
component="ejb_foobar:myserver,productionserver"
debug="true"/>
</serverdeploy>
</pre>
<p>This example shows serverdeploy being used to delete a component from a
WebLogic server:</p>
<pre>
<serverdeploy action="delete">/
<weblogic application="myapp"
server="t3://myserver:7001"
classpath="${weblogic.home}/lib/weblogic.jar"
username="${user.name}"
password="${user.password}"/>
</serverdeploy>
</pre>
<hr>
<p align="center">Copyright © 2002 Apache Software Foundation. All
rights Reserved.</p>
</body>
</html>
1.116 +1 -1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties
Index: defaults.properties
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/defaults.properties,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- defaults.properties 24 Mar 2002 14:51:03 -0000 1.115
+++ defaults.properties 27 Mar 2002 14:32:18 -0000 1.116
@@ -151,7 +151,7 @@
soslabel=org.apache.tools.ant.taskdefs.optional.sos.SOSLabel
echoproperties=org.apache.tools.ant.taskdefs.optional.EchoProperties
splash=org.apache.tools.ant.taskdefs.optional.splash.SplashTask
-ejbdeploy=org.apache.tools.ant.taskdefs.optional.ejb.EjbDeploy
+serverdeploy=org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy
# deprecated ant tasks (kept for back compatibility)
starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut
1.27 +1 -0 jakarta-ant/docs/manual/optionaltasklist.html
Index: optionaltasklist.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/optionaltasklist.html,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- optionaltasklist.html 22 Feb 2002 08:29:37 -0000 1.26
+++ optionaltasklist.html 27 Mar 2002 14:32:19 -0000 1.27
@@ -44,6 +44,7 @@
<a href="OptionalTasks/renameextensions.html"><i>RenameExtensions</i></a><br>
<a href="OptionalTasks/replaceregexp.html">ReplaceRegExp</a><br>
<a href="OptionalTasks/rpm.html">Rpm</a><br>
+<a href="OptionalTasks/serverdeploy.html">ServerDeploy</a><br>
<a href="OptionalTasks/script.html">Script</a><br>
<a href="OptionalTasks/sound.html">Sound</a><br>
<a href="OptionalTasks/sos.html">SourceOffSite</a><br>
1.1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/AbstractHotDeploymentTool.java
Index: AbstractHotDeploymentTool.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.taskdefs.optional.j2ee;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy;
/**
* Abstract class to support vendor-specific hot deployment tools.
* This class will validate boilerplate attributes.
*
* Subclassing this class for a vendor specific tool involves the
* following.
* <ol><li>Implement the <code>isActionValid()<code> method to insure the
* action supplied as the "action" attribute of ServerDeploy is valid.
* <li>Implement the <code>validateAttributes()</code> method to insure
* all required attributes are supplied, and are in the correct format.
* <li>Add a <code>add<TOOL></code> method to the ServerDeploy
* class. This method will be called when Ant encounters a
* <code>add<TOOL></code> task nested in the
* <code>serverdeploy</code> task.
* <li>Define the <code>deploy</code> method. This method should perform
* whatever task it takes to hot-deploy the component. IE: spawn a JVM and
* run class, exec a native executable, run Java code...
*
* @author Christopher A. Longo - [EMAIL PROTECTED]
*
* @see org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy
*/
public abstract class AbstractHotDeploymentTool implements HotDeploymentTool
{
/** The parent task **/
private ServerDeploy task;
/** The classpath passed to the JVM on execution. **/
private Path classpath;
/** The username for the deployment server. **/
private String userName;
/** The password for the deployment server. **/
private String password;
/** The address of the deployment server **/
private String server;
/**
* Add a classpath. Used to handle the nested classpath
* element.
* @return A Path object representing the classpath to be used.
*/
public Path createClasspath() {
if(classpath == null)
classpath = new Path(task.getProject());
return classpath.createPath();
}
/**
* Determines if the "action" attribute defines a valid action.
* <p>Subclasses should determine if the action passed in is
* supported by the vendor's deployment tool.
* <p>Actions may by "deploy", "delete", etc... It all depends
* on the tool.
* @return true if the "action" attribute is valid, false if not.
*/
protected abstract boolean isActionValid();
/**
* Validates the passed in attributes.
* Subclasses should chain to this super-method to insure
* validation of boilerplate attributes.
* <p>Only the "action" attribute is required in the
* base class. Subclasses should check attributes accordingly.
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete.
*/
public void validateAttributes() throws BuildException {
if (task.getAction() == null)
throw new BuildException("The \"action\" attribute must be set");
if (!isActionValid())
throw new BuildException("Invalid action \"" + task.getAction() +
"\" passed");
if (classpath == null)
throw new BuildException("The classpath attribute must be set");
}
/**
* Perform the actual deployment.<br>
* It's up to the subclasses to implement the actual behavior.
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete.
*/
public abstract void deploy() throws BuildException;
/**
* Sets the parent task.
* @param task a ServerDeploy object representing the parent task.
*/
public void setTask(ServerDeploy task) {
this.task = task;
}
/**
* Returns the task field, a ServerDeploy object.
* @return An ServerDeploy representing the parent task.
*/
protected ServerDeploy getTask() {
return task;
}
/**
* gets the classpath field.
* @return A Path representing the "classpath" attribute.
*/
public Path getClasspath() {
return classpath;
}
/**
* Sets the classpath field.
* This is a required attribute.
* @param classpath A Path object representing the "classpath" attribute.
*/
public void setClasspath(Path classpath) {
this.classpath = classpath;
}
/**
* Returns the userName field.
* @return A String representing the "userName" attribute.
*/
public String getUserName() {
return userName;
}
/**
* Sets the userName field.
* This is a <b>not</b> required attribute.
* @param userName A String representing the "userName" attribute.
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* Returns the password field.
* @return A String representing the "password" attribute.
*/
public String getPassword() {
return password;
}
/**
* Set the password field.
* This is a <b>not</b> required attribute.
* @param password A String representing the "password" attribute.
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Returns the server field.
* @return A String representing the "server" attribute.
*/
public String getServer() {
return server;
}
/**
* Sets the server field.
* This is <b>not</b> a required attribute.
* @param server A String representing the "server" attribute.
*/
public void setServer(String server) {
this.server = server;
}
}
1.1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/GenericHotDeploymentTool.java
Index: GenericHotDeploymentTool.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.taskdefs.optional.j2ee;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy;
import org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool;
/**
* A generic tool for J2EE server hot deployment.
* <p>The simple implementation spawns a JVM with the supplied
* class name, jvm args, and arguments.
*
* @author Christopher A. Longo - [EMAIL PROTECTED]
*
* @see org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy
*/
public class GenericHotDeploymentTool extends AbstractHotDeploymentTool
{
/** A Java task used to run the deployment tool **/
private Java java;
/** The fully qualified class name of the deployment tool **/
private String className;
/** List of valid actions **/
private static final String[] VALID_ACTIONS = { ACTION_DEPLOY };
/**
* Creates a nested arg element.
* @return A Commandline.Argument object representing the
* command line argument being passed when the deployment
* tool is run. IE: "-user=mark", "-password=venture"...
*/
public Commandline.Argument createArg() {
return java.createArg();
}
/**
* Creates a nested jvmarg element.
* Creates a nested arg element.
* @return A Commandline.Argument object representing the
* JVM command line argument being passed when the deployment
* tool is run. IE: "-ms64m", "-mx128m"...
*/
public Commandline.Argument createJvmarg() {
return java.createJvmarg();
}
/**
* Determines if the "action" attribute defines a valid action.
* <p>Subclasses should determine if the action passed in is
* supported by the vendor's deployment tool.
* For this generic implementation, the only valid action is "deploy"
* @return true if the "action" attribute is valid, false if not.
*/
protected boolean isActionValid() {
return(getTask().getAction().equals(VALID_ACTIONS[0]));
}
/**
* Sets the parent task.
* @param task An ServerDeploy object representing the parent task.
*/
public void setTask(ServerDeploy task) {
super.setTask(task);
java = (Java)task.getProject().createTask("java");
}
/**
* Perform the actual deployment.<br>
* For this generic implementation, a JVM is spawned using the
* supplied classpath, classname, JVM args, and command line arguments.
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete.
*/
public void deploy() throws BuildException {
java.setClassname(className);
java.setClasspath(getClasspath());
java.setFork(true);
java.setFailonerror(true);
java.execute();
}
/**
* Validates the passed in attributes.
* Ensures the className and arguments attribute have been set.
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete.
*/
public void validateAttributes() throws BuildException {
super.validateAttributes();
if(className == null)
throw new BuildException("The classname attribute must be set");
}
/**
* Sets the className field.
* <p>The className is the name of the class to execute to perfom
* deployment. IE: "com.foobar.tools.deploy.DeployTool"
* This is a required attribute.
* @param className The fully qualified class name of the class
* to perform deployment.
*/
public void setClassName(String className) {
this.className = className;
}
}
1.1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/HotDeploymentTool.java
Index: HotDeploymentTool.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.taskdefs.optional.j2ee;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy;
/**
* An interface for vendor-specific "hot" deployment tools.
*
* @author Christopher A. Longo - [EMAIL PROTECTED]
*
* @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy
*/
public interface HotDeploymentTool
{
/** The delete action String **/
public static final String ACTION_DELETE = "delete";
/** The deploy action String **/
public static final String ACTION_DEPLOY = "deploy";
/** The list action String **/
public static final String ACTION_LIST = "list";
/** The undeploy action String **/
public static final String ACTION_UNDEPLOY = "undeploy";
/** The update action String **/
public static final String ACTION_UPDATE = "update";
/**
* Validates the passed in attributes.
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete.
*/
public void validateAttributes() throws BuildException;
/**
* Perform the actual deployment.<br>
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete.
*/
public void deploy() throws BuildException;
/**
* Sets the parent task.
* @param task A ServerDeploy object representing the parent task.
*/
public void setTask(ServerDeploy task);
}
1.1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/ServerDeploy.java
Index: ServerDeploy.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.taskdefs.optional.j2ee;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
* A task to support hot deployment tools for J2EE servers.
*
* This class is used as a framework for the creation of vendor specific
* hot deployment tools.
*
* @author Christopher A. Longo - [EMAIL PROTECTED]
*
* @see org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.GenericHotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.WebLogicHotDeploymentTool
*/
public class ServerDeploy extends Task
{
/** The action to be performed. IE: "deploy", "delete", etc... **/
private String action;
/** The source (fully-qualified path) to the component being deployed **/
private File source;
/** The vendor specific tool for deploying the component **/
private ArrayList vendorTools = new ArrayList();
///////////////////////////////////////////////////////////////////////////
//
// Place vendor specific tool creations here.
//
///////////////////////////////////////////////////////////////////////////
/**
* Creates a generic deployment tool.
* <p>Ant calls this method on creation to handle embedded "generic"
elements
* in the ServerDeploy task.
* @param tool An instance of GenericHotDeployment tool, passed in by
Ant.
*/
public void addGeneric(GenericHotDeploymentTool tool) {
tool.setTask(this);
vendorTools.add(tool);
}
/**
* Creates a WebLogic deployment tool, for deployment to WebLogic
servers.
* <p>Ant calls this method on creation to handle embedded "weblogic"
elements
* in the ServerDeploy task.
* @param tool An instance of WebLogicHotDeployment tool, passed in by
Ant.
*/
public void addWeblogic(WebLogicHotDeploymentTool tool) {
tool.setTask(this);
vendorTools.add(tool);
}
///////////////////////////////////////////////////////////////////////////
//
// Execute method
//
///////////////////////////////////////////////////////////////////////////
/**
* Execute the task.
* <p>This method calls the deploy() method on each of the
vendor-specific tools
* in the <code>vendorTools</code> collection. This performs the actual
* process of deployment on each tool.
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete, or
* a failure occurs in the deployment process.
*/
public void execute() throws BuildException {
for (Iterator iterator = vendorTools.iterator(); iterator.hasNext();)
{
HotDeploymentTool tool = (HotDeploymentTool) iterator.next();
tool.validateAttributes();
tool.deploy();
}
}
///////////////////////////////////////////////////////////////////////////
//
// Set/get methods
//
///////////////////////////////////////////////////////////////////////////
/**
* Returns the action field.
* @return A string representing the "action" attribute.
*/
public String getAction() {
return action;
}
/**
* Sets the action field.
* This is a required attribute.
* @param action A String representing the "action" attribute.
*/
public void setAction(String action) {
this.action = action;
}
/**
* Returns the source field (the path/filename of the component to be
* deployed.
* @return A File object representing the "source" attribute.
*/
public File getSource() {
return source;
}
/**
* Sets the source field (the path/filename of the component to be
* deployed.
* This is <b>not</b> a required attribute.
* @param source String representing the "source" attribute.
*/
public void setSource(File source) {
this.source = source;
}
}
1.1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/WebLogicHotDeploymentTool.java
Index: WebLogicHotDeploymentTool.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.taskdefs.optional.j2ee;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy;
import org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool;
import org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool;
/**
* An Ant wrapper task for the weblogic.deploy tool. This is used to
* hot-deploy J2EE applications to a running WebLogic server.
* This is <b>not</b> the same as creating the application archive.
* This task assumes the archive (EAR, JAR, or WAR) file has been
* assembled and is supplied as the "source" attribute.
* <p>In the end, this task assembles the commadline parameters
* and runs the weblogic.deploy tool in a seperate JVM.
*
* @author Christopher A. Longo - [EMAIL PROTECTED]
*
* @see org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool
* @see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy
*/
public class WebLogicHotDeploymentTool extends AbstractHotDeploymentTool
implements HotDeploymentTool
{
/** The classname of the tool to run **/
private static final String WEBLOGIC_DEPLOY_CLASS_NAME =
"weblogic.deploy";
/** All the valid actions that weblogic.deploy permits **/
private static final String[] VALID_ACTIONS =
{ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST, ACTION_UNDEPLOY,
ACTION_UPDATE};
/** Represents the "-debug" flag from weblogic.deploy **/
private boolean debug;
/** The application name that is being deployed **/
private String application;
/** The component name:target(s) for the "-component" argument of
weblogic.deploy **/
private String component;
/**
* Perform the actual deployment.<br>
* For this implementation, a JVM is spawned and the weblogic.deploy
* tools is executed.
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete.
*/
public void deploy()
{
Java java = (Java)getTask().getProject().createTask("java");
java.setFork(true);
java.setFailonerror(true);
java.setClasspath(getClasspath());
java.setClassname(WEBLOGIC_DEPLOY_CLASS_NAME);
java.createArg().setLine(getArguments());
java.execute();
}
/**
* Validates the passed in attributes.
* <p>The rules are:
* <ol><li>If action is "deploy" or "update" the "application" and
"source"
* attributes must be supplied.
* <li>If action is "delete" or "undeploy" the "application" attribute
must
* be supplied.
* @exception org.apache.tools.ant.BuildException if the attributes are
invalid or incomplete
*/
public void validateAttributes() throws BuildException {
super.validateAttributes();
String action = getTask().getAction();
// check that the password has been set
if((getPassword() == null))
throw new BuildException("The password attribute must be set.");
// check for missing application on deploy & update
if((action.equals(ACTION_DEPLOY) || action.equals(ACTION_UPDATE)) &&
application == null)
throw new BuildException("The application attribute must be set
if action = " + action);
// check for missing source on deploy & update
if((action.equals(ACTION_DEPLOY) || action.equals(ACTION_UPDATE)) &&
getTask().getSource() == null)
throw new BuildException("The source attribute must be set if
action = " + action);
// check for missing application on delete & undeploy
if((action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY))
&& application == null)
throw new BuildException("The application attribute must be set
if action = " + action);
}
/**
* Builds the arguments to pass to weblogic.deploy according to the
* supplied action.
* @return A String containing the arguments for the weblogic.deploy
tool.
*/
public String getArguments() throws BuildException {
String action = getTask().getAction();
String args = null;
if(action.equals(ACTION_DEPLOY) || action.equals(ACTION_UPDATE))
args = buildDeployArgs();
else if(action.equals(ACTION_DELETE) ||
action.equals(ACTION_UNDEPLOY))
args = buildUndeployArgs();
else if(action.equals(ACTION_LIST))
args = buildListArgs();
return args;
}
/**
* Determines if the action supplied is valid.
* <p>Valid actions are contained in the static array VALID_ACTIONS
* @return true if the action attribute is valid, false if not.
*/
protected boolean isActionValid() {
boolean valid = false;
String action = getTask().getAction();
for(int i = 0; i < VALID_ACTIONS.length; i++) {
if(action.equals(VALID_ACTIONS[i])) {
valid = true;
break;
}
}
return valid;
}
/**
* Builds the prefix arguments to pass to weblogic.deploy.
* These arguments are generic across all actions.
* @return A StringBuffer containing the prefix arguments.
* The action-specific build methods will append to this StringBuffer.
*/
protected StringBuffer buildArgsPrefix() {
ServerDeploy task = getTask();
// constructs the "-url <url> -debug <action> <password>" portion
// of the commmand line
return new StringBuffer(1024)
.append((getServer() != null)
? "-url " + getServer()
: "")
.append(" ")
.append(debug ? "-debug " : "")
.append((getUserName() != null)
? "-username " + getUserName()
: "")
.append(" ")
.append(task.getAction()).append(" ")
.append(getPassword()).append(" ");
}
/**
* Builds the arguments to pass to weblogic.deploy for deployment actions
* ("deploy" and "update").
* @return A String containing the full argument string for
weblogic.deploy.
*/
protected String buildDeployArgs() {
String args = buildArgsPrefix()
.append(application).append(" ")
.append(getTask().getSource())
.toString();
if(component != null)
args = "-component " + component + " " + args;
return args;
}
/**
* Builds the arguments to pass to weblogic.deploy for undeployment
actions
* ("undeploy" and "delete").
* @return A String containing the full argument string for
weblogic.deploy.
*/
protected String buildUndeployArgs() {
return buildArgsPrefix()
.append(application).append(" ")
.toString();
}
/**
* Builds the arguments to pass to weblogic.deploy for the list action
* @return A String containing the full argument string for
weblogic.deploy.
*/
protected String buildListArgs() {
return buildArgsPrefix()
.toString();
}
/**
* Sets the debug field.
* <p>This is not a required attribute.
* @param debug A boolean representing weblogic.deploy "-debug" flag.
*/
public void setDebug(boolean debug) {
this.debug = debug;
}
/**
* Sets the application field.
* <p>This is a required attribute.
* @param application A String representing the application portion of
the
* weblogic.deploy command line.
*/
public void setApplication(String application) {
this.application = application;
}
/**
* Sets the component attribute.
* <p>This attribute is not a required attribute.
* @param component A String representing the value of the "-component"
* argument of the weblogic.deploy command line argument.<br>
* This string should be in the format of
*
<<i>componentName</i>>:<<i>target1</i>>,<<i>target2</i>>...
*/
public void setComponent(String component) {
this.component = component;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>