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/modules MbeansDescriptorsSerSource.java
Date Wed, 15 Jan 2003 00:36:31 GMT
costin      2003/01/14 16:36:31

  Modified:    modeler/src/java/org/apache/commons/modeler/modules
                        MbeansDescriptorsSerSource.java
  Log:
  Few updates. It's still not perfect - but works fine ( 2-3x faster than
  XML ).
  
  The .ser should be used as a cache - with xml as primary source. There is
  no need to parse the xml file every time.
  
  Revision  Changes    Path
  1.2       +15 -4     jakarta-commons/modeler/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsSerSource.java
  
  Index: MbeansDescriptorsSerSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsSerSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MbeansDescriptorsSerSource.java	11 Jan 2003 07:30:06 -0000	1.1
  +++ MbeansDescriptorsSerSource.java	15 Jan 2003 00:36:31 -0000	1.2
  @@ -10,6 +10,7 @@
   import java.io.InputStream;
   import java.io.ObjectInputStream;
   import java.io.EOFException;
  +import java.net.URL;
   
   
   public class MbeansDescriptorsSerSource extends Registry.DescriptorSource
  @@ -22,19 +23,29 @@
       {
           long t1=System.currentTimeMillis();
           try {
  -            InputStream stream=(InputStream)source;
  +            InputStream stream=null;
  +            if( source instanceof URL ) {
  +                stream=((URL)source).openStream();
  +            }
  +            if( source instanceof InputStream ) {
  +                stream=(InputStream)source;
  +            }
  +            if( stream==null ) {
  +                throw new Exception( "Can't process "+ source);
  +            }
               ObjectInputStream ois=new ObjectInputStream(stream);
  +            Thread.currentThread().setContextClassLoader(ManagedBean.class.getClassLoader());
               Object obj=ois.readObject();
  -            log.info("Reading " + obj);
  +            //log.info("Reading " + obj);
               ManagedBean beans[]=(ManagedBean[])obj;
               // after all are read without error
  -            Thread.currentThread().setContextClassLoader(ManagedBean.class.getClassLoader());
               for( int i=0; i<beans.length; i++ ) {
                   registry.addManagedBean(beans[i]);
               }
   
           } catch( Exception ex ) {
  -            log.error( "Error reading descriptors " +  ex.toString());
  +            log.error( "Error reading descriptors " + source + " " +  ex.toString(),
  +                    ex);
               throw ex;
           }
           long t2=System.currentTimeMillis();
  
  
  

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


Mime
View raw message