Browse Source

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 - cal@cloud9.net

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272053 13f79535-47bb-0310-9956-ffa450edef68
master
Erik Hatcher 23 years ago
parent
commit
00988f5180
12 changed files with 728 additions and 530 deletions
  1. +1
    -1
      WHATSNEW
  2. +0
    -1
      docs/manual/OptionalTasks/ejb.html
  3. +0
    -145
      docs/manual/OptionalTasks/ejbdeploy.html
  4. +201
    -0
      docs/manual/OptionalTasks/serverdeploy.html
  5. +1
    -0
      docs/manual/optionaltasklist.html
  6. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/defaults.properties
  7. +0
    -158
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/AbstractEjbHotDeploymentTool.java
  8. +232
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/AbstractHotDeploymentTool.java
  9. +163
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/GenericHotDeploymentTool.java
  10. +29
    -25
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/HotDeploymentTool.java
  11. +46
    -129
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/ServerDeploy.java
  12. +54
    -70
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/WebLogicHotDeploymentTool.java

+ 1
- 1
WHATSNEW View File

@@ -242,7 +242,7 @@ Other changes:
"site chmod", as well as set the umask before transferring files, if "site chmod", as well as set the umask before transferring files, if
the server supports "site umask". the server supports "site umask".
* New <ejbdeploy> "optional" task.
* New <serverdeploy> "optional" task.


* <patternset> now supports nested patternsets. * <patternset> now supports nested patternsets.




+ 0
- 1
docs/manual/OptionalTasks/ejb.html View File

@@ -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="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="#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="#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><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 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> <tr><td><a href="BorlandEJBTasks.html">borland</a></td><td>Borland Application Server 4.5</td></tr>


+ 0
- 145
docs/manual/OptionalTasks/ejbdeploy.html View File

@@ -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 &lt;classpath&gt;
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>&lt;component&gt;:&lt;target1&gt;,&lt;target2&gt;...</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>
&lt;ejbdeploy action=&quot;deploy&quot;
serverUrl=&quot;t3://myserver:7001&quot;
classpath=&quot;${classpath}&quot;
username=&quot;${user.name}&quot;
password=&quot;${user.password}&quot;
source=&quot;${lib.dir}/ejb_myApp.ear&quot;&gt;
&lt;weblogic application=&quot;myapp&quot;
component=&quot;ejb_foobar:myserver,productionserver&quot;
debug=&quot;true&quot;/&gt;
&lt;/ejbdeploy&gt;
</pre>

<p>This example shows ejbdeploy being used to delete a component from a
WebLogic server:</p>

<pre>
&lt;ejbdeploy action=&quot;delete&quot;
serverUrl=&quot;t3://myserver:7001&quot;
classpath=&quot;${classpath}&quot;
username=&quot;${user.name}&quot;
password=&quot;${user.password}&quot;&gt;
&lt;weblogic application=&quot;myapp&quot;/&gt;
&lt;/ejbdeploy&gt;
</pre>
<hr>
<p align="center">Copyright &copy; 2002 Apache Software Foundation. All rights Reserved.</p>
</body>
</html>

+ 201
- 0
docs/manual/OptionalTasks/serverdeploy.html View File

@@ -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 &lt;arg&gt; and &lt;jvmarg&gt; 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>
&lt;serverdeploy action=&quot;deploy&quot; source=&quot;${lib.dir}/ejb_myApp.ear&quot;&gt;
&lt;generic classname="com.yamato.j2ee.tools.deploy.DeployTool"
classpath=&quot;${classpath}&quot;
username=&quot;${user.name}&quot;
password=&quot;${user.password}&quot;&gt;
&lt;arg value="-component=WildStar"/&gt;
&lt;arg value="-force"/&gt;
&lt;jvmarg value="-ms64m"/&gt;
&lt;jvmarg value="-mx128m"/&gt;
&lt;/generic&gt;
&lt;/serverdeploy&gt;
</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>&lt;component&gt;:&lt;target1&gt;,&lt;target2&gt;...</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>
&lt;serverdeploy action=&quot;deploy&quot; source=&quot;${lib.dir}/ejb_myApp.ear&quot;&gt;
&lt;weblogic application=&quot;myapp&quot;
server=&quot;t3://myserver:7001&quot;
classpath=&quot;${weblogic.home}/lib/weblogic.jar&quot;
username=&quot;${user.name}&quot;
password=&quot;${user.password}&quot;
component=&quot;ejb_foobar:myserver,productionserver&quot;
debug=&quot;true&quot;/&gt;
&lt;/serverdeploy&gt;
</pre>

<p>This example shows serverdeploy being used to delete a component from a
WebLogic server:</p>

<pre>
&lt;serverdeploy action=&quot;delete&quot;&gt/
&lt;weblogic application=&quot;myapp&quot
server=&quot;t3://myserver:7001&quot;
classpath=&quot;${weblogic.home}/lib/weblogic.jar&quot;
username=&quot;${user.name}&quot;
password=&quot;${user.password}&quot;/&gt;
&lt;/serverdeploy&gt;
</pre>
<hr>
<p align="center">Copyright &copy; 2002 Apache Software Foundation. All rights Reserved.</p>
</body>
</html>

+ 1
- 0
docs/manual/optionaltasklist.html View File

@@ -44,6 +44,7 @@
<a href="OptionalTasks/renameextensions.html"><i>RenameExtensions</i></a><br> <a href="OptionalTasks/renameextensions.html"><i>RenameExtensions</i></a><br>
<a href="OptionalTasks/replaceregexp.html">ReplaceRegExp</a><br> <a href="OptionalTasks/replaceregexp.html">ReplaceRegExp</a><br>
<a href="OptionalTasks/rpm.html">Rpm</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/script.html">Script</a><br>
<a href="OptionalTasks/sound.html">Sound</a><br> <a href="OptionalTasks/sound.html">Sound</a><br>
<a href="OptionalTasks/sos.html">SourceOffSite</a><br> <a href="OptionalTasks/sos.html">SourceOffSite</a><br>


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/defaults.properties View File

@@ -151,7 +151,7 @@ soscheckout=org.apache.tools.ant.taskdefs.optional.sos.SOSCheckout
soslabel=org.apache.tools.ant.taskdefs.optional.sos.SOSLabel soslabel=org.apache.tools.ant.taskdefs.optional.sos.SOSLabel
echoproperties=org.apache.tools.ant.taskdefs.optional.EchoProperties echoproperties=org.apache.tools.ant.taskdefs.optional.EchoProperties
splash=org.apache.tools.ant.taskdefs.optional.splash.SplashTask 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) # deprecated ant tasks (kept for back compatibility)
starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut


+ 0
- 158
src/main/org/apache/tools/ant/taskdefs/optional/ejb/AbstractEjbHotDeploymentTool.java View File

@@ -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&lt;TOOL&gt;</code> method to the EjbDeploy
* class. This method will be called when Ant encounters a
* <code>create&lt;TOOL&gt;</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;
}
}

+ 232
- 0
src/main/org/apache/tools/ant/taskdefs/optional/j2ee/AbstractHotDeploymentTool.java View File

@@ -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&lt;TOOL&gt;</code> method to the ServerDeploy
* class. This method will be called when Ant encounters a
* <code>add&lt;TOOL&gt;</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;
}
}

+ 163
- 0
src/main/org/apache/tools/ant/taskdefs/optional/j2ee/GenericHotDeploymentTool.java View File

@@ -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;
}
}

src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbHotDeploymentTool.java → src/main/org/apache/tools/ant/taskdefs/optional/j2ee/HotDeploymentTool.java View File

@@ -51,47 +51,51 @@
* information on the Apache Software Foundation, please see * information on the Apache Software Foundation, please see
* <http://www.apache.org/>. * <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.BuildException;
import org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy;


/** /**
* An interface for vendor-specific "hot" deployment tools. * An interface for vendor-specific "hot" deployment tools.
* *
* @author Christopher A. Longo - cal@cloud9.net * @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. * 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; 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);
} }

src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbDeploy.java → src/main/org/apache/tools/ant/taskdefs/optional/j2ee/ServerDeploy.java View File

@@ -52,61 +52,38 @@
* <http://www.apache.org/>. * <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.io.File;
import java.util.ArrayList;
import java.util.Iterator;


import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task; 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 * 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 * @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... **/ /** The action to be performed. IE: "deploy", "delete", etc... **/
private String action; 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 **/ /** The source (fully-qualified path) to the component being deployed **/
private File source; private File source;


/** The vendor specific tool for deploying the component **/ /** 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. * 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. * 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 { 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; 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 * Returns the source field (the path/filename of the component to be
* deployed. * deployed.
@@ -254,10 +170,11 @@ public class EjbDeploy extends Task
/** /**
* Sets the source field (the path/filename of the component to be * Sets the source field (the path/filename of the component to be
* deployed. * 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) { public void setSource(File source) {
this.source = source; this.source = source;
} }
} }


src/main/org/apache/tools/ant/taskdefs/optional/ejb/WebLogicHotDeploymentTool.java → src/main/org/apache/tools/ant/taskdefs/optional/j2ee/WebLogicHotDeploymentTool.java View File

@@ -52,9 +52,13 @@
* <http://www.apache.org/>. * <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.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 * 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 is <b>not</b> the same as creating the application archive.
* This task assumes the archive (EAR, JAR, or WAR) file has been * This task assumes the archive (EAR, JAR, or WAR) file has been
* assembled and is supplied as the "source" attribute. * 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 * @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 **/ /** The classname of the tool to run **/
private static final String WEBLOGIC_DEPLOY_CLASS_NAME = "weblogic.deploy"; 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}; {ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST, ACTION_UNDEPLOY, ACTION_UPDATE};


/** Represents the "-debug" flag from weblogic.deploy **/ /** Represents the "-debug" flag from weblogic.deploy **/
public boolean debug;
private boolean debug;


/** The application name that is being deployed **/ /** 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 **/ /** 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. * attributes must be supplied.
* <li>If action is "delete" or "undeploy" the "application" attribute must * <li>If action is "delete" or "undeploy" the "application" attribute must
* be supplied. * 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 { public void validateAttributes() throws BuildException {
super.validateAttributes(); 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 // 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 // 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 // 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. * @return A String containing the arguments for the weblogic.deploy tool.
*/ */
public String getArguments() throws BuildException { public String getArguments() throws BuildException {
String action = getDeploy().getAction();
String action = getTask().getAction();
String args = null; String args = null;


if(action.equals(ACTION_DEPLOY) || action.equals(ACTION_UPDATE)) if(action.equals(ACTION_DEPLOY) || action.equals(ACTION_UPDATE))
@@ -184,7 +169,7 @@ public class WebLogicHotDeploymentTool
protected boolean isActionValid() { protected boolean isActionValid() {
boolean valid = false; boolean valid = false;


String action = getDeploy().getAction();
String action = getTask().getAction();


for(int i = 0; i < VALID_ACTIONS.length; i++) { for(int i = 0; i < VALID_ACTIONS.length; i++) {
if(action.equals(VALID_ACTIONS[i])) { if(action.equals(VALID_ACTIONS[i])) {
@@ -203,22 +188,21 @@ public class WebLogicHotDeploymentTool
* The action-specific build methods will append to this StringBuffer. * The action-specific build methods will append to this StringBuffer.
*/ */
protected StringBuffer buildArgsPrefix() { protected StringBuffer buildArgsPrefix() {
EjbDeploy deploy = getDeploy();

ServerDeploy task = getTask();
// constructs the "-url <url> -debug <action> <password>" portion // constructs the "-url <url> -debug <action> <password>" portion
// of the commmand line // of the commmand line
return new StringBuffer(1024) return new StringBuffer(1024)
.append((deploy.getServerUrl() != null)
? "-url " + deploy.getServerUrl()
: "")
.append((getServer() != null)
? "-url " + getServer()
: "")
.append(" ") .append(" ")
.append(debug ? "-debug " : "") .append(debug ? "-debug " : "")
.append((deploy.getUserName() != null)
? "-username " + deploy.getUserName()
: "")
.append((getUserName() != null)
? "-username " + getUserName()
: "")
.append(" ") .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() { protected String buildDeployArgs() {
String args = buildArgsPrefix() String args = buildArgsPrefix()
.append(application).append(" ") .append(application).append(" ")
.append(getDeploy().getSource())
.append(getTask().getSource())
.toString(); .toString();


if(component != null) if(component != null)
@@ -260,7 +244,7 @@ public class WebLogicHotDeploymentTool


/** /**
* Sets the debug field. * 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. * @param debug A boolean representing weblogic.deploy "-debug" flag.
*/ */
public void setDebug(boolean debug) { public void setDebug(boolean debug) {
@@ -269,7 +253,7 @@ public class WebLogicHotDeploymentTool


/** /**
* Sets the application field. * 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 * @param application A String representing the application portion of the
* weblogic.deploy command line. * weblogic.deploy command line.
*/ */

Loading…
Cancel
Save