Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 42161 invoked from network); 26 Mar 2002 02:03:45 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 26 Mar 2002 02:03:45 -0000 Received: (qmail 17140 invoked by uid 97); 26 Mar 2002 02:03:47 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 17095 invoked by uid 97); 26 Mar 2002 02:03:47 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 17083 invoked from network); 26 Mar 2002 02:03:46 -0000 From: To: "Ant Developers List" Subject: CONTRIBUTION: GenericHotDeploymentTool.java Date: Mon, 25 Mar 2002 21:03:55 -0500 Message-ID: <000401c1d46a$7be1ebf0$6401a8c0@chris> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0005_01C1D440.930BE3F0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-OriginalArrivalTime: 26 Mar 2002 02:03:55.0311 (UTC) FILETIME=[7BE1EBF0:01C1D46A] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0005_01C1D440.930BE3F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Part of the hot deployment framework. - Chris ------=_NextPart_000_0005_01C1D440.930BE3F0 Content-Type: application/octet-stream; name="GenericHotDeploymentTool.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="GenericHotDeploymentTool.java" /* * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software = itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Ant", and "Apache Software * Foundation" must not be used to endorse or promote products = derived * from this software without prior written permission. For written * permission, please contact 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. * = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * * 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 * . */ package org.apache.tools.ant.taskdefs.optional.ejb; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.taskdefs.Java; /** * A generic tool for EJB hot deployment. *

The simple implementation spawns a JVM with the supplied * class name, jvm args, and arguments. * * @author Christopher A. Longo - cal@cloud9.net * * @see EjbHotDeploymentTool * @see AbstractEjbHotDeploymentTool * @see EjbDeploy */ public class GenericHotDeploymentTool extends = AbstractEjbHotDeploymentTool { /** A Java task used to run the deployment tool **/ private Java java; /** The fully qualified class name of the deployment tool **/ private String className; /** The deploy action String **/ public static final String ACTION_DEPLOY =3D "deploy"; /** List of valid actions **/ private static final String[] VALID_ACTIONS =3D { 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=3Dmark", "-password=3Dventure"... */ 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. *

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 EjbDeploy object representing the parent task. */ public void setTask(EjbDeploy task) { super.setTask(task); if(java =3D=3D null) java =3D (Java)task.getProject().createTask("java"); } /** * Perform the actual deployment.
* For this generic implementation, a JVM is spawned using the * supplied classpath, classname, JVM args, and command line = arguments. * @exception BuildException if the attributes are invalid or = incomplete. */ public void deploy() throws BuildException { java.setClassname(className); java.setClasspath(getTask().getClasspath()); java.setFork(true); java.setFailonerror(true); java.execute(); } /** * Validates the passed in attributes. * Ensures the className and arguments attribute have been set. * @exception BuildException if the attributes are invalid or = incomplete. */ public void validateAttributes() throws BuildException { super.validateAttributes(); if(className =3D=3D null) throw new BuildException("The classname attribute must be = set"); } /** * Sets the className field. *

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 =3D className; } } ------=_NextPart_000_0005_01C1D440.930BE3F0 Content-Type: text/plain; charset=us-ascii -- To unsubscribe, e-mail: For additional commands, e-mail: ------=_NextPart_000_0005_01C1D440.930BE3F0--