costin      2003/04/04 14:10:30

  Modified:    catalina/src/share/org/apache/catalina/core
                        ContainerBase.java
  Log:
  few small fixes in unregistration.
  
  Added the "controller" - this will be the name of the component that
  registers, or null if it's an outside entity.
  
  For example, if a Container/Valve/etc is created automatically by tomcat,
  then the code that creates it will set the field. When the controller stops,
  it must also unregister all the components it registered ( and not more :-).
  
  If the same Container is created by modeler from a config file or by
  an embeding application by direct calls or other means - then the controller field
  will not be set, which means that the container is responsible for its lifecycle.
  
  Short version:
  1. who register is responsible to unregister
  2. you shouldn't unregister what you didn't registered
  
  Revision  Changes    Path
  1.18      +8 -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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ContainerBase.java        27 Mar 2003 03:06:39 -0000      1.17
  +++ ContainerBase.java        4 Apr 2003 22:10:30 -0000       1.18
  @@ -1312,12 +1312,11 @@
   
           if( logger instanceof LoggerBase ) {
               LoggerBase lb=(LoggerBase)logger;
  -            if( lb.getObjectName()==null ) {
  -                ObjectName lname=lb.createObjectName();
  +            if( lb.getObjectName()!=null ) {
                   try {
  -                    Registry.getRegistry().registerComponent(lb, lname, null);
  +                    Registry.getRegistry().unregisterComponent(lb.getObjectName());
                   } catch( Exception ex ) {
  -                    log.error( "Can't register logger " + lname, ex);
  +                    log.error( "Can't unregister logger " + lb.getObjectName(), ex);
                   }
               }
           }
  @@ -1325,8 +1324,10 @@
           // unregister this component
           if( oname != null ) {
               try {
  -                Registry.getRegistry().unregisterComponent(oname);
  -                log.info("unregistering " + oname);
  +                if( controller == oname ) {
  +                    Registry.getRegistry().unregisterComponent(oname);
  +                    log.debug("unregistering " + oname);
  +                }
               } catch( Throwable t ) {
                   log.error("Error unregistering ", t );
               }
  @@ -1578,6 +1579,7 @@
       protected String domain;
       protected String suffix;
       protected ObjectName oname;
  +    protected ObjectName controller;
       protected MBeanServer mserver;
   
       public ObjectName getObjectName() {
  
  
  

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

Reply via email to