cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ContainerBase.java StandardContext.java

2003-10-31 Thread remm
remm2003/10/31 13:45:25

  Modified:catalina/src/share/org/apache/catalina/core
ContainerBase.java StandardContext.java
  Log:
  - Modify the MBean lifecycle for the containers.
  - The MBeans will now be removed only on destroy, rather than on stop.
  - The use case is this:
* Assume a started host exists
* Add a context by instantiating a MBean
* Then call init (addChild will be called, which will start the context)
* If there's an error starting the context, its MBean would have been removed
  right away, preventing further operations on the context (at least through JMX),
  and preventing redeploying it again (the host still has it as a child, so trying 
the
  same sequence again after fixing the issue would fail). I have deterrmined
  there's no way to properly handle this case through JMX, so the clean fix
  seems to do JMX unregistration only on destroy (so that the MBean has the
  same lifecycle as the context itself, which seems logical).
  
  Revision  ChangesPath
  1.30  +14 -13
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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ContainerBase.java15 Oct 2003 17:24:16 -  1.29
  +++ ContainerBase.java31 Oct 2003 21:45:25 -  1.30
  @@ -1213,18 +1213,6 @@
   }
   }
   
  -// unregister this component
  -if( oname != null ) {
  -try {
  -if( controller == oname ) {
  -Registry.getRegistry().unregisterComponent(oname);
  -log.debug(unregistering  + oname);
  -}
  -} catch( Throwable t ) {
  -log.error(Error unregistering , t );
  -}
  -}
  -
   // Notify our interested LifecycleListeners
   lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
   
  @@ -1253,7 +1241,7 @@
   mserver.invoke(parentName, addChild, new Object[] { this },
   new String[] {org.apache.catalina.Container});
   }
  -}  
  +}
   initialized=true;
   }
   
  @@ -1266,6 +1254,19 @@
   stop();
   }
   initialized=false;
  +
  +// unregister this component
  +if ( oname != null ) {
  +try {
  +if( controller == oname ) {
  +Registry.getRegistry().unregisterComponent(oname);
  +log.debug(unregistering  + oname);
  +}
  +} catch( Throwable t ) {
  +log.error(Error unregistering , t );
  +}
  +}
  +
   if (parent != null) {
   parent.removeChild(this);
   }
  
  
  
  1.98  +32 -18
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.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- StandardContext.java  21 Oct 2003 00:18:25 -  1.97
  +++ StandardContext.java  31 Oct 2003 21:45:25 -  1.98
  @@ -4059,6 +4059,7 @@
   
   if (ok) {
   
  +boolean mainOk = false;
   try {
   
   started = true;
  @@ -4084,7 +4085,7 @@
   
   // Set JMX object name for proper pipeline registration
   preRegisterJMX();
  -
  +
   // Start our child containers, if any
   Container children[] = findChildren();
   for (int i = 0; i  children.length; i++) {
  @@ -4123,9 +4124,16 @@
   // Start ContainerBackgroundProcessor thread
   super.threadStart();
   
  +mainOk = true;
  +
   } finally {
   // Unbinding thread
   unbindThread(oldCCL);
  +if (!mainOk) {
  +// An exception occurred
  +// Register with JMX anyway, to allow management
  +registerJMX();
  +}
   }
   
   }
  @@ -4190,9 +4198,9 @@
   }
   
   // JMX registration
  -if (ok) {
  -registerJMX();
  +registerJMX();
   
  +if (ok) {
   // Notify our interested LifecycleListeners
   lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
   }
  @@ 

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ContainerBase.java StandardContext.java

2003-10-15 Thread luehe
luehe   2003/10/15 10:24:16

  Modified:catalina/src/share/org/apache/catalina/core
ContainerBase.java StandardContext.java
  Log:
  Start/stop ContainerBackgroundProcessor thread as part of 
StandardContext.start()/stop(), respectively.
  
  Revision  ChangesPath
  1.29  +3 -3  
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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ContainerBase.java2 Sep 2003 21:22:04 -   1.28
  +++ ContainerBase.java15 Oct 2003 17:24:16 -  1.29
  @@ -1158,7 +1158,7 @@
   // Notify our interested LifecycleListeners
   lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
   
  -// Stop out thread
  +// Stop our thread
   threadStop();
   
   // Notify our interested LifecycleListeners
  @@ -1583,7 +1583,7 @@
* Start the background thread that will periodically check for
* session timeouts.
*/
  -private void threadStart() {
  +protected void threadStart() {
   
   if (thread != null)
   return;
  @@ -1603,7 +1603,7 @@
* Stop the background thread that is periodically checking for
* session timeouts.
*/
  -private void threadStop() {
  +protected void threadStop() {
   
   if (thread == null)
   return;
  
  
  
  1.96  +7 -1  
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.95
  retrieving revision 1.96
  diff -u -r1.95 -r1.96
  --- StandardContext.java  23 Sep 2003 09:07:37 -  1.95
  +++ StandardContext.java  15 Oct 2003 17:24:16 -  1.96
  @@ -4107,6 +4107,9 @@
   ((Lifecycle) getManager()).start();
   }
   
  +// Start ContainerBackgroundProcessor thread
  +super.threadStart();
  +
   } finally {
   // Unbinding thread
   unbindThread(oldCCL);
  @@ -4294,6 +4297,9 @@
   
   // Finalize our character set mapper
   setCharsetMapper(null);
  +
  +// Stop ContainerBackgroundProcessor thread
  +super.threadStop();
   
   if ((manager != null)  (manager instanceof Lifecycle)) {
   ((Lifecycle) manager).stop();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ContainerBase.java StandardContext.java StandardWrapper.java

2003-07-28 Thread amyroh
amyroh  2003/07/28 17:09:43

  Modified:catalina/src/share/org/apache/catalina/core
ContainerBase.java StandardContext.java
StandardWrapper.java
  Log:
  Send JSR77 spec required notifications for J2EE mbeans.
  
  Revision  ChangesPath
  1.26  +3 -1  
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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ContainerBase.java26 May 2003 22:03:59 -  1.25
  +++ ContainerBase.java29 Jul 2003 00:09:42 -  1.26
  @@ -1461,7 +1461,9 @@
   }
   
   public String getObjectName() {
  -return oname.toString();
  +if (oname != null) {
  +return oname.toString();
  +} else return null;
   }
   
   public String getDomain() {
  
  
  
  1.75  +70 -11
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.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- StandardContext.java  22 Jul 2003 21:01:26 -  1.74
  +++ StandardContext.java  29 Jul 2003 00:09:42 -  1.75
  @@ -85,11 +85,13 @@
   import javax.servlet.ServletRequestListener;
   import javax.naming.NamingException;
   import javax.naming.directory.DirContext;
  -import javax.management.ObjectName;
  -import javax.management.MBeanServer;
  -import javax.management.MalformedObjectNameException;
   import javax.management.InstanceNotFoundException;
  +import javax.management.MalformedObjectNameException;
   import javax.management.MBeanRegistrationException;
  +import javax.management.MBeanServer;
  +import javax.management.Notification;
  +import javax.management.NotificationBroadcasterSupport;
  +import javax.management.ObjectName;
   import org.apache.naming.ContextBindings;
   import org.apache.naming.resources.BaseDirContext;
   import org.apache.naming.resources.FileDirContext;
  @@ -155,6 +157,7 @@
   super();
   pipeline.setBasic(new StandardContextValve());
   namingResources.setContainer(this);
  +broadcaster = new NotificationBroadcasterSupport();
   
   }
   
  @@ -199,8 +202,12 @@
* The application available flag for this Context.
*/
   private boolean available = false;
  -
  -
  +
  +/**
  + * The broadcaster that sends j2ee notifications. 
  + */
  +private NotificationBroadcasterSupport broadcaster = null;
  +
   /**
* The Locale to character set mapper for this application.
*/
  @@ -441,7 +448,11 @@
*/
   private int sessionTimeout = 30;
   
  -
  +/**
  + * The notification sequence number.
  + */
  +private long sequenceNumber = 0;
  +
   /**
* The status code error pages for this web application, keyed by
* HTTP status code (as an Integer).
  @@ -640,8 +651,7 @@
  new Boolean(this.available));
   
   }
  -
  -
  +
   /**
* Return the Locale to character set mapper for this Context.
*/
  @@ -4118,6 +4128,15 @@
   lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
   startTime=System.currentTimeMillis();
   
  +
  +// Send j2ee.state.running notification 
  +if (this.getObjectName() != null) {
  +Notification notification = 
  +new Notification(j2ee.state.running, this.getObjectName(), 
  +sequenceNumber++);
  +broadcaster.sendNotification(notification);
  +}
  +
   // Close all JARs right away to avoid always opening a peak number 
   // of files on startup
   if (getLoader() instanceof WebappLoader) {
  @@ -4198,7 +4217,15 @@
   
   // Notify our interested LifecycleListeners
   lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
  -
  +
  +// Send j2ee.state.stoping notification 
  +if (this.getObjectName() != null) {
  +Notification notification = 
  +new Notification(j2ee.state.stoping, this.getObjectName(), 
  +sequenceNumber++);
  +broadcaster.sendNotification(notification);
  +}
  +
   // Mark this application as unavailable while we shut down
   setAvailable(false);
   
  @@ -4262,6 +4289,14 @@
   
   }
   
  +// Send 

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ContainerBase.java StandardContext.java StandardHost.java StandardPipeline.java StandardWrapper.java StandardWrapperValve.java mbeans-descriptors.xml

2003-03-20 Thread costin
costin  2003/03/20 10:28:29

  Modified:catalina/src/share/org/apache/catalina/core
ContainerBase.java StandardContext.java
StandardHost.java StandardPipeline.java
StandardWrapper.java StandardWrapperValve.java
mbeans-descriptors.xml
  Log:
  Fix the build - the dependencies don't seem to work very well..
  
  Removed some duplicated methods and unused fields, moved more to super, more
  work on clean stop and restart.
  
  Revision  ChangesPath
  1.12  +78 -6 
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ContainerBase.java20 Mar 2003 15:55:28 -  1.11
  +++ ContainerBase.java20 Mar 2003 18:28:28 -  1.12
  @@ -75,6 +75,7 @@
   import javax.management.ObjectName;
   import javax.management.MBeanRegistration;
   import javax.management.MBeanServer;
  +import javax.management.MalformedObjectNameException;
   
   import org.apache.naming.resources.ProxyDirContext;
   import org.apache.catalina.Cluster;
  @@ -93,6 +94,7 @@
   import org.apache.catalina.Request;
   import org.apache.catalina.Response;
   import org.apache.catalina.Valve;
  +import org.apache.catalina.startup.ContextConfig;
   import org.apache.catalina.logger.LoggerBase;
   import org.apache.catalina.session.StandardManager;
   import org.apache.catalina.valves.ValveBase;
  @@ -347,7 +349,9 @@
* the corresponding version number, in the format
* codelt;descriptiongt;/lt;versiongt;/code.
*/
  -public abstract String getInfo();
  +public String getInfo() {
  +return this.getClass().getName();
  +}
   
   
   /**
  @@ -1219,9 +1223,11 @@
   try {
   ObjectName 
vname=((ValveBase)valve).createObjectName(getDomain(),
   this.getObjectName());
  -((ValveBase)valve).setObjectName(vname);
  -Registry.getRegistry().registerComponent(valve, vname, 
valve.getClass().getName());
  -((ValveBase)valve).setController(oname);
  +if( vname != null ) {
  +((ValveBase)valve).setObjectName(vname);
  +Registry.getRegistry().registerComponent(valve, vname, 
valve.getClass().getName());
  +((ValveBase)valve).setController(oname);
  +}
   } catch( Throwable t ) {
   log.info( Can't register valve  + valve , t );
   }
  @@ -1335,11 +1341,77 @@
   ((Lifecycle) loader).stop();
   }
   
  +if( logger instanceof LoggerBase ) {
  +LoggerBase lb=(LoggerBase)logger;
  +if( lb.getObjectName()==null ) {
  +ObjectName lname=lb.createObjectName();
  +try {
  +Registry.getRegistry().registerComponent(lb, lname, null);
  +} catch( Exception ex ) {
  +log.error( Can't register logger  + lname, ex);
  +}
  +}
  +}
  +
  +// 
  +Valve valves[]=getValves();
  +for( int i=0; ivalves.length; i++ ) {
  +Valve valve=valves[i];
  +if( valve instanceof ValveBase 
  +((ValveBase)valve).getObjectName()!=null ) {
  +
Registry.getRegistry().unregisterComponent(((ValveBase)valve).getObjectName()); 
  +}
  +}
  +
   // Notify our interested LifecycleListeners
   lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
   
   }
   
  +/** Init method, part of the MBean lifecycle.
  + *  If the container was added via JMX, it'll register itself with the 
  + * parent, using the ObjectName conventions to locate the parent.
  + * 
  + *  If the container was added directly and it doesn't have an ObjectName,
  + * it'll create a name and register itself with the JMX console. On destroy(), 
  + * the object will unregister.
  + * 
  + * @throws Exception
  + */ 
  +public void init() throws Exception {
  +
  +if( this.getParent() == null ) {
  +// Life update
  +ObjectName parentName=getParentName();
  +
  +if( parentName != null  
  +! mserver.isRegistered(parentName)) 
  +{
  +mserver.invoke(parentName, addChild, new Object[] { this },
  +new String[] {org.apache.catalina.Container});
  +}
  +}
  +}
  

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core ContainerBase.java StandardContext.java

2003-03-20 Thread costin
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  ChangesPath
  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.java20 Mar 2003 18:28:28 -  1.12
  +++ ContainerBase.java21 Mar 2003 06:38:47 -  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 -  1.29
  +++ StandardContext.java  21 Mar 2003 06:38:47 -  1.30
  @@ -3754,6 +3754,13 @@
   log.info(sm.getString(containerBase.alreadyStarted, logName()));
   return;
   }
  +if( !initialized ) { 
  +try {
  +init();
  +} catch(