Browse Source

Patch to enable JOnAS for <serverdeploy> (PR 7633). Supplied by Cyrille Morvan.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272108 13f79535-47bb-0310-9956-ffa450edef68
master
Erik Hatcher 23 years ago
parent
commit
8abcb93e20
5 changed files with 427 additions and 3 deletions
  1. +3
    -0
      WHATSNEW
  2. +120
    -3
      docs/manual/OptionalTasks/serverdeploy.html
  3. +11
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/GenericHotDeploymentTool.java
  4. +281
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java
  5. +12
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/ServerDeploy.java

+ 3
- 0
WHATSNEW View File

@@ -251,6 +251,9 @@ Other changes:

* Perforce tasks now support a "failonerror" attribute (defaults to "true").

* Open Source application server JOnAS support :
EJB hot deploy and deploy with <serverdeploy> and <ejbjar>

Changes from Ant 1.4 to Ant 1.4.1
===========================================



+ 120
- 3
docs/manual/OptionalTasks/serverdeploy.html View File

@@ -8,7 +8,40 @@

<body>

<h2><a name="serverdeploy">serverdeploy</a></h2>
<h1><a name="serverdeploy">ANT ServerDeploy User Manual</a></h1>
<p>by</p>
<!-- Names are in alphabetical order, on last name -->
<ul>
<li>Christopher A. Longo (<a href="mailto:cal@cloud9.net">cal@cloud9.net</a>)</li>
<li>Cyrille Morvan (<a href="mailto:cmorvan@ingenosya.com">cmorvan@ingenosya.com</a>)</li>
</ul>

</p>
<hr>
<p> At present the tasks support:<br>

<ul>
<li><a href="http://www.bea.com" target="_top">Weblogic</a> servers</li>
<li><a href="http://www.objectweb.org/jonas/" target="_top">JOnAS</a>
2.4 Open Source EJB server</li>
</ul>
Over time we expect further optional tasks to support additional J2EE Servers.
</p>

<hr>

<table border="1" cellpadding="5">
<tr><td>Task</td><td colspan="2">Application Servers</td></tr>
<tr><td rowspan="4"><a href="#serverdeploy_element">serverdeploy</a></td><td colspan="2" align="center"><b>Nested Elements</b></td></tr>
<tr><td><a href="#serverdeploy_generic">generic</a></td><td>Generic task</td></tr>
<tr><td><a href="#serverdeploy_jonas">jonas</a></td><td>JOnAS 2.4</td></tr>
<tr><td><a href="#serverdeploy_weblogic">weblogic</a></td><td>Weblogic</td></tr>

</table>

<a name="serverdeploy_element">
<h2>ServerDeploy element</h2>

<h3><b>Description:</b></h3>

<p>The <code>serverdeploy</code> task is used to run a "hot" deployment tool for
@@ -79,6 +112,7 @@ attributes are required, depending on the tool.

<p>Also supported are nested vendor-specific elements.</p>

<a name="serverdeploy_generic">
<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>
@@ -125,7 +159,7 @@ using a Java based deploy tool:</p>
&lt;/serverdeploy&gt;
</pre>

<a name="serverdeploy_weblogic">
<h3>WebLogic element</h3>
<p>
The WebLogic element contains additional attributes to run the
@@ -187,7 +221,88 @@ required for all actions.
WebLogic server:</p>

<pre>
&lt;serverdeploy action=&quot;delete&quot;&gt/
&lt;serverdeploy action=&quot;delete&quot; source=&quot;${lib.dir}/ejb_myApp.jar&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>

<a name="serverdeploy_jonas">
<h3>JOnAS (Java Open Applicaton Server) element</h3>
<p>
The JOnAS element contains additional attributes to run the
<code>JonasAdmin</code> deployment tool.
<p>Valid actions for the tool are <code>deploy</code>, <code>undeploy</code>,
<code>list</code> and <code>update</code>.
<p>You can't use <code>user</code> and <code>password</code> property with this
task.
<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">jonasroot</td>
<td valign="top">The root directory for JOnAS.</td>
<td>Yes</td>
</tr>
<tr>
<td valign="top">orb</td>
<td valign="top">Choose your ORB : RMI, JEREMIE, DAVID, ... If omitted, it defaults
to the one present in classpath. The corresponding JOnAS JAR is
automatically added to the classpath. If your orb is DAVID (RMI/IIOP) you must
specify davidhost and davidport properties.</td>
<td>No</td>
</tr>
<tr>
<td valign="top">davidhost</td>
<td valign="top">The value for the system property : <code>david.CosNaming.default_host</code> .</td>
<td>No</td>
</tr>
<tr>
<td valign="top">davidport</td>
<td valign="top">The value for the system property : <code>david.CosNaming.default_port</code> .</td>
<td>No</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. Default to <code>org.objectweb.jonas.adm.JonasAdmin</code></td>
<td>No</td>
</tr>

</table>

<h3>Nested Elements</h3>
<p>The jonas element supports nested &lt;arg&gt; and &lt;jvmarg&gt; elements.</p>


<h3>Examples</h3>

<p>This example shows the use of serverdeploy to deploy a component to a JOnAS server:</p>

<pre>
&lt;serverdeploy action=&quot;deploy&quot; source=&quot;${lib.dir}/ejb_myApp.jar&quot;&gt;
&lt;jonas server=&quot;MyJOnAS&quot; jonasroot="${jonas.root}" >
&lt;classpath&gt;
&lt;pathelement path=&quot;${jonas.root}/lib/RMI_jonas.jar&quot; /&gt;
&lt;pathelement path=&quot;${jonas.root}/config/&quot; /&gt;
&lt;/classpath&gt;
&lt;/jonas&gt;
&lt;/serverdeploy&gt;
</pre>

<p>This example shows serverdeploy being used to list the components from a
JOnAS server and a WebLogic server:</p>

<pre>
&lt;serverdeploy action=&quot;list&quot; /&gt
&lt;jonas jonasroot=&quot;${jonas.root}&quot; orb=&quot;JEREMIE&quot; /&gt;
&lt;weblogic application=&quot;myapp&quot
server=&quot;t3://myserver:7001&quot;
classpath=&quot;${weblogic.home}/lib/weblogic.jar&quot;
@@ -195,6 +310,8 @@ WebLogic server:</p>
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>


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

@@ -160,4 +160,15 @@ public class GenericHotDeploymentTool extends AbstractHotDeploymentTool
public void setClassName(String className) {
this.className = className;
}
/**
*
*/
public Java getJava() {
return java;
}
public String getClassName() {
return className;
}
}

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

@@ -0,0 +1,281 @@
/*
* 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 java.io.File;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.taskdefs.optional.j2ee.AbstractHotDeploymentTool;
import org.apache.tools.ant.taskdefs.optional.j2ee.HotDeploymentTool;
import org.apache.tools.ant.taskdefs.optional.j2ee.ServerDeploy;
import org.apache.tools.ant.types.Path;

/**
* An Ant wrapper task for the weblogic.deploy tool. This is used
* to hot-deploy J2EE applications to a running WebLogic server.
* This is <b>not</b> the same as creating the application
* archive. This task assumes the archive (EAR, JAR, or WAR) file
* has been assembled and is supplied as the "source" attribute.
* <p>
*
* In the end, this task assembles the commadline parameters and
* runs the weblogic.deploy tool in a seperate JVM.
*
*@author Cyrille Morvan
*@created March 30, 2002
*@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 JonasHotDeploymentTool extends GenericHotDeploymentTool implements HotDeploymentTool {

/**
* Description of the Field
*/
protected final static String DEFAULT_ORB = "RMI";

/**
* The classname of the tool to run *
*/
private final static String JONAS_DEPLOY_CLASS_NAME = "org.objectweb.jonas.adm.JonasAdmin";

/**
* All the valid actions that weblogic.deploy permits *
*/
private final static String[] VALID_ACTIONS =
{ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST, ACTION_UNDEPLOY, ACTION_UPDATE};

/**
* Description of the Field
*/
private File jonasroot;
/**
* Description of the Field
*/
private String orb = null;

/**
* Description of the Field
*/
private String davidHost;
/**
* Description of the Field
*/
private int davidPort;


/**
* Set the host for the David ORB.
*
*@param inValue The new davidhost value
*/
public void setDavidhost(final String inValue) {
davidHost = inValue;
}


/**
* Set the port for the David ORB.
*
*@param inValue The new davidport value
*/
public void setDavidport(final int inValue) {
davidPort = inValue;
}


/**
* set the jonas root directory (-Dinstall.root=). This
* element is required.
*
*@param inValue The new jonasroot value
*/
public void setJonasroot(final File inValue) {
jonasroot = inValue;
}


/**
* Set the ORB to construct classpath.
*
*@param inValue RMI, JEREMIE, DAVID,...
*/
public void setOrb(final String inValue) {
orb = inValue;
}


/**
* gets the classpath field.
*
*@return A Path representing the "classpath" attribute.
*/
public Path getClasspath() {

Path aClassPath = super.getClasspath();

if (aClassPath == null) {
aClassPath = new Path(getTask().getProject());
}
if (orb != null) {
String aOrbJar = new File(jonasroot, "lib/" + orb + "_jonas.jar").toString();
String aConfigDir = new File(jonasroot, "config/").toString();
Path aJOnASOrbPath = new Path(aClassPath.getProject(),
aOrbJar + File.pathSeparator + aConfigDir);
aClassPath.append(aJOnASOrbPath);
}
return aClassPath;
}


/**
* 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 Description
* of Exception
*/
public void validateAttributes() throws BuildException {
// super.validateAttributes(); // don't want to call this method

Java java = getJava();

String action = getTask().getAction();
if (action == null) {
throw new BuildException("The \"action\" attribute must be set");
}

if (!isActionValid()) {
throw new BuildException("Invalid action \"" + action + "\" passed");
}

if (getClassName() == null) {
setClassName(JONAS_DEPLOY_CLASS_NAME);
}

if (jonasroot == null || jonasroot.isDirectory()) {
java.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot + "/config/java.policy");

if ("DAVID".equals(orb)) {
java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB");
java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass=org.objectweb.david.libs.binding.orbs.ORBSingletonClass");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass=org.objectweb.david.libs.stub_factories.rmi.StubDelegate");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass=org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass=org.objectweb.david.libs.helpers.RMIUtilDelegate");
java.createJvmarg().setValue("-Ddavid.CosNaming.default_method=0");
java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass=com.sun.corba.se.internal.io.ValueHandlerImpl");
if (davidHost != null) {
java.createJvmarg().setValue("-Ddavid.CosNaming.default_host=" + davidHost);
}
if (davidPort != 0) {
java.createJvmarg().setValue("-Ddavid.CosNaming.default_port=" + davidPort);
}
}
}

String anAction = getTask().getAction();

if (getServer() != null) {
java.createArg().setLine("-n " + getServer());
}

if (action.equals(ACTION_DEPLOY) ||
action.equals(ACTION_UPDATE) ||
action.equals("redeploy")) {
java.createArg().setLine("-a " + getTask().getSource());
}
else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) {
java.createArg().setLine("-r " + getTask().getSource());
}
else if (action.equals(ACTION_LIST)) {
java.createArg().setValue("-l");
}
}


/**
* Determines if the action supplied is valid. <p>
*
* Valid actions are contained in the static array
* VALID_ACTIONS
*
*@return true if the action attribute is valid, false if
* not.
*/
protected boolean isActionValid() {
boolean valid = false;

String action = getTask().getAction();

for (int i = 0; i < VALID_ACTIONS.length; i++) {
if (action.equals(VALID_ACTIONS[i])) {
valid = true;
break;
}
}

return valid;
}
}


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

@@ -113,6 +113,18 @@ public class ServerDeploy extends Task
vendorTools.addElement(tool);
}

/**
* Creates a JOnAS deployment tool, for deployment to JOnAS servers.
* <p>Ant calls this method on creation to handle embedded "jonas" elements
* in the ServerDeploy task.
* @param tool An instance of JonasHotDeployment tool, passed in by Ant.
*/
public void addJonas(JonasHotDeploymentTool tool) {
tool.setTask(this);
vendorTools.addElement(tool);
}


///////////////////////////////////////////////////////////////////////////
//
// Execute method


Loading…
Cancel
Save