001/* 002 * (C) Copyright 2010-2011 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Julien Carsique 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.launcher; 021 022import java.io.File; 023import java.util.ArrayList; 024import java.util.Collection; 025import java.util.List; 026 027import org.nuxeo.launcher.config.ConfigurationGenerator; 028import org.nuxeo.launcher.config.TomcatConfigurator; 029 030/** 031 * Main Nuxeo server thread 032 * 033 * @author jcarsique 034 * @since 5.4.2 035 */ 036public class NuxeoTomcatLauncher extends NuxeoLauncher { 037 038 /** 039 * @param configurationGenerator 040 */ 041 public NuxeoTomcatLauncher(ConfigurationGenerator configurationGenerator) { 042 super(configurationGenerator); 043 } 044 045 @Override 046 protected Collection<? extends String> getServerProperties() { 047 ArrayList<String> serverProperties = new ArrayList<>(); 048 serverProperties.add("-Djava.util.logging.manager=" + "org.apache.juli.ClassLoaderLogManager"); 049 File home = configurationGenerator.getNuxeoHome(); 050 File endorsed = new File(home, "endorsed"); 051 serverProperties.add("-Dcatalina.base=" + home.getPath()); 052 serverProperties.add("-Dcatalina.home=" + home.getPath()); 053 serverProperties.add("-Djava.endorsed.dirs=" + endorsed.getPath()); 054 return serverProperties; 055 } 056 057 @Override 058 protected String getClassPath() { 059 String cp = "."; 060 cp = addToClassPath(cp, "nxserver" + File.separator + "lib"); 061 cp = addToClassPath(cp, "bin" + File.separator + "bootstrap.jar"); 062 // Tomcat 7 needs tomcat-juli.jar for bootstrap as well 063 cp = addToClassPath(cp, "bin" + File.separator + "tomcat-juli.jar"); 064 return cp; 065 } 066 067 @Override 068 protected void setServerStartCommand(List<String> command) { 069 command.add(TomcatConfigurator.STARTUP_CLASS); 070 command.add("start"); 071 } 072 073 @Override 074 protected void setServerStopCommand(List<String> command) { 075 command.add(TomcatConfigurator.STARTUP_CLASS); 076 command.add("stop"); 077 } 078 079 @Override 080 protected String getServerPrint() { 081 return TomcatConfigurator.STARTUP_CLASS; 082 } 083 084 @Override 085 protected String getShutdownClassPath() { 086 return getClassPath(); 087 } 088}