org.ow2.jonas.ant.jonasbase.web.Tomcat Maven / Gradle / Ivy
/**
* JOnAS: Java(TM) Open Application Server
* Copyright (C) 2006-2008 Bull S.A.S.
* Contact: [email protected]
*
* 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: Tomcat.java 15428 2008-10-07 11:20:29Z sauthieg $
* --------------------------------------------------------------------------
*/
package org.ow2.jonas.ant.jonasbase.web;
import org.ow2.jonas.ant.JOnASBaseTask;
import org.ow2.jonas.ant.jonasbase.JReplace;
import org.ow2.jonas.ant.jonasbase.Tasks;
/**
* Support Tomcat Connector Configuration.
* Prefered order : http, director, ajp, https, cluster.
*
* @author Guillaume Sauthier
*/
public class Tomcat extends Tasks {
/**
* Info for the logger.
*/
private static final String INFO = "[Tomcat] ";
/**
* Tomcat AJP Connector token.
*/
private static final String AJP_CONNECTOR_TOKEN = "\n");
value.append(" \n\n");
value.append(" " + HTTPS_CONNECTOR_TOKEN);
propertyReplace.setValue(value.toString());
propertyReplace.setLogInfo(INFO + "Setting HTTPS Connector to : " + https.getPort());
addTask(propertyReplace);
// Replace redirect port value in HTTP Connector
propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken(" redirectPort=\"" + Https.DEFAULT_PORT + "\" ");
propertyReplace.setValue(" redirectPort=\"" + https.getPort() + "\" ");
propertyReplace.setLogInfo(INFO + "Fix HTTP redirect port number to : " + https.getPort());
addTask(propertyReplace);
}
/**
* Configure an AJP Connector.
* @param ajp AJP Configuration.
*/
public void addConfiguredAjp(final Ajp ajp) {
JReplace propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken(AJP_CONNECTOR_TOKEN);
StringBuffer value = new StringBuffer();
value.append(" \n");
value.append(" \n\n");
value.append(" " + AJP_CONNECTOR_TOKEN);
propertyReplace.setValue(value.toString());
propertyReplace.setLogInfo(INFO + "Setting AJP Connector to : " + ajp.getPort());
addTask(propertyReplace);
}
/**
* Configure a jvmRoute.
* @param jvmRoute jvm route name
*/
public void setJvmRoute(final String jvmRoute) {
JReplace propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken(JVM_ROUTE_TOKEN);
StringBuffer value = new StringBuffer();
value.append("");
propertyReplace.setValue(value.toString());
propertyReplace.setLogInfo(INFO + "Setting the jvmRoute to : " + jvmRoute);
addTask(propertyReplace);
}
/**
* Configure a Director Connector.
* @param dir Director Configuration.
*/
public void addConfiguredDirector(final Director dir) {
JReplace propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken(DIRECTOR_CONNECTOR_TOKEN);
StringBuffer value = new StringBuffer();
value.append("\n");
value.append(" \n\n");
value.append(" " + DIRECTOR_CONNECTOR_TOKEN);
propertyReplace.setValue(value.toString());
propertyReplace.setLogInfo(INFO + "Setting Director Connector to : " + dir.getPort());
addTask(propertyReplace);
}
/**
* Configure a Cluster HTTP Session.
* @param cluster Cluster HTTP Session.
*/
public void addConfiguredCluster(final Cluster cluster) {
// General Cluster configuration
setCluster();
// Cluster name
JReplace propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken(Cluster.DEFAULT_CLUSTER_NAME);
propertyReplace.setValue(cluster.getName());
propertyReplace.setLogInfo(INFO + "Setting Cluster name : " + cluster.getName());
addTask(propertyReplace);
// Cluster listening port
propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken(Cluster.DEFAULT_LISTEN_PORT);
propertyReplace.setValue(cluster.getListenPort());
propertyReplace.setLogInfo(INFO + "Setting Cluster listen port : " + cluster.getListenPort());
addTask(propertyReplace);
// Cluster Multicast Address
propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken(Cluster.DEFAULT_MCAST_ADDR);
propertyReplace.setValue(cluster.getMcastAddr());
propertyReplace.setLogInfo(INFO + "Setting Cluster multicast addr : " + cluster.getMcastAddr());
addTask(propertyReplace);
// Cluster Multicast Port
propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken(Cluster.DEFAULT_MCAST_PORT);
propertyReplace.setValue(cluster.getMcastPort());
propertyReplace.setLogInfo(INFO + "Setting Cluster multicast port : " + cluster.getMcastPort());
addTask(propertyReplace);
}
/**
* Enable the cluster feature.
*/
private void setCluster() {
JReplace propertyReplace = new JReplace();
propertyReplace.setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
propertyReplace.setToken("");
StringBuffer value = new StringBuffer("\n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" \n");
// " " +"\n" +
value.append(" \n");
value.append(" \n");
value.append(" \n");
value.append(" ");
propertyReplace.setValue(value.toString());
propertyReplace.setLogInfo(INFO + "Setting Cluster");
addTask(propertyReplace);
}
/**
* @return Returns true
if HTTP is configured.
*/
public boolean isHttpConfigured() {
return httpConfigured;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy