git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272053 13f79535-47bb-0310-9956-ffa450edef68master
@@ -242,7 +242,7 @@ Other changes: | |||
"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. | |||
@@ -62,7 +62,6 @@ In general these tasks are specific to the particular vendor's EJB Server.</p> | |||
<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,145 +0,0 @@ | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Language" content="en-us"> | |||
<title>EjbDeploy Task</title> | |||
</head> | |||
<body> | |||
<h2><a name="ejbdeploy">ejbdeploy</a></h2> | |||
<h3><b>Description:</b></h3> | |||
<p>The <code>ejbdeploy</code> task is used to run a "hot" deployment tool for | |||
vendor-specific J2EE server. The task runs the tool in a separate JVM. The | |||
task requires nested elements which define the attributes of the | |||
vendor-specific deployment tool being executed. | |||
</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">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>No</td> | |||
</tr> | |||
<tr> | |||
<td valign="top">serverUrl</td> | |||
<td valign="top">The URL for the server where the component will be deployed.</td> | |||
<td>No</td> | |||
</tr> | |||
<tr> | |||
<td valign="top">username</td> | |||
<td valign="top">The user with privileges to deploy applications to the server.</td> | |||
<td>No</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>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 a EAR, JAR, WAR, or any other type that is supported by the server. | |||
</td> | |||
<td>No</td> | |||
</tr> | |||
</table> | |||
<h3>Nested Elements</h3> | |||
<p>The ejbdeploy task supports a nested <classpath> | |||
element to set the classpath.</p> | |||
<h3>Vendor-specific nested elements</h3> | |||
<p>Also supported are nested vendor-specific elements.</p> | |||
<h3>WebLogic element</h3> | |||
<p> | |||
The WebLogic element contains additional parameters 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. | |||
<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 ejbdeploy to deploy a component to a WebLogic server:</p> | |||
<pre> | |||
<ejbdeploy action="deploy" | |||
serverUrl="t3://myserver:7001" | |||
classpath="${classpath}" | |||
username="${user.name}" | |||
password="${user.password}" | |||
source="${lib.dir}/ejb_myApp.ear"> | |||
<weblogic application="myapp" | |||
component="ejb_foobar:myserver,productionserver" | |||
debug="true"/> | |||
</ejbdeploy> | |||
</pre> | |||
<p>This example shows ejbdeploy being used to delete a component from a | |||
WebLogic server:</p> | |||
<pre> | |||
<ejbdeploy action="delete" | |||
serverUrl="t3://myserver:7001" | |||
classpath="${classpath}" | |||
username="${user.name}" | |||
password="${user.password}"> | |||
<weblogic application="myapp"/> | |||
</ejbdeploy> | |||
</pre> | |||
<hr> | |||
<p align="center">Copyright © 2002 Apache Software Foundation. All rights Reserved.</p> | |||
</body> | |||
</html> |
@@ -0,0 +1,201 @@ | |||
<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> |
@@ -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> | |||
@@ -151,7 +151,7 @@ soscheckout=org.apache.tools.ant.taskdefs.optional.sos.SOSCheckout | |||
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,158 +0,0 @@ | |||
/* | |||
* 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 apache@apache.org. | |||
* | |||
* 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.ejb; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Task; | |||
/** | |||
* 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>getClassName()</code> method to supply the | |||
* super-task class name of the vendor specific deployment tool to run. | |||
* <li>Implement the <code>getArguments()</code> method to supply the | |||
* super-task the command line to pass for the vendor specific deployment | |||
* tool. | |||
* <li>Implement the <code>isActionValid()<code> method to insure the | |||
* action supplied as the "action" attribute of EjbDeploy 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>create<TOOL></code> method to the EjbDeploy | |||
* class. This method will be called when Ant encounters a | |||
* <code>create<TOOL></code> task nested in the | |||
* <code>ejbdeploy</code> task. | |||
* | |||
* @author Christopher A. Longo - cal@cloud9.net | |||
* | |||
* @see EjbHotDeploymentTool | |||
* @see EjbDeploy | |||
*/ | |||
public abstract class AbstractEjbHotDeploymentTool | |||
extends Task | |||
implements EjbHotDeploymentTool | |||
{ | |||
/** The super-task **/ | |||
private EjbDeploy deploy; | |||
/** | |||
* Constructor. | |||
* @param deploy The super-task which wraps this one. | |||
*/ | |||
public AbstractEjbHotDeploymentTool(EjbDeploy deploy) { | |||
this.deploy = deploy; | |||
} | |||
/** | |||
* Returns the class name of the weblogic.deploy tool to the super-task. | |||
* <p>This is called by the super-task, EjbDeploy. | |||
* <p>Subclasses should return the fully qualified class name of the | |||
* vendor tool to run. IE: "com.foobar.tools.DeployTool" | |||
* @return A String representing the classname of the deployment tool to run | |||
*/ | |||
public abstract String getClassName(); | |||
/** | |||
* Returns a String containing the runtime commandline arguments | |||
* of the deployment tool. | |||
* <p>Subclasses should return the appropriate string from that | |||
* vendor's tool. IE: "-url=http://myserver:31337 -user=foo -passsword=bar" | |||
* @return a String containing the runtime commandline arguments | |||
* of the deployment tool. | |||
*/ | |||
public abstract String getArguments(); | |||
/** | |||
* Validates the passed in attributes. | |||
* Subclasses should chain to this super-method to insure | |||
* validation of boilerplate attributes. | |||
* <p>Only the "action" and "password" attributes are required in the | |||
* base class. Subclasses should check attributes accordingly. | |||
* @exception BuildException if the attributes are invalid or incomplete | |||
*/ | |||
public void validateAttributes() throws BuildException { | |||
String action = deploy.getAction(); | |||
if(action == null) | |||
throw new BuildException("The \"action\" attribute must be set"); | |||
if(!isActionValid()) | |||
throw new BuildException("Invalid action \"" + action + "\" passed"); | |||
if(deploy.getPassword() == null) | |||
throw new BuildException("The WebLogic system password must be set"); | |||
} | |||
/** | |||
* 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(); | |||
/** | |||
* Returns the super-task. | |||
* @return An EjbDeploy object representing the super-task. | |||
*/ | |||
protected EjbDeploy getDeploy() { | |||
return deploy; | |||
} | |||
} |
@@ -0,0 +1,232 @@ | |||
/* | |||
* 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 apache@apache.org. | |||
* | |||
* 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 - cal@cloud9.net | |||
* | |||
* @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; | |||
} | |||
} |
@@ -0,0 +1,163 @@ | |||
/* | |||
* 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 apache@apache.org. | |||
* | |||
* 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 - cal@cloud9.net | |||
* | |||
* @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; | |||
} | |||
} |
@@ -51,47 +51,51 @@ | |||
* information on the Apache Software Foundation, please see | |||
* <http://www.apache.org/>. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.ejb; | |||
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 - cal@cloud9.net | |||
* | |||
* @see AbstractEjbHotDeploymentTool | |||
* @see EjbDeploy | |||
* @see org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool | |||
* @see org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy | |||
*/ | |||
public interface EjbHotDeploymentTool | |||
public interface HotDeploymentTool | |||
{ | |||
/** | |||
* Returns the class name of the weblogic.deploy tool to the super-task. | |||
* <p>This is called by the super-task, EjbDeploy. | |||
* <p>Subclasses should return the fully qualified class name of the | |||
* vendor tool to run. IE: "com.foobar.tools.DeployTool" | |||
* @return A String representing the classname of the deployment tool to run | |||
*/ | |||
public String getClassName(); | |||
/** 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. | |||
* <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 BuildException if the attributes are invalid or incomplete | |||
* @exception org.apache.tools.ant.BuildException if the attributes are invalid or incomplete. | |||
*/ | |||
public void validateAttributes() throws BuildException; | |||
/** | |||
* Returns a String containing the runtime commandline arguments | |||
* of the deployment tool. | |||
* <p>Subclasses should return the appropriate string from that | |||
* vendor's tool. IE: "-url=http://myserver:31337 -user=foo -passsword=bar" | |||
* @return a String containing the runtime commandline arguments | |||
* of the deployment tool. | |||
* 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 String getArguments() throws BuildException; | |||
public void setTask(ServerDeploy task); | |||
} |
@@ -52,61 +52,38 @@ | |||
* <http://www.apache.org/>. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.ejb; | |||
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; | |||
import org.apache.tools.ant.taskdefs.Java; | |||
import org.apache.tools.ant.types.Path; | |||
/** | |||
* A task to support "hot" deployment tools for J2EE servers. | |||
* 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. | |||
* hot deployment tools. | |||
* | |||
* @author Christopher A. Longo - cal@cloud9.net | |||
* | |||
* @see EjbHotDeploymentTool | |||
* @see AbstractEjbHotDeploymentTool | |||
* @see WebLogicHotDeploymentTool | |||
* @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 EjbDeploy extends Task | |||
public class ServerDeploy extends Task | |||
{ | |||
/** The action to be performed. IE: "deploy", "delete", etc... **/ | |||
private String action; | |||
/** 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 URL of the deployment server **/ | |||
private String serverUrl; | |||
/** The source (fully-qualified path) to the component being deployed **/ | |||
private File source; | |||
/** The vendor specific tool for deploying the component **/ | |||
private EjbHotDeploymentTool vendorTool; | |||
/** | |||
* Creates 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(project); | |||
return classpath.createPath(); | |||
} | |||
private ArrayList vendorTools = new ArrayList(); | |||
/////////////////////////////////////////////////////////////////////////// | |||
// | |||
@@ -114,41 +91,48 @@ public class EjbDeploy extends Task | |||
// | |||
/////////////////////////////////////////////////////////////////////////// | |||
/** | |||
* 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" tags | |||
* in the EjbDeploy task. | |||
* @return An instance of WebLogicHotDeployment tool. | |||
* <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 WebLogicHotDeploymentTool createWeblogic() { | |||
WebLogicHotDeploymentTool weblogic = new WebLogicHotDeploymentTool(this); | |||
vendorTool = (EjbHotDeploymentTool)weblogic; | |||
return weblogic; | |||
public void addWeblogic(WebLogicHotDeploymentTool tool) { | |||
tool.setTask(this); | |||
vendorTools.add(tool); | |||
} | |||
/////////////////////////////////////////////////////////////////////////// | |||
// | |||
// Execute method | |||
// | |||
/////////////////////////////////////////////////////////////////////////// | |||
/** | |||
* Execute the task. | |||
* <p>This will fork a JVM and run the vendor-specific deployment tool. | |||
* The process will fail if the tool returns an error. | |||
* @exception BuildException if the attributes are invalid or incomplete | |||
* <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 { | |||
if (vendorTool == null) { | |||
throw new BuildException("No vendor tool specified"); | |||
for (Iterator iterator = vendorTools.iterator(); iterator.hasNext();) { | |||
HotDeploymentTool tool = (HotDeploymentTool) iterator.next(); | |||
tool.validateAttributes(); | |||
tool.deploy(); | |||
} | |||
vendorTool.validateAttributes(); | |||
Java deploy = (Java)project.createTask("java"); | |||
deploy.setFork(true); | |||
deploy.setFailonerror(true); | |||
deploy.setClasspath(classpath); | |||
deploy.setClassname(vendorTool.getClassName()); | |||
deploy.createArg().setLine(vendorTool.getArguments()); | |||
deploy.execute(); | |||
deploy = null; | |||
} | |||
/////////////////////////////////////////////////////////////////////////// | |||
@@ -174,74 +158,6 @@ public class EjbDeploy extends Task | |||
this.action = action; | |||
} | |||
/** | |||
* gets the classpath field. | |||
* @return A Path representing the "classpath" attribute. | |||
*/ | |||
public Path getClasspath() { | |||
return classpath; | |||
} | |||
/** | |||
* Sets the classpath field. | |||
* This is not 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 not a 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 required attribute. | |||
* @param A String representing the "password" attribute. | |||
*/ | |||
public void setPassword(String password) { | |||
this.password = password; | |||
} | |||
/** | |||
* Returns the serverUrl field. | |||
* @return A String representing the "serverUrl" attribute. | |||
*/ | |||
public String getServerUrl() { | |||
return serverUrl; | |||
} | |||
/** | |||
* Sets the serverUrl field. | |||
* This is not a required attribute. | |||
* @param serverUrl A String representing the "serverUrl" attribute. | |||
*/ | |||
public void setServerUrl(String serverUrl) { | |||
this.serverUrl = serverUrl; | |||
} | |||
/** | |||
* Returns the source field (the path/filename of the component to be | |||
* deployed. | |||
@@ -254,10 +170,11 @@ public class EjbDeploy extends Task | |||
/** | |||
* Sets the source field (the path/filename of the component to be | |||
* deployed. | |||
* This is not a required attribute. | |||
* @param A String representing the "source" attribute. | |||
* This is <b>not</b> a required attribute. | |||
* @param source String representing the "source" attribute. | |||
*/ | |||
public void setSource(File source) { | |||
this.source = source; | |||
} | |||
} | |||
@@ -52,9 +52,13 @@ | |||
* <http://www.apache.org/>. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.ejb; | |||
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 | |||
@@ -62,35 +66,17 @@ import org.apache.tools.ant.BuildException; | |||
* 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 | |||
* to run the weblogic.deploy tool. | |||
* <p>In the end, this task assembles the commadline parameters | |||
* and runs the weblogic.deploy tool in a seperate JVM. | |||
* | |||
* @author Christopher A. Longo - cal@cloud9.net | |||
* | |||
* @see EjbHotDeploymentTool | |||
* @see AbstractEjbHotDeploymentTool | |||
* @see EjbDeploy | |||
* @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 AbstractEjbHotDeploymentTool | |||
implements EjbHotDeploymentTool | |||
public class WebLogicHotDeploymentTool extends AbstractHotDeploymentTool implements 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"; | |||
/** The classname of the tool to run **/ | |||
private static final String WEBLOGIC_DEPLOY_CLASS_NAME = "weblogic.deploy"; | |||
@@ -99,29 +85,30 @@ public class WebLogicHotDeploymentTool | |||
{ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST, ACTION_UNDEPLOY, ACTION_UPDATE}; | |||
/** Represents the "-debug" flag from weblogic.deploy **/ | |||
public boolean debug; | |||
private boolean debug; | |||
/** The application name that is being deployed **/ | |||
public String application; | |||
private String application; | |||
/** The component name:target(s) for the "-component" argument of weblogic.deploy **/ | |||
public String component; | |||
/** | |||
* Constructor | |||
* @param deploy - The super-task which wraps this task | |||
*/ | |||
public WebLogicHotDeploymentTool(EjbDeploy deploy) { | |||
super(deploy); | |||
} | |||
private String component; | |||
/** | |||
* Returns the class name of the weblogic.deploy tool to the super-task. | |||
* <p>This is called by the super-task, EjbDeploy. | |||
* @return A String representing the classname of the deployment tool to run | |||
* 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 String getClassName() { | |||
return WEBLOGIC_DEPLOY_CLASS_NAME; | |||
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(); | |||
} | |||
/** | |||
@@ -131,30 +118,28 @@ public class WebLogicHotDeploymentTool | |||
* attributes must be supplied. | |||
* <li>If action is "delete" or "undeploy" the "application" attribute must | |||
* be supplied. | |||
* @exception BuildException if the attributes are invalid or incomplete | |||
* @exception org.apache.tools.ant.BuildException if the attributes are invalid or incomplete | |||
*/ | |||
public void validateAttributes() throws BuildException { | |||
super.validateAttributes(); | |||
String action = getDeploy().getAction(); | |||
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); | |||
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)) | |||
&& getDeploy().getSource() == null) | |||
throw new BuildException( | |||
"The source attribute must be set if action = " + action); | |||
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); | |||
if((action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) && application == null) | |||
throw new BuildException("The application attribute must be set if action = " + action); | |||
} | |||
/** | |||
@@ -163,7 +148,7 @@ public class WebLogicHotDeploymentTool | |||
* @return A String containing the arguments for the weblogic.deploy tool. | |||
*/ | |||
public String getArguments() throws BuildException { | |||
String action = getDeploy().getAction(); | |||
String action = getTask().getAction(); | |||
String args = null; | |||
if(action.equals(ACTION_DEPLOY) || action.equals(ACTION_UPDATE)) | |||
@@ -184,7 +169,7 @@ public class WebLogicHotDeploymentTool | |||
protected boolean isActionValid() { | |||
boolean valid = false; | |||
String action = getDeploy().getAction(); | |||
String action = getTask().getAction(); | |||
for(int i = 0; i < VALID_ACTIONS.length; i++) { | |||
if(action.equals(VALID_ACTIONS[i])) { | |||
@@ -203,22 +188,21 @@ public class WebLogicHotDeploymentTool | |||
* The action-specific build methods will append to this StringBuffer. | |||
*/ | |||
protected StringBuffer buildArgsPrefix() { | |||
EjbDeploy deploy = getDeploy(); | |||
ServerDeploy task = getTask(); | |||
// constructs the "-url <url> -debug <action> <password>" portion | |||
// of the commmand line | |||
return new StringBuffer(1024) | |||
.append((deploy.getServerUrl() != null) | |||
? "-url " + deploy.getServerUrl() | |||
: "") | |||
.append((getServer() != null) | |||
? "-url " + getServer() | |||
: "") | |||
.append(" ") | |||
.append(debug ? "-debug " : "") | |||
.append((deploy.getUserName() != null) | |||
? "-username " + deploy.getUserName() | |||
: "") | |||
.append((getUserName() != null) | |||
? "-username " + getUserName() | |||
: "") | |||
.append(" ") | |||
.append(deploy.getAction()).append(" ") | |||
.append(deploy.getPassword()).append(" "); | |||
.append(task.getAction()).append(" ") | |||
.append(getPassword()).append(" "); | |||
} | |||
/** | |||
@@ -229,7 +213,7 @@ public class WebLogicHotDeploymentTool | |||
protected String buildDeployArgs() { | |||
String args = buildArgsPrefix() | |||
.append(application).append(" ") | |||
.append(getDeploy().getSource()) | |||
.append(getTask().getSource()) | |||
.toString(); | |||
if(component != null) | |||
@@ -260,7 +244,7 @@ public class WebLogicHotDeploymentTool | |||
/** | |||
* Sets the debug field. | |||
* <p>This attribute is not a required attribute. | |||
* <p>This is not a required attribute. | |||
* @param debug A boolean representing weblogic.deploy "-debug" flag. | |||
*/ | |||
public void setDebug(boolean debug) { | |||
@@ -269,7 +253,7 @@ public class WebLogicHotDeploymentTool | |||
/** | |||
* Sets the application field. | |||
* <p>This attribute is a required attribute. | |||
* <p>This is a required attribute. | |||
* @param application A String representing the application portion of the | |||
* weblogic.deploy command line. | |||
*/ |