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

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

/**
 * A ConfigManagerTask.  Delegates to the Server manager.
 * 
 * @author <a href="ryan.campbell@jboss.com">Ryan Campbell</a>
 * @version $Revision: 1.1.4.3 $
 */
public class ConfigManagerTask extends Task
{
   /** The key for the project reference **/
   protected static final String MANAGER_REF = "serverManager";

   ServerManager manager = null;

   /**
    * Create a new ConfigManagerTask.
    * 
    * 
    */
   public ConfigManagerTask()
   {
       manager = new ServerManager();
   }
   
   /**
    * Create a server manager using the specified configuration.
    */
   public void execute() throws BuildException
   {
      if (getProject().getReference(MANAGER_REF) == null)
      {
         getProject().addReference(MANAGER_REF, manager);   
      }
   }

   /**
    * Add a server.
    */
   public void addServer(Server server)
   {
      manager.addServer(server);
   }

   /** 
    * JAVA_HOME to start jboss with.
    * @param javaHome
    */
   public void setJavaHome(String javaHome)
   {
      manager.setJavaHome(javaHome);
   }

   /**
    * JBoss dist to start.
    * @param jbossHome
    */
   public void setJbossHome(String jbossHome)
   {
      manager.setJbossHome(jbossHome);
   }

   /**
    * JVM command to use default is "java"
    * @param jvm
    */
   public void setJvm(String jvm)
   {
      manager.setJvm(jvm);
   }
   
   /**
    * The UDP group to pass to org.jboss.Main using
    * the -u option.
    */
   public void setUdpGroup(String udpGroup)
   {
      manager.setUdpGroup(udpGroup);
   }
}