You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2002/08/10 18:54:15 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup CatalinaService.java
costin 2002/08/10 09:54:15
Modified: catalina/src/share/org/apache/catalina/startup
CatalinaService.java
Log:
Add the setters and execute that allows it to be used as an ant task. See build2.xml
as an example.
The attributes are not 'final' - I just wanted to get it working.
Things seem to be fine ( as long as all jars are included in the PATH ).
I'll work on a mechanism to start it using the loader hierarchy after
Bootstrap cleanups.
Revision Changes Path
1.2 +59 -29 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/CatalinaService.java
Index: CatalinaService.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/CatalinaService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CatalinaService.java 18 Jul 2002 16:47:47 -0000 1.1
+++ CatalinaService.java 10 Aug 2002 16:54:15 -0000 1.2
@@ -108,8 +108,8 @@
// ----------------------------------------------------- Instance Variables
-
-
+ private String action="start";
+ private boolean doWait=false;
// ------------------------------------------------------ Protected Methods
@@ -158,12 +158,44 @@
}
+ public void setHome( String s ) {
+ System.setProperty("catalina.home", s );
+ System.setProperty("catalina.base", s );
+ }
+
+ public void setUseNaming( boolean b ) {
+ useNaming=b;
+ }
+
+ public void setConfig( String file ) {
+ configFile=file;
+ }
+
+ public void setDo( String action ) {
+ if (action.equals("start")) {
+ starting = true;
+ stopping = false;
+ } else if (action.equals("stop")) {
+ starting = false;
+ stopping = true;
+ }
+ }
+ public void setWait( boolean b ) {
+ doWait=b;
+ }
+
+ public void setCompiler( String s ) {
+ System.setProperty( "build.compiler" , s );
+ }
+
/**
* Execute the processing that has been configured from the command line.
*/
- protected void execute() throws Exception {
-
+ public void execute() throws Exception {
+ // make sure the thread loader is set
+ log.info("Running tomcat5");
+ Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader());
if (starting) {
load();
start();
@@ -171,6 +203,10 @@
stop();
}
+ if( doWait ) {
+ server.await();
+ }
+
}
@@ -186,9 +222,8 @@
digester.push(this);
digester.parse(file);
} catch (Exception e) {
- System.out.println("Catalina.start: " + e);
- e.printStackTrace(System.out);
- System.exit(1);
+ log.error("Catalina.start", e);
+ return;
}
// Setting additional variables
@@ -233,12 +268,7 @@
try {
server.initialize();
} catch (LifecycleException e) {
- System.out.println("Catalina.start: " + e);
- e.printStackTrace(System.out);
- if (e.getThrowable() != null) {
- System.out.println("----- Root Cause -----");
- e.getThrowable().printStackTrace(System.out);
- }
+ log.error("Catalina.start", e);
}
}
@@ -270,15 +300,18 @@
try {
((Lifecycle) server).start();
} catch (LifecycleException e) {
- System.out.println("Catalina.start: " + e);
- e.printStackTrace(System.out);
- if (e.getThrowable() != null) {
- System.out.println("----- Root Cause -----");
- e.getThrowable().printStackTrace(System.out);
- }
+ log.error("Catalina.start: ", e);
}
}
+ Thread shutdownHook = new CatalinaShutdownHook();
+ try {
+ // Register shutdown hook
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ } catch (Throwable t) {
+ // This will fail on JDK 1.2. Ignoring, as Tomcat can run
+ // fine without the shutdown hook.
+ }
}
@@ -292,16 +325,13 @@
try {
((Lifecycle) server).stop();
} catch (LifecycleException e) {
- System.out.println("Catalina.stop: " + e);
- e.printStackTrace(System.out);
- if (e.getThrowable() != null) {
- System.out.println("----- Root Cause -----");
- e.getThrowable().printStackTrace(System.out);
- }
+ log.error("Catalina.stop", e);
}
}
}
+ private static org.apache.commons.logging.Log log=
+ org.apache.commons.logging.LogFactory.getLog( CatalinaService.class );
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>