larryi 01/03/25 13:53:18
Modified: src/share/org/apache/tomcat/core ContextManager.java
src/share/org/apache/tomcat/modules/config PathSetter.java
src/share/org/apache/tomcat/startup Main.java
StopTomcat.java Tomcat.java
src/share/org/apache/tomcat/util IntrospectionUtils.java
Log:
Allow separate "home" and "install" directories by specifying both, "home"
using the "tomcat.home" System property and "install" using the
"tomcat.install" System property. If either is not specified, it defaults to the
other. Classloader construction now uses "install" to find the "lib" jars.
Revision Changes Path
1.175 +5 -1
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
Index: ContextManager.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -r1.174 -r1.175
--- ContextManager.java 2001/03/14 03:45:17 1.174
+++ ContextManager.java 2001/03/25 21:53:13 1.175
@@ -153,9 +153,13 @@
/** System property used to set the base directory ( tomcat home ).
* use -DTOMCAT_HOME= in java command line or as a System.setProperty.
- * XXX hack - setHome is better
*/
public static final String TOMCAT_HOME="tomcat.home";
+
+ /** System property used to set the install directory ( tomcat install ).
+ * use -DTOMCAT_INSTALL= in java command line or as a System.setProperty.
+ */
+ public static final String TOMCAT_INSTALL="tomcat.install";
// State
1.6 +20 -12
jakarta-tomcat/src/share/org/apache/tomcat/modules/config/PathSetter.java
Index: PathSetter.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/PathSetter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PathSetter.java 2001/02/20 03:16:51 1.5
+++ PathSetter.java 2001/03/25 21:53:14 1.6
@@ -113,23 +113,30 @@
home=System.getProperty(ContextManager.TOMCAT_HOME);
}
+ // if "home" is not set, guess "install" and use as "home"
if( home==null ) {
- home=IntrospectionUtils.guessHome( "tomcat.home",
- "tomcat_core.jar",
- "org/apache/tomcat/core/Request.class");
+ home=IntrospectionUtils.guessInstall(
+ ContextManager.TOMCAT_INSTALL,
+ ContextManager.TOMCAT_HOME,
+ "tomcat_core.jar",
+ "org/apache/tomcat/core/Request.class");
}
- if (home == null) {
- System.out.println(sm.getString("tomcat.nohome"));
- home = ".";
- // Assume current working directory
+ if (home != null) {
+ // Make it absolute
+ home=FileUtil.getCanonicalPath( home );
+ cm.setHome( home );
}
-
- // Make it absolute
- home=FileUtil.getCanonicalPath( home );
- cm.setHome( home );
String installDir=cm.getInstallDir();
+ // if "install" is not set, guess "install" if not already guessed
+ if ( installDir==null ) {
+ installDir=IntrospectionUtils.guessInstall(
+ ContextManager.TOMCAT_INSTALL,
+ ContextManager.TOMCAT_HOME,
+ "tomcat_core.jar",
+ "org/apache/tomcat/core/Request.class");
+ }
if( installDir!= null ) {
installDir=FileUtil.getCanonicalPath( installDir );
cm.setInstallDir( installDir );
@@ -157,7 +164,8 @@
cm.setInstallDir( home );
}
- System.getProperties().put("tomcat.home", cm.getHome());
+ System.getProperties().put(ContextManager.TOMCAT_HOME, cm.getHome());
+ System.getProperties().put(ContextManager.TOMCAT_INSTALL, cm.getInstallDir());
}
/** After server.xml is read - make sure the workDir is absolute,
1.31 +13 -9 jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- Main.java 2001/03/06 05:25:14 1.30
+++ Main.java 2001/03/25 21:53:15 1.31
@@ -1,4 +1,4 @@
-/* $Id: Main.java,v 1.30 2001/03/06 05:25:14 larryi Exp $
+/* $Id: Main.java,v 1.31 2001/03/25 21:53:15 larryi Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
@@ -107,7 +107,7 @@
@author Costin Manolache
@author Ignacio J. Ortega
@author Mel Martinez [EMAIL PROTECTED]
- @version $Revision: 1.30 $ $Date: 2001/03/06 05:25:14 $
+ @version $Revision: 1.31 $ $Date: 2001/03/25 21:53:15 $
*/
public class Main{
@@ -231,8 +231,8 @@
if( libBase!=null ){
return libBase;
}
- if( homeDir!=null ){
- libBase=checkDir( homeDir + "/lib/container");
+ if( installDir!=null ){
+ libBase=checkDir( installDir + "/lib/container");
}else{
libBase=checkDir("./lib/container");
}
@@ -243,8 +243,8 @@
if( serverBase!=null ){
return serverBase;
}
- if( homeDir!=null ){
- serverBase=checkDir( homeDir + "/lib/apps");
+ if( installDir!=null ){
+ serverBase=checkDir( installDir + "/lib/apps");
}else{
serverBase=checkDir("./lib/apps");
}
@@ -255,8 +255,8 @@
if( commonBase!=null ){
return commonBase;
}
- if( homeDir!=null ){
- commonBase=checkDir( homeDir + "/lib/common");
+ if( installDir!=null ){
+ commonBase=checkDir( installDir + "/lib/common");
}else{
commonBase=checkDir("./lib/common");
}
@@ -269,8 +269,11 @@
protected void execute( String args[] ) throws Exception {
try {
- homeDir=IntrospectionUtils.guessHome("tomcat.home", "tomcat.jar");
+ installDir=IntrospectionUtils.guessInstall("tomcat.install",
+ "tomcat.home", "tomcat.jar");
+ homeDir = System.getProperty("tomcat.home");
+
ClassLoader parentL=this.getClass().getClassLoader();
// the server classloader loads from classes dir too and from tools.jar
@@ -318,6 +321,7 @@
IntrospectionUtils.setAttribute(proxy,"args", args );
IntrospectionUtils.setAttribute(proxy,"home", homeDir );
+ IntrospectionUtils.setAttribute(proxy,"install", installDir );
IntrospectionUtils.setAttribute(proxy,"parentClassLoader",appsCl);
IntrospectionUtils.execute( proxy, "execute" );
return;
1.6 +6 -3
jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java
Index: StopTomcat.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/StopTomcat.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StopTomcat.java 2001/02/20 03:17:57 1.5
+++ StopTomcat.java 2001/03/25 21:53:16 1.6
@@ -178,9 +178,11 @@
}
public String getTomcatHome() {
+ // Try to establish install and home locations
+ String tchome=IntrospectionUtils.guessInstall("tomcat.install",
+ "tomcat.home","stop-tomcat.jar");
// Use the "tomcat.home" property to resolve the default filename
- String tchome=IntrospectionUtils.guessHome("tomcat.home",
- "stop-tomcat.jar");
+ tchome = System.getProperty("tomcat.home");
if (tchome == null) {
System.out.println(sm.getString("tomcat.nohome"));
tchome = ".";
@@ -248,7 +250,8 @@
if (arg.equals("-h") || arg.equals("-home")) {
i++;
if (i < args.length)
- System.getProperties().put("tomcat.home", args[i]);
+ System.getProperties().put("tomcat.home",
+ args[i]);
else
return false;
}
1.60 +17 -1 jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java
Index: Tomcat.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Tomcat.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- Tomcat.java 2001/03/15 07:33:19 1.59
+++ Tomcat.java 2001/03/25 21:53:16 1.60
@@ -29,6 +29,7 @@
private String action="start";
String home=null;
+ String install=null;
String args[];
ClassLoader parentClassLoader;
boolean sandbox=false;
@@ -48,6 +49,10 @@
this.home=home;
}
+ public void setInstall(String install) {
+ this.install=install;
+ }
+
public void setArgs(String args[]) {
this.args=args;
}
@@ -161,6 +166,7 @@
System.out.println(" -config file (or -f file) Use this fileinstead of
server.xml");
System.out.println(" -help (or help) Show this usage report");
System.out.println(" -home dir (or -h dir) Use this directory as
tomcat.home");
+ System.out.println(" -install dir (or -i dir) Use this directory as
tomcat.install");
System.out.println(" -stop Shut down currently running
Tomcat");
}
@@ -191,8 +197,16 @@
return false;
} else if (arg.equals("-h") || arg.equals("-home")) {
i++;
+ if (i < args.length)
+ System.getProperties().put(
+ ContextManager.TOMCAT_HOME, args[i]);
+ else
+ return false;
+ } else if (arg.equals("-i") || arg.equals("-install")) {
+ i++;
if (i < args.length)
- System.getProperties().put("tomcat.home", args[i]);
+ System.getProperties().put(
+ ContextManager.TOMCAT_INSTALL, args[i]);
else
return false;
}
@@ -204,6 +218,8 @@
public void setAttribute(String s,Object o) {
if( "home".equals( s ) )
setHome( (String)o);
+ if( "install".equals( s ) )
+ setInstall( (String)o);
else if("args".equals( s ) )
setArgs((String[])o);
else if( "parentClassLoader".equals( s ) ) {
1.7 +45 -22
jakarta-tomcat/src/share/org/apache/tomcat/util/IntrospectionUtils.java
Index: IntrospectionUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/IntrospectionUtils.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- IntrospectionUtils.java 2001/03/08 01:06:00 1.6
+++ IntrospectionUtils.java 2001/03/25 21:53:17 1.7
@@ -135,23 +135,42 @@
}
- public static String guessHome(String systemProperty, String jarName) {
- return guessHome( systemProperty, jarName, null);
+ public static String guessInstall(String installSysProp,
+ String homeSysProp, String jarName) {
+ return guessInstall( installSysProp, homeSysProp, jarName, null);
}
- /** Guess a product home by analyzing the class path.
+ /** Guess a product install/home by analyzing the class path.
* It works for product using the pattern: lib/executable.jar
* or if executable.jar is included in classpath by a shell
* script. ( java -jar also works )
+ *
+ * Insures both "install" and "home" System properties are set.
+ * If either or both System properties are unset, "install" and
+ * "home" will be set to the same value. This value will be
+ * the other System property that is set, or the guessed value
+ * if neither is set.
*/
- public static String guessHome(String systemProperty, String jarName,
- String classFile) {
- String h=null;
+ public static String guessInstall(String installSysProp, String homeSysProp,
+ String jarName, String classFile) {
+ String install=null;
+ String home=null;
- if( systemProperty != null )
- h=System.getProperty( systemProperty );
-
- if( h!=null ) return h;
+ if ( installSysProp != null )
+ install=System.getProperty( installSysProp );
+
+ if( homeSysProp != null )
+ home=System.getProperty( homeSysProp );
+
+ if ( install != null ) {
+ if ( home == null )
+ System.getProperties().put( homeSysProp, install );
+ return install;
+ }
+ if ( home != null ) {
+ System.setProperty( installSysProp, home );
+ return home;
+ }
// Find the directory where jarName.jar is located
@@ -162,14 +181,16 @@
String path=st.nextToken();
// log( "path " + path );
if( path.endsWith( jarName ) ) {
- h=path.substring( 0, path.length() - jarName.length() );
+ home=path.substring( 0, path.length() - jarName.length() );
try {
- File f=new File( h );
- File f1=new File ( h, "..");
- h = f1.getCanonicalPath();
- if( systemProperty != null )
- System.getProperties().put( systemProperty, h );
- return h;
+ File f=new File( home );
+ File f1=new File ( f, "..");
+ install = f1.getCanonicalPath();
+ if( installSysProp != null )
+ System.getProperties().put( installSysProp, install );
+ if( homeSysProp != null )
+ System.getProperties().put( homeSysProp, install );
+ return install;
} catch( Exception ex ) {
ex.printStackTrace();
}
@@ -178,11 +199,13 @@
if( new File( fname ).exists()) {
try {
File f=new File( path );
- File f1=new File ( h, "..");
- h = f1.getCanonicalPath();
- if( systemProperty != null )
- System.getProperties().put( systemProperty, h );
- return h;
+ File f1=new File ( f, "..");
+ install = f1.getCanonicalPath();
+ if( installSysProp != null )
+ System.getProperties().put( installSysProp, install );
+ if( homeSysProp != null )
+ System.getProperties().put( homeSysProp, install );
+ return install;
} catch( Exception ex ) {
ex.printStackTrace();
}