Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 212   Methods: 8
NCLOC: 61   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
WLStop.java 0% 0% 0% 0%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
 5   
  * reserved.
 6   
  *
 7   
  * Redistribution and use in source and binary forms, with or without
 8   
  * modification, are permitted provided that the following conditions
 9   
  * are met:
 10   
  *
 11   
  * 1. Redistributions of source code must retain the above copyright
 12   
  *    notice, this list of conditions and the following disclaimer.
 13   
  *
 14   
  * 2. Redistributions in binary form must reproduce the above copyright
 15   
  *    notice, this list of conditions and the following disclaimer in
 16   
  *    the documentation and/or other materials provided with the
 17   
  *    distribution.
 18   
  *
 19   
  * 3. The end-user documentation included with the redistribution, if
 20   
  *    any, must include the following acknowlegement:
 21   
  *       "This product includes software developed by the
 22   
  *        Apache Software Foundation (http://www.apache.org/)."
 23   
  *    Alternately, this acknowlegement may appear in the software itself,
 24   
  *    if and wherever such third-party acknowlegements normally appear.
 25   
  *
 26   
  * 4. The names "Ant" and "Apache Software
 27   
  *    Foundation" must not be used to endorse or promote products derived
 28   
  *    from this software without prior written permission. For written
 29   
  *    permission, please contact apache@apache.org.
 30   
  *
 31   
  * 5. Products derived from this software may not be called "Apache"
 32   
  *    nor may "Apache" appear in their names without prior written
 33   
  *    permission of the Apache Group.
 34   
  *
 35   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46   
  * SUCH DAMAGE.
 47   
  * ====================================================================
 48   
  *
 49   
  * This software consists of voluntary contributions made by many
 50   
  * individuals on behalf of the Apache Software Foundation.  For more
 51   
  * information on the Apache Software Foundation, please see
 52   
  * <http://www.apache.org/>.
 53   
  */
 54   
 package org.apache.tools.ant.taskdefs.optional.ejb;
 55   
 
 56   
 
 57   
 import java.io.File;
 58   
 import org.apache.tools.ant.BuildException;
 59   
 import org.apache.tools.ant.Task;
 60   
 import org.apache.tools.ant.taskdefs.Java;
 61   
 import org.apache.tools.ant.types.Path;
 62   
 
 63   
 /**
 64   
  * Shuts down a WebLogic server.
 65   
  * To shut down an instance you must supply both a username and
 66   
  * a password.
 67   
  *
 68   
  * @author Conor MacNeill, Cortex ebusiness Pty Limited
 69   
  */
 70   
 public class WLStop extends Task {
 71   
     /**
 72   
      * The classpath to be used. It must contains the weblogic.Admin class.
 73   
      */
 74   
     private Path classpath;
 75   
 
 76   
     /**
 77   
      * The weblogic username to use to request the shutdown.
 78   
      */
 79   
     private String username;
 80   
 
 81   
     /**
 82   
      * The password to use to shutdown the weblogic server.
 83   
      */
 84   
     private String password;
 85   
 
 86   
     /**
 87   
      * The URL which the weblogic server is listening on.
 88   
      */
 89   
     private String serverURL;
 90   
 
 91   
     /**
 92   
      * The delay (in seconds) to wait before shutting down.
 93   
      */
 94   
     private int delay = 0;
 95   
 
 96   
     /**
 97   
      * The location of the BEA Home under which this server is run.
 98   
      * WL6 only
 99   
      */
 100   
     private File beaHome = null;
 101   
 
 102   
     /**
 103   
      * Do the work.
 104   
      *
 105   
      * The work is actually done by creating a separate JVM to run the weblogic admin task
 106   
      * This approach allows the classpath of the helper task to be set.
 107   
      *
 108   
      * @exception BuildException if someting goes wrong with the build
 109   
      */
 110  0
     public void execute() throws BuildException {
 111  0
         if (username == null || password == null) {
 112  0
             throw new BuildException("weblogic username and password must both be set");
 113   
         }
 114   
 
 115  0
         if (serverURL == null) {
 116  0
             throw new BuildException("The url of the weblogic server must be provided.");
 117   
         }
 118   
 
 119  0
         Java weblogicAdmin = (Java) getProject().createTask("java");
 120  0
         weblogicAdmin.setFork(true);
 121  0
         weblogicAdmin.setClassname("weblogic.Admin");
 122  0
         String args;
 123   
 
 124  0
         if (beaHome == null) {
 125  0
             args = serverURL + " SHUTDOWN " + username + " " + password + " " + delay;
 126   
         } else {
 127  0
             args = " -url " + serverURL +
 128   
                     " -username " + username +
 129   
                     " -password " + password +
 130   
                     " SHUTDOWN " + " " + delay;
 131   
         }
 132   
 
 133  0
         weblogicAdmin.createArg().setLine(args);
 134  0
         weblogicAdmin.setClasspath(classpath);
 135  0
         weblogicAdmin.execute();
 136   
     }
 137   
 
 138   
     /**
 139   
      * The classpath to be used with the Java Virtual Machine that runs the Weblogic
 140   
      * Shutdown command;
 141   
      *
 142   
      * @param path the classpath to use when executing the weblogic admin task.
 143   
      */
 144  0
     public void setClasspath(Path path) {
 145  0
         this.classpath = path;
 146   
     }
 147   
 
 148   
     /**
 149   
      * The classpath to be used with the Java Virtual Machine that runs the Weblogic
 150   
      * Shutdown command;
 151   
      */
 152  0
     public Path createClasspath() {
 153  0
         if (classpath == null) {
 154  0
             classpath = new Path(getProject());
 155   
         }
 156  0
         return classpath.createPath();
 157   
     }
 158   
 
 159   
     /**
 160   
      * The username of the account which will be used to shutdown the server;
 161   
      * required.
 162   
      *
 163   
      * @param s the username.
 164   
      */
 165  0
     public void setUser(String s) {
 166  0
         this.username = s;
 167   
     }
 168   
 
 169   
     /**
 170   
      * The password for the account specified in the
 171   
      * user parameter; required
 172   
      *
 173   
      * @param s the password.
 174   
      */
 175  0
     public void setPassword(String s) {
 176  0
         this.password = s;
 177   
     }
 178   
 
 179   
     /**
 180   
      * Set the URL to which the weblogic server is listening
 181   
      * for T3 connections; required.
 182   
      *
 183   
      * @param s the url.
 184   
      */
 185  0
     public void setUrl(String s) {
 186  0
         this.serverURL = s;
 187   
     }
 188   
 
 189   
 
 190   
     /**
 191   
      * Set the delay (in seconds) before shutting down the server;
 192   
      * optional.
 193   
      *
 194   
      * @param s the selay.
 195   
      */
 196  0
     public void setDelay(String s) {
 197  0
         delay = Integer.parseInt(s);
 198   
     }
 199   
 
 200   
     /**
 201   
      * The location of the BEA Home; implicitly
 202   
      * selects Weblogic 6.0 shutdown; optional.
 203   
      *
 204   
      * @param beaHome the BEA Home directory.
 205   
      *
 206   
      */
 207  0
     public void setBEAHome(File beaHome) {
 208  0
         this.beaHome = beaHome;
 209   
     }
 210   
 
 211   
 }
 212