You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by pe...@apache.org on 2005/01/29 20:42:27 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector MapperListener.java

pero        2005/01/29 11:42:27

  Modified:    catalina/src/share/org/apache/catalina/connector
                        MapperListener.java
  Log:
  Add destory methode to unregister as Notifcation listener
  Fix remove host mapping from other domains
  
  Revision  Changes    Path
  1.2       +34 -11    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/MapperListener.java
  
  Index: MapperListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/MapperListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MapperListener.java	23 Jun 2004 08:24:57 -0000	1.1
  +++ MapperListener.java	29 Jan 2005 19:42:27 -0000	1.2
  @@ -150,6 +150,19 @@
   
       }
   
  +    /**
  +     * unregister this from JMImplementation:type=MBeanServerDelegate
  +     */
  +    public void destroy() {
  +        try {
  +
  +            ObjectName objectName = new ObjectName(
  +                    "JMImplementation:type=MBeanServerDelegate");
  +            mBeanServer.removeNotificationListener(objectName, this);
  +        } catch (Exception e) {
  +            log.warn("Error unregistering MBeanServerDelegate", e);
  +        }
  +    }
   
       // ------------------------------------------- NotificationListener Methods
   
  @@ -183,12 +196,12 @@
                      (engineName != null) ) )  {
                   return;
               }
  -
  -            log.debug( "Handle " + objectName );    
  +            if(log.isDebugEnabled())
  +                log.debug( "Handle " + objectName  + " type : " + notification.getType());    
               if (notification.getType().equals
                   (MBeanServerNotification.REGISTRATION_NOTIFICATION)) {
                   String type=objectName.getKeyProperty("type");
  -                if( "Host".equals( type )) {
  +                if( "Host".equals( type ) && domain.equals(objectName.getDomain())) {
                       try {
                           registerHost(objectName);
                       } catch (Exception e) {
  @@ -214,7 +227,7 @@
               } else if (notification.getType().equals
                          (MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                   String type=objectName.getKeyProperty("type");
  -                if( "Host".equals( type )) {
  +                if( "Host".equals( type )&& domain.equals(objectName.getDomain())) {
                       try {
                           unregisterHost(objectName);
                       } catch (Exception e) {
  @@ -276,8 +289,8 @@
                   }
               }
               
  -            if (!isRegisteredWithAlias)
  -                log.warn("Unknown default host: " + defaultHost);
  +            if (!isRegisteredWithAlias && log.isWarnEnabled())
  +                log.warn(sm.getString("mapperListener.unknownDefaultHost", defaultHost));
           }
           // This should probablt be called later 
           if( defaultHost != null ) {
  @@ -295,6 +308,10 @@
               String[] aliases = (String[])
                   mBeanServer.invoke(objectName, "findAliases", null, null);
               mapper.addHost(name, aliases, objectName);
  +            if(log.isDebugEnabled())
  +                log.debug(sm.getString
  +                     ("mapperListener.registerHost", name, domain));
  +
           }
       }
   
  @@ -306,6 +323,9 @@
           throws Exception {
           String name=objectName.getKeyProperty("host");
           mapper.removeHost(name);
  +        if(log.isDebugEnabled())
  +            log.debug(sm.getString
  +                 ("mapperListener.unregisterHost", name, domain));
       }
   
   
  @@ -350,7 +370,8 @@
               contextName = "";
           }
   
  -        log.debug(sm.getString
  +        if(log.isDebugEnabled())
  +             log.debug(sm.getString
                     ("mapperListener.registerContext", contextName));
   
           Object context = 
  @@ -408,8 +429,8 @@
           if (contextName.equals("/")) {
               contextName = "";
           }
  -
  -        log.debug(sm.getString
  +        if(log.isDebugEnabled())
  +            log.debug(sm.getString
                     ("mapperListener.unregisterContext", contextName));
   
           mapper.removeContext(hostName, contextName);
  @@ -458,8 +479,8 @@
           if (contextName.equals("/")) {
               contextName = "";
           }
  -
  -        log.debug(sm.getString
  +        if(log.isDebugEnabled())
  +            log.debug(sm.getString
                     ("mapperListener.registerWrapper", 
                      wrapperName, contextName));
   
  @@ -478,4 +499,6 @@
       }
   
   
  +
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org