/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2006-2011 Bull S.A.S.
 * Contact: jonas-team@ow2.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */
package org.ow2.jonas.antmodular.jonasbase.web.tomcat6;

import org.ow2.jonas.antmodular.web.base.Cluster;
import org.ow2.jonas.antmodular.jonasbase.web.tomcat.Tomcat;

/**
 * Support Tomcat Connector Configuration.
 * Prefered order : http, director, ajp, https, cluster.
 *
 * @author Jeremy Cazaux
 */
public class Tomcat6 extends Tomcat {

    /**
     * Name of the tomcat file
    */
    public static final String TOMCAT_CONF_FILE = "tomcat6-server.xml";

    /**
     * Name of the implementation class for Tomcat.
     */
    private static final String TOMCAT_SERVICE = "org.ow2.jonas.web.tomcat6.Tomcat6Service";

    /**
     * Default Constructor.
     */
    public Tomcat6() {
        super();
    }

    /**
     * Set the port number for the WebContainer
     * @param portNumber the port number
     */
    @Override
    public void setPort(String portNumber) {
        super.setPort(portNumber, TOMCAT_CONF_FILE, "tomcat");
    }

    /**
     * Configure Tomcat6's connectors
     * @param tomcat6Connectors
     */
    public void addConfiguredConnectors(final Tomcat6Connectors tomcat6Connectors) {
        addTasks(tomcat6Connectors);
    }

    /**
     * Configure a Cluster HTTP Session.
     * @param cluster Cluster HTTP Session.
     */
    public void addConfiguredCluster(final Cluster cluster) {
        super.addConfiguredCluster(cluster, Tomcat6.TOMCAT_CONF_FILE);
    }

    /**
     * Configure a jvmRoute.
     * @param jvmRoute jvm route name
     */
    public void setJvmRoute(final String jvmRoute) {
        super.setJvmRoute(jvmRoute, Tomcat6.TOMCAT_CONF_FILE);
    }

    /**
     * Execute all tasks
     */
    @Override
    public void execute() {
        super.execute();
        super.createServiceNameReplace(this.TOMCAT_SERVICE, this.INFO, destDir.getAbsolutePath() + this.CONF_DIR);
    }
}
