001/* 002 * (C) Copyright 2010-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Julien Carsique 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.launcher; 023 024import java.io.File; 025import java.util.ArrayList; 026import java.util.Collection; 027import java.util.List; 028 029import org.nuxeo.launcher.config.ConfigurationGenerator; 030import org.nuxeo.launcher.config.TomcatConfigurator; 031 032/** 033 * Main Nuxeo server thread 034 * 035 * @author jcarsique 036 * @since 5.4.2 037 */ 038public class NuxeoTomcatLauncher extends NuxeoLauncher { 039 040 /** 041 * @param configurationGenerator 042 */ 043 public NuxeoTomcatLauncher(ConfigurationGenerator configurationGenerator) { 044 super(configurationGenerator); 045 } 046 047 @Override 048 protected Collection<? extends String> getServerProperties() { 049 ArrayList<String> serverProperties = new ArrayList<>(); 050 serverProperties.add("-Djava.util.logging.manager=" + "org.apache.juli.ClassLoaderLogManager"); 051 File home = configurationGenerator.getNuxeoHome(); 052 File endorsed = new File(home, "endorsed"); 053 serverProperties.add("-Dcatalina.base=" + home.getPath()); 054 serverProperties.add("-Dcatalina.home=" + home.getPath()); 055 serverProperties.add("-Djava.endorsed.dirs=" + endorsed.getPath()); 056 return serverProperties; 057 } 058 059 @Override 060 protected String getClassPath() { 061 String cp = "."; 062 cp = addToClassPath(cp, "nxserver" + File.separator + "lib"); 063 cp = addToClassPath(cp, "bin" + File.separator + "bootstrap.jar"); 064 // Tomcat 7 needs tomcat-juli.jar for bootstrap as well 065 cp = addToClassPath(cp, "bin" + File.separator + "tomcat-juli.jar"); 066 return cp; 067 } 068 069 @Override 070 protected void setServerStartCommand(List<String> command) { 071 command.add(TomcatConfigurator.STARTUP_CLASS); 072 command.add("start"); 073 } 074 075 @Override 076 protected void setServerStopCommand(List<String> command) { 077 command.add(TomcatConfigurator.STARTUP_CLASS); 078 command.add("stop"); 079 } 080 081 @Override 082 protected String getServerPrint() { 083 return TomcatConfigurator.STARTUP_CLASS; 084 } 085 086 @Override 087 protected String getShutdownClassPath() { 088 return getClassPath(); 089 } 090}