[jboss-cvs] jboss-seam/src/main/org/jboss/seam/deployment ...

Gavin King gavin.king at jboss.com
Wed Mar 7 00:20:40 EST 2007


  User: gavin   
  Date: 07/03/07 00:20:40

  Modified:    src/main/org/jboss/seam/deployment   ComponentScanner.java
                        Scanner.java
  Log:
  hot deployment for JavaBean components
  
  Revision  Changes    Path
  1.7       +2 -4      jboss-seam/src/main/org/jboss/seam/deployment/ComponentScanner.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ComponentScanner.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/ComponentScanner.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- ComponentScanner.java	25 Jan 2007 05:14:52 -0000	1.6
  +++ ComponentScanner.java	7 Mar 2007 05:20:40 -0000	1.7
  @@ -29,9 +29,7 @@
      }
   
      /**
  -    * Returns only Seam components (ie: classes annotated with
  -    * 
  -    * @Name)
  +    * Returns only Seam components (ie: classes annotated with @Name)
       */
      public Set<Class<Object>> getClasses()
      {
  @@ -57,7 +55,7 @@
                        && !"false".equals( getAnnotationValue(classFile, Install.class, "value") );
               if (installable)
               {
  -               if ( log.isDebugEnabled() ) log.debug("found component class: " + name);
  +               log.debug("found component class: " + name);
                  classes.add( (Class<Object>) classLoader.loadClass(classname) );
               }
            }
  
  
  
  1.25      +52 -30    jboss-seam/src/main/org/jboss/seam/deployment/Scanner.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Scanner.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/deployment/Scanner.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- Scanner.java	6 Mar 2007 04:35:45 -0000	1.24
  +++ Scanner.java	7 Mar 2007 05:20:40 -0000	1.25
  @@ -1,4 +1,4 @@
  -//$Id: Scanner.java,v 1.24 2007/03/06 04:35:45 gavin Exp $
  +//$Id: Scanner.java,v 1.25 2007/03/07 05:20:40 gavin Exp $
   package org.jboss.seam.deployment;
   
   import java.io.DataInputStream;
  @@ -7,8 +7,11 @@
   import java.io.InputStream;
   import java.lang.annotation.Annotation;
   import java.net.URL;
  +import java.net.URLClassLoader;
   import java.net.URLDecoder;
   import java.util.Enumeration;
  +import java.util.HashSet;
  +import java.util.Set;
   import java.util.zip.ZipEntry;
   import java.util.zip.ZipException;
   import java.util.zip.ZipFile;
  @@ -48,22 +51,27 @@
   
       protected void scan() 
       {
  -      Enumeration<URL> urls;
  -      try
  +      Set<String> paths = new HashSet<String>();
  +      if (resourceName==null)
         {
  -         urls = classLoader.getResources(resourceName);
  -      }
  -      catch (IOException ioe) 
  +         for ( URL url: ( (URLClassLoader) classLoader ).getURLs() )
         {
  -         log.warn("could not read: " + resourceName, ioe);
  -         return;
  +            String urlPath = url.getFile();
  +            if ( urlPath.endsWith("/") )
  +            {
  +               urlPath = urlPath.substring( 0, urlPath.length()-1 );
         }
  -      
  -      while ( urls.hasMoreElements() )
  +            paths.add( urlPath );
  +         }
  +      }
  +      else
         {
            try
            {
  -            String urlPath = urls.nextElement().getFile();
  +            Enumeration<URL> urlEnum = classLoader.getResources(resourceName);
  +            while ( urlEnum.hasMoreElements() )
  +            {
  +               String urlPath = urlEnum.nextElement().getFile();
               urlPath = URLDecoder.decode(urlPath, "UTF-8");
               if ( urlPath.startsWith("file:") )
               {
  @@ -78,13 +86,27 @@
               else
               {
                  File dirOrArchive = new File(urlPath);
  -               if ( resourceName.lastIndexOf('/')>0 )
  +                  if ( resourceName!=null && resourceName.lastIndexOf('/')>0 )
                  {
                     //for META-INF/components.xml
                     dirOrArchive = dirOrArchive.getParentFile();
                  }
                  urlPath = dirOrArchive.getParent();
               }
  +               paths.add(urlPath);
  +            }
  +         }
  +         catch (IOException ioe) 
  +         {
  +            log.warn("could not read: " + resourceName, ioe);
  +            return;
  +         }
  +      }
  +      
  +      for ( String urlPath: paths )
  +      {
  +         try
  +         {
               log.info("scanning: " + urlPath);
               File file = new File(urlPath);
               if ( file.isDirectory() )
  @@ -106,7 +128,7 @@
   
      private void handleArchive(File file) throws ZipException, IOException
      {
  -      log.debug("archive: " + file);
  +      log.info("archive: " + file);
         ZipFile zip = new ZipFile(file);
         Enumeration<? extends ZipEntry> entries = zip.entries();
         while ( entries.hasMoreElements() )
  
  
  



More information about the jboss-cvs-commits mailing list