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 2003/03/21 07:38:47 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ContainerBase.java StandardContext.java
costin 2003/03/20 22:38:47
Modified: catalina/src/share/org/apache/catalina/core
ContainerBase.java StandardContext.java
Log:
More work on reloading.
It seems context can be stoped and started from the console, but when it
starts again I get 404s.
I suspect something related with the mapper. Remy - could you help me a bit ?
Revision Changes Path
1.13 +15 -24 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ContainerBase.java 20 Mar 2003 18:28:28 -0000 1.12
+++ ContainerBase.java 21 Mar 2003 06:38:47 -0000 1.13
@@ -309,6 +309,7 @@
*/
protected boolean started = false;
+ protected boolean initialized=false;
/**
* The property change support for this component.
@@ -828,6 +829,8 @@
private void addChildInternal(Container child) {
+ if( log.isDebugEnabled() )
+ log.debug("Add child " + child + " " + this);
synchronized(children) {
if (children.get(child.getName()) != null)
throw new IllegalArgumentException("addChild: Child name '" +
@@ -844,20 +847,6 @@
}
}
children.put(child.getName(), child);
- if( child instanceof ContainerBase ) {
- ContainerBase childCB=(ContainerBase)child;
- // XXX we should also send JMX notifications
- if( childCB.getObjectName() == null ) {
- // child was not registered yet.
-// ObjectName oname=childCB.createObjectName(this.getDomain(),
-// this.getObjectName());
-// if( oname != null ) {
-// // XXX Register the child
-//
-// }
-
- }
- }
fireContainerEvent(ADD_CHILD_EVENT, child);
}
@@ -1064,6 +1053,7 @@
return;
children.remove(child.getName());
}
+
if (started && (child instanceof Lifecycle)) {
try {
if( child instanceof ContainerBase ) {
@@ -1077,16 +1067,10 @@
log.error("ContainerBase.removeChild: stop: ", e);
}
}
- if( child instanceof ContainerBase ) {
- ContainerBase childCB=(ContainerBase)child;
- // XXX we should also send JMX notifications
- ObjectName oname=childCB.getObjectName();
- if( oname != null ) {
- // XXX UnRegister the child
- }
- }
+
fireContainerEvent(REMOVE_CHILD_EVENT, child);
- child.setParent(null);
+
+ // child.setParent(null);
}
@@ -1313,6 +1297,11 @@
if (children[i] instanceof Lifecycle)
((Lifecycle) children[i]).stop();
}
+ // Remove children - so next start can work
+ children = findChildren();
+ for (int i = 0; i < children.length; i++) {
+ removeChild(children[i]);
+ }
// Stop our Mappers, if any
Mapper mappers[] = findMappers();
@@ -1390,7 +1379,8 @@
mserver.invoke(parentName, "addChild", new Object[] { this },
new String[] {"org.apache.catalina.Container"});
}
- }
+ }
+ initialized=true;
}
public ObjectName getParentName() throws MalformedObjectNameException {
@@ -1401,6 +1391,7 @@
if( started ) {
stop();
}
+ initialized=false;
if (parent != null) {
parent.removeChild(this);
}
1.30 +21 -19 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
Index: StandardContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- StandardContext.java 20 Mar 2003 18:28:28 -0000 1.29
+++ StandardContext.java 21 Mar 2003 06:38:47 -0000 1.30
@@ -3754,6 +3754,13 @@
log.info(sm.getString("containerBase.alreadyStarted", logName()));
return;
}
+ if( !initialized ) {
+ try {
+ init();
+ } catch( Exception ex ) {
+ throw new LifecycleException("Error initializaing ", ex);
+ }
+ }
String logName="tomcat." + getParent().getName() + "." +
("".equals(getName()) ? "ROOT" : getName()) + ".Context";
@@ -4764,24 +4771,19 @@
public void init() throws Exception {
- if( this.getParent() != null ) {
- log.info( "Already configured" );
- return;
- }
- ObjectName parentName=getParentName();
-
- log.info("Adding to " + parentName );
-
- if( ! mserver.isRegistered(parentName)) {
- log.info("No host, creating one ");
- StandardHost host=new StandardHost();
- host.setName(hostName);
- Registry.getRegistry().registerComponent(host, parentName, null);
- mserver.invoke(parentName, "init", new Object[] {}, new String[] {} );
- }
- ContextConfig config = new ContextConfig();
- this.addLifecycleListener(config);
-
+ if( this.getParent() == null ) {
+ ObjectName parentName=getParentName();
+
+ if( ! mserver.isRegistered(parentName)) {
+ log.info("No host, creating one " + parentName);
+ StandardHost host=new StandardHost();
+ host.setName(hostName);
+ Registry.getRegistry().registerComponent(host, parentName, null);
+ mserver.invoke(parentName, "init", new Object[] {}, new String[] {} );
+ }
+ ContextConfig config = new ContextConfig();
+ this.addLifecycleListener(config);
+ }
super.init();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org