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 Registry.java
Date Tue, 08 Apr 2003 04:08:21 GMT
costin      2003/04/07 21:08:21

  Modified:    modeler/src/java/org/apache/commons/modeler Registry.java
  Log:
  Deal with non-local mbeans.
  
  Revision  Changes    Path
  1.28      +22 -16    jakarta-commons/modeler/src/java/org/apache/commons/modeler/Registry.java
  
  Index: Registry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/Registry.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Registry.java	7 Apr 2003 06:46:58 -0000	1.27
  +++ Registry.java	8 Apr 2003 04:08:21 -0000	1.28
  @@ -215,7 +215,6 @@
       {
           if( type==null )
               type=bean.getName();
  -
           ManagedBean managed = registry.findManagedBean(type);
   
           // Search for a descriptor in the same package
  @@ -241,6 +240,10 @@
                       bean, type);
   
               managed=findManagedBean(type);
  +            if( managed==null ) {
  +                log.warn( "No metadata found for " + type );
  +                return null;
  +            }
               managed.setName( type );
               addManagedBean(managed);
           }
  @@ -413,14 +416,8 @@
           }
           String descriptors=res + "/mbeans-descriptors.ser";
   
  -        if( classLoader==null )
  -            classLoader=Thread.currentThread().getContextClassLoader();
  -        if( classLoader==null )
  -            classLoader=this.getClass().getClassLoader();
  -
           URL dURL=classLoader.getResource( descriptors );
   
  -
           if( dURL == null ) {
               descriptors=res + "/mbeans-descriptors.xml";
               dURL=classLoader.getResource( descriptors );
  @@ -517,6 +514,11 @@
               mbeans=ds.loadDescriptors(this, url.toString(), param, stream);
           }
   
  +        if( source instanceof File ) {
  +            mbeans=ds.loadDescriptors(this, ((File)source).getAbsolutePath(),
  +                    param, new FileInputStream((File)source));            
  +        }        
  +        
           if( source instanceof InputStream ) {
               mbeans=ds.loadDescriptors(this, null, param, source);
           }
  @@ -791,11 +793,18 @@
        * @param bean
        * @return
        */
  -    private boolean findDescriptor( Class beanClass, String pkg ) {
  -
  -        if( beanClass!=null ) {
  -            pkg=beanClass.getName();
  -        }
  +    private boolean findDescriptor( Class beanClass, String type ) {
  +        if( type==null ) type=beanClass.getName();
  +        ClassLoader classLoader=null;
  +        if( beanClass!=null ) 
  +            classLoader=beanClass.getClassLoader();
  +        if( classLoader==null )
  +            classLoader=Thread.currentThread().getContextClassLoader();
  +        if( classLoader==null )
  +            classLoader=this.getClass().getClassLoader();    
  +        
  +        String className=type;
  +        String pkg=className;
           while( pkg.indexOf( ".") > 0 ) {
               int lastComp=pkg.lastIndexOf( ".");
               if( lastComp <= 0 ) return false;
  @@ -803,10 +812,7 @@
               if( searchedPaths.get( pkg ) != null ) {
                   return false;
               }
  -            if( beanClass!=null )
  -                loadDescriptors(pkg, beanClass.getClassLoader());
  -            else
  -                loadDescriptors(pkg, null);
  +            loadDescriptors(pkg, classLoader);
           }
           return false;
       }
  
  
  

---------------------------------------------------------------------
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