/*
 * JBoss, Home of Professional Open Source
 * 
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.ant.taskdefs.server;

import java.io.IOException;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.jboss.test.util.server.ServerManager;

/**
 * A StopServerTask.
 * 
 * @author <a href="ryan.campbell@jboss.com">Ryan Campbell</a>
 * @version $Revision: 1.1.4.2 $
 */
public class StopServerTask extends Task
{

   private String name;

   /**
    * Stop the server.
    */

   public void execute() throws BuildException
   {
      ServerManager manager = (ServerManager) getProject().getReference(ConfigManagerTask.MANAGER_REF);
      try
      {
         manager.stopServer(name);
      }
      catch (IOException e)
      {
         throw new BuildException("Error starting server \"" + name + "\": " + e.toString(), e);
      }
   }

   /**
    * Set the name.
    * 
    * @param name The name to set.
    */
   public void setName(String name)
   {
      this.name = name;
   }
}