001/* 002 * (C) Copyright 2006-2008 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 * bstefanescu 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.runtime.tomcat; 021 022import java.io.File; 023import java.lang.reflect.Method; 024 025import org.apache.catalina.Container; 026import org.apache.catalina.core.StandardContext; 027import org.apache.catalina.loader.WebappLoader; 028 029/** 030 * Shared attribute is experimental. Do not use it yet. 031 * <p> 032 * (Its purpose is to be able to deploy multiple WARs using the same nuxeo instance but it is not working yet). 033 * 034 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 035 */ 036public class NuxeoWebappLoader extends WebappLoader { 037 038 protected File baseDir; // the baseDir from the Context (which is private..) 039 040 protected void overwriteWar() { 041 // File baseDir = getBaseDir(); 042 // remove all files 043 } 044 045 public File getBaseDir() throws ReflectiveOperationException { 046 if (baseDir == null) { 047 Container container = getContainer(); 048 Method method = StandardContext.class.getDeclaredMethod("getBasePath"); 049 method.setAccessible(true); 050 String path = (String) method.invoke(container); 051 baseDir = new File(path); 052 } 053 return baseDir; 054 } 055 056}