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/11/05 22:31:14 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ContainerBase.java
costin 2002/11/05 13:31:14
Modified: catalina/src/share/org/apache/catalina/core
ContainerBase.java
Log:
Prevent stoping apps that are not started ( and the
associated traces )
Revision Changes Path
1.2 +40 -34 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ContainerBase.java
Index: ContainerBase.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ContainerBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContainerBase.java 18 Jul 2002 16:48:12 -0000 1.1
+++ ContainerBase.java 5 Nov 2002 21:31:14 -0000 1.2
@@ -381,7 +381,7 @@
try {
((Lifecycle) oldLoader).stop();
} catch (LifecycleException e) {
- log("ContainerBase.setLoader: stop: ", e);
+ log.error("ContainerBase.setLoader: stop: ", e);
}
}
@@ -393,7 +393,7 @@
try {
((Lifecycle) loader).start();
} catch (LifecycleException e) {
- log("ContainerBase.setLoader: start: ", e);
+ log.error("ContainerBase.setLoader: start: ", e);
}
}
@@ -438,7 +438,7 @@
try {
((Lifecycle) oldLogger).stop();
} catch (LifecycleException e) {
- log("ContainerBase.setLogger: stop: ", e);
+ log.error("ContainerBase.setLogger: stop: ", e);
}
}
@@ -450,7 +450,7 @@
try {
((Lifecycle) logger).start();
} catch (LifecycleException e) {
- log("ContainerBase.setLogger: start: ", e);
+ log.error("ContainerBase.setLogger: start: ", e);
}
}
@@ -495,7 +495,7 @@
try {
((Lifecycle) oldManager).stop();
} catch (LifecycleException e) {
- log("ContainerBase.setManager: stop: ", e);
+ log.error("ContainerBase.setManager: stop: ", e);
}
}
@@ -507,7 +507,7 @@
try {
((Lifecycle) manager).start();
} catch (LifecycleException e) {
- log("ContainerBase.setManager: start: ", e);
+ log.error("ContainerBase.setManager: start: ", e);
}
}
@@ -535,7 +535,7 @@
/**
* Set the Cluster with which this Container is associated.
*
- * @param manager The newly associated Cluster
+ * @param cluster The newly associated Cluster
*/
public synchronized void setCluster(Cluster cluster) {
// Change components if necessary
@@ -550,7 +550,7 @@
try {
((Lifecycle) oldCluster).stop();
} catch (LifecycleException e) {
- log("ContainerBase.setCluster: stop: ", e);
+ log.error("ContainerBase.setCluster: stop: ", e);
}
}
@@ -563,7 +563,7 @@
try {
((Lifecycle) cluster).start();
} catch (LifecycleException e) {
- log("ContainerBase.setCluster: start: ", e);
+ log.error("ContainerBase.setCluster: start: ", e);
}
}
@@ -641,11 +641,11 @@
* been configured.
*/
public ClassLoader getParentClassLoader() {
-
if (parentClassLoader != null)
return (parentClassLoader);
- if (parent != null)
+ if (parent != null) {
return (parent.getParentClassLoader());
+ }
return (ClassLoader.getSystemClassLoader());
}
@@ -661,7 +661,6 @@
* @param parent The new parent class loader
*/
public void setParentClassLoader(ClassLoader parent) {
-
ClassLoader oldParentClassLoader = this.parentClassLoader;
this.parentClassLoader = parent;
support.firePropertyChange("parentClassLoader", oldParentClassLoader,
@@ -716,7 +715,7 @@
try {
((Lifecycle) oldRealm).stop();
} catch (LifecycleException e) {
- log("ContainerBase.setRealm: stop: ", e);
+ log.error("ContainerBase.setRealm: stop: ", e);
}
}
@@ -728,7 +727,7 @@
try {
((Lifecycle) realm).start();
} catch (LifecycleException e) {
- log("ContainerBase.setRealm: start: ", e);
+ log.error("ContainerBase.setRealm: start: ", e);
}
}
@@ -745,7 +744,6 @@
* return <code>null</code>.
*/
public DirContext getResources() {
-
if (resources != null)
return (resources);
if (parent != null)
@@ -762,6 +760,9 @@
* @param resources The newly associated DirContext
*/
public synchronized void setResources(DirContext resources) {
+ // Called from StandardContext.setResources()
+ // <- StandardContext.start()
+ // <- ContainerBase.addChildInternal()
// Change components if necessary
DirContext oldResources = this.resources;
@@ -820,7 +821,7 @@
try {
((Lifecycle) child).start();
} catch (LifecycleException e) {
- log("ContainerBase.addChild: start: ", e);
+ log.error("ContainerBase.addChild: start: ", e);
throw new IllegalStateException
("ContainerBase.addChild: start: " + e);
}
@@ -866,7 +867,7 @@
try {
((Lifecycle) mapper).start();
} catch (LifecycleException e) {
- log("ContainerBase.addMapper: start: ", e);
+ log.error("ContainerBase.addMapper: start: ", e);
throw new IllegalStateException
("ContainerBase.addMapper: start: " + e);
}
@@ -1033,9 +1034,15 @@
}
if (started && (child instanceof Lifecycle)) {
try {
- ((Lifecycle) child).stop();
+ if( child instanceof ContainerBase ) {
+ if( ((ContainerBase)child).started ) {
+ ((Lifecycle) child).stop();
+ }
+ } else {
+ ((Lifecycle) child).stop();
+ }
} catch (LifecycleException e) {
- log("ContainerBase.removeChild: stop: ", e);
+ log.error("ContainerBase.removeChild: stop: ", e);
}
}
fireContainerEvent(REMOVE_CHILD_EVENT, child);
@@ -1074,7 +1081,7 @@
try {
((Lifecycle) mapper).stop();
} catch (LifecycleException e) {
- log("ContainerBase.removeMapper: stop: ", e);
+ log.error("ContainerBase.removeMapper: stop: ", e);
throw new IllegalStateException
("ContainerBase.removeMapper: stop: " + e);
}
@@ -1376,7 +1383,7 @@
mapper.setProtocol("http");
addMapper(mapper);
} catch (Exception e) {
- log(sm.getString("containerBase.addDefaultMapper", mapperClass),
+ log.error(sm.getString("containerBase.addDefaultMapper", mapperClass),
e);
}
@@ -1413,12 +1420,11 @@
*/
protected void log(String message) {
- Logger logger = getLogger();
- if (logger != null)
- logger.log(logName() + ": " + message);
- else
- System.out.println(logName() + ": " + message);
-
+// Logger logger = getLogger();
+// if (logger != null)
+// logger.log(logName() + ": " + message);
+// else
+ log.info(message);
}
@@ -1435,8 +1441,7 @@
if (logger != null)
logger.log(logName() + ": " + message, throwable);
else {
- System.out.println(logName() + ": " + message + ": " + throwable);
- throwable.printStackTrace(System.out);
+ log.error( message, throwable );
}
}
@@ -1455,6 +1460,7 @@
}
-
+ private static org.apache.commons.logging.Log log=
+ org.apache.commons.logging.LogFactory.getLog( ContainerBase.class );
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit:
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core
ContainerBase.java
Posted by Jon Scott Stevens <jo...@latchkey.com>.
on 2002/11/5 1:31 PM, "costin@apache.org" <co...@apache.org> wrote:
> protected void log(String message) {
>
> - Logger logger = getLogger();
> - if (logger != null)
> - logger.log(logName() + ": " + message);
> - else
> - System.out.println(logName() + ": " + message);
> -
> +// Logger logger = getLogger();
> +// if (logger != null)
> +// logger.log(logName() + ": " + message);
> +// else
> + log.info(message);
> }
What the heck is that? There are now two methods with the same name for
logging and one goes to info and the other goes to error based on the method
signature? Where is the logic in that?
And god forbid...maybe try formatting your code properly? The spaces are off
and you put the static log at the bottom of the file???
http://java.sun.com/docs/codeconv/html/CodeConventions.doc2.html#1852
-jon
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>