tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/mx DynamicMBeanProxy.java
Date Fri, 09 Aug 2002 20:50:38 GMT
costin      2002/08/09 13:50:38

  Modified:    util/java/org/apache/tomcat/util/mx DynamicMBeanProxy.java
  Log:
  Few more fixes and minor enhancements.
  
  Fix recognition of boolean and long, let the caller specify the full name.
  
  Revision  Changes    Path
  1.5       +20 -10    jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/mx/DynamicMBeanProxy.java
  
  Index: DynamicMBeanProxy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/mx/DynamicMBeanProxy.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DynamicMBeanProxy.java	9 Aug 2002 17:39:07 -0000	1.4
  +++ DynamicMBeanProxy.java	9 Aug 2002 20:50:38 -0000	1.5
  @@ -119,19 +119,19 @@
       /** If a name was not provided, generate a name based on the
        *  class name and a sequence number.
        */
  -    public String generateName(Class realClass) {
  -        name=realClass.getName();
  +    public static String generateName(Class realClass) {
  +        String name=realClass.getName();
           name=name.substring( name.lastIndexOf( ".") + 1 );
           Integer iInt=(Integer)instances.get(name );
  +        int seq=0;
           if( iInt!= null ) {
  -            int i=iInt.intValue();
  -            i++;
  -            instances.put( name, new Integer( i ));
  -            name=name + "_" + i;
  +            seq=iInt.intValue();
  +            seq++;
  +            instances.put( name, new Integer( seq ));
           } else {
               instances.put( name, new Integer( 0 ));
           }
  -        return name;
  +        return "name=" + name + " seq=" + seq;
       }
   
       public static void createMBean( Object proxy, String domain, String name ) {
  @@ -140,6 +140,8 @@
               mbean.setReal( proxy );
               if( name!=null ) {
                   mbean.setName( name );
  +            } else {
  +                mbean.setName( generateName( proxy.getClass() ));
               }
   
               mbean.registerMBean( domain );
  @@ -151,7 +153,7 @@
       public void registerMBean( String domain ) {
           try {
               // XXX use aliases, suffix only, proxy.getName(), etc
  -            ObjectName oname=new ObjectName( domain + ": name=" +  getName());
  +            ObjectName oname=new ObjectName( domain + ": " +  getName());
   
               if(  getMBeanServer().isRegistered( oname )) {
                   log.info("Unregistering " + oname );
  @@ -179,8 +181,12 @@
           return ret == String.class ||
               ret == Integer.class ||
               ret == Integer.TYPE ||
  +            ret == Long.class ||
  +            ret == Long.TYPE ||
               ret == java.io.File.class ||
  -            ret == Boolean.class;
  +            ret == Boolean.class ||
  +            ret == Boolean.TYPE 
  +            ; 
       }
       
       /** Set the managed object.
  @@ -204,10 +210,14 @@
                   if( methods[j].getParameterTypes().length != 0 ) {
                       continue;
                   }
  -                if( ! Modifier.isPublic( methods[j].getModifiers() ) )
  +                if( ! Modifier.isPublic( methods[j].getModifiers() ) ) {
  +                    //log.debug("not public " + methods[j] );
                       continue;
  +                }
                   Class ret=methods[j].getReturnType();
                   if( ! supportedType( ret ) ) {
  +                    if( log.isDebugEnabled() )
  +                        log.debug("Unsupported " + ret );
                       continue;
                   }
                   name=unCapitalize( name.substring(3));
  
  
  

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


Mime
View raw message