commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-commons/modeler/src/java/org/apache/commons/modeler/mbeans SimpleRemoteConnector.java
Date Sun, 13 Apr 2003 17:27:07 GMT
costin      2003/04/13 10:27:06

  Modified:    modeler/src/java/org/apache/commons/modeler/mbeans
                        SimpleRemoteConnector.java
  Log:
  Fix removal of proxies if the mbeans are removed on the other end.
  
  Revision  Changes    Path
  1.5       +20 -1     jakarta-commons/modeler/src/java/org/apache/commons/modeler/mbeans/SimpleRemoteConnector.java
  
  Index: SimpleRemoteConnector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/mbeans/SimpleRemoteConnector.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleRemoteConnector.java	9 Apr 2003 19:01:44 -0000	1.4
  +++ SimpleRemoteConnector.java	13 Apr 2003 17:27:06 -0000	1.5
  @@ -75,6 +75,7 @@
   import java.util.jar.Attributes;
   import javax.management.*;
   import javax.management.AttributeNotFoundException;
  +import javax.management.loading.ClassLoaderRepository;
   
   import org.apache.commons.modeler.Registry;
   import org.apache.commons.modeler.BaseModelMBean;
  @@ -268,7 +269,8 @@
               if( is==null ) return;
   
               Manifest mf=new Manifest(is);
  -
  +            
  +            HashMap currentObjects=new HashMap(); // used to remove older ones
               Map entries=mf.getEntries();
               Iterator it=entries.keySet().iterator();
               while( it.hasNext() ) {
  @@ -276,6 +278,7 @@
                   Attributes attrs=(Attributes)entries.get( name );
   
                   ObjectName oname=new ObjectName(name);
  +                currentObjects.put( oname, "");
                   MBeanProxy proxy=(MBeanProxy)mbeans.get(oname);
                   if( proxy==null ) {
                       log.debug( "New object " + name);
  @@ -302,6 +305,22 @@
                       cnt++;
                   }
               }
  +            
  +            // Now we have to remove all the mbeans that are no longer there
  +            Iterator existingIt=mbeans.keySet().iterator();
  +            while( existingIt.hasNext() ) {
  +                ObjectName on=(ObjectName)existingIt.next();
  +                if(currentObjects.get( on ) != null )
  +                    continue; // still alive
  +                if( log.isDebugEnabled() )
  +                    log.debug("No longer alive " + on);
  +                try {
  +                    mserver.unregisterMBean(on);
  +                } catch( Throwable t ) {
  +                    log.info("Error unregistering " + on + " " + t.toString());
  +                }
  +            }
  +            
               log.info( "Refreshing attributes " + cnt);
           } catch( Exception ex ) {
               log.info("Error ", ex);
  
  
  

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


Mime
View raw message