[seam-commits] Seam SVN: r7145 - in trunk/src/main/org/jboss/seam: init and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Jan 18 10:14:01 EST 2008


Author: pete.muir at jboss.org
Date: 2008-01-17 17:18:17 -0500 (Thu, 17 Jan 2008)
New Revision: 7145

Removed:
   trunk/src/main/org/jboss/seam/deployment/ComponentScanner.java
   trunk/src/main/org/jboss/seam/deployment/GroovyComponentScanner.java
   trunk/src/main/org/jboss/seam/deployment/NamespaceScanner.java
   trunk/src/main/org/jboss/seam/init/GroovyHotRedeployable.java
   trunk/src/main/org/jboss/seam/init/JavaHotRedeployable.java
   trunk/src/main/org/jboss/seam/init/NoHotRedeployable.java
   trunk/src/main/org/jboss/seam/init/RedeployableStrategy.java
Log:
Tidy up from cvs2svn migration problem

Deleted: trunk/src/main/org/jboss/seam/deployment/ComponentScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/ComponentScanner.java	2008-01-17 21:18:35 UTC (rev 7144)
+++ trunk/src/main/org/jboss/seam/deployment/ComponentScanner.java	2008-01-17 22:18:17 UTC (rev 7145)
@@ -1,93 +0,0 @@
-package org.jboss.seam.deployment;
-
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-import javassist.bytecode.ClassFile;
-
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-
-/**
- * Scans archives in the Seam classpath for Seam components.
- * 
- * @author Thomas Heute
- * @author Gavin King
- * @author Norman Richards
- *
- */
-public class ComponentScanner extends Scanner
-{
-   private static final LogProvider log = Logging.getLogProvider(ComponentScanner.class);
-
-   protected Set<Class<Object>> classes;
-
-   private Set<String> resources;
-
-   public ComponentScanner(String resourceName)
-   {
-      super(resourceName);
-   }
-
-   public ComponentScanner(String resourceName, ClassLoader classLoader)
-   {
-      super(resourceName, classLoader);
-   }
-
-   /**
-    * Returns only Seam components (ie: classes annotated with @Name)
-    */
-   public Set<Class<Object>> getClasses()
-   {
-      if (classes == null) {
-         classes = new HashSet<Class<Object>>();
-         resources = new HashSet<String>();
-         scan();
-      }
-      return classes;
-   }
-   
-   public Set<String> getResources() {
-       return resources;
-   }
-
-   @Override
-   @SuppressWarnings("unchecked")
-   protected void handleItem(String name)
-   {
-      if (name.endsWith(".class")) {
-         String classname = filenameToClassname(name);
-         String filename = Scanner.componentFilename(name);
-         try {
-            ClassFile classFile = getClassFile(name);
-            boolean installable = ( hasAnnotation(classFile, Name.class) || classLoader.getResources(filename).hasMoreElements() )
-                     && !"false".equals( getAnnotationValue(classFile, Install.class, "value") );
-            if (installable) {
-               log.debug("found component class: " + name);
-               classes.add( (Class<Object>) classLoader.loadClass(classname) );
-            }
-            
-         } catch (ClassNotFoundException cnfe) {
-            log.debug("could not load class: " + classname, cnfe);
-         } catch (NoClassDefFoundError ncdfe) {
-            log.debug("could not load class (missing dependency): " + classname, ncdfe);
-         } catch (IOException ioe) {
-            log.debug("could not load classfile: " + classname, ioe);
-         }
-      } else if (name.endsWith(".component.xml") || name.endsWith("/components.xml")) {
-          // we want to skip over known meta-directories since Seam will auto-load these without a scan
-          if (!name.startsWith("WEB-INF/") && !name.startsWith("META-INF/")) {
-              resources.add(name);
-          }           
-      }
-           
-   }
-   
-   public ClassLoader getClassLoader() {
-       return classLoader;
-   }
-}

Deleted: trunk/src/main/org/jboss/seam/deployment/GroovyComponentScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/GroovyComponentScanner.java	2008-01-17 21:18:35 UTC (rev 7144)
+++ trunk/src/main/org/jboss/seam/deployment/GroovyComponentScanner.java	2008-01-17 22:18:17 UTC (rev 7145)
@@ -1,139 +0,0 @@
-//$Id$
-package org.jboss.seam.deployment;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import groovy.lang.GroovyClassLoader;
-import groovy.lang.GroovyRuntimeException;
-import org.codehaus.groovy.control.CompilationFailedException;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-
-/**
- * Scan Groovy files as well as Java files
- * <p/>
- * TODO: make it so that you can plug any Scripting scanner
- *
- * @author Emmanuel Bernard
- */
-public class GroovyComponentScanner extends ComponentScanner
-{
-   private static final LogProvider log = Logging.getLogProvider(GroovyComponentScanner.class);
-   private final String groovyFileExtension;
-
-   public GroovyComponentScanner(String resourceName, String groovyFileExtension)
-   {
-      super(resourceName);
-      this.groovyFileExtension = groovyFileExtension;
-   }
-
-   //has to be a GroovyClassLoader see #getURLsFromClassLoader
-   public GroovyComponentScanner(String resourceName, GroovyClassLoader classLoader, String groovyFileExtension)
-   {
-      super(resourceName, classLoader);
-      this.groovyFileExtension = groovyFileExtension;
-   }
-
-   @Override
-   protected URL[] getURLsFromClassLoader()
-   {
-      /*
-       * a GroovyClassLoader accept no URL,
-       * use the parent URL
-       */
-      return ( (URLClassLoader) classLoader.getParent() ).getURLs();
-   }
-
-   @Override
-   protected void handleItem(String name)
-   {
-      //handle java classes
-      super.handleItem(name);
-
-      if (name.endsWith(groovyFileExtension))
-      {
-         log.debug("Found a groovy file: " + name);
-         String classname = filenameToGroovyname(name);
-         String filename = groovyComponentFilename(name);
-         BufferedReader buffReader = null;
-         try
-         {
-            InputStream stream = classLoader.getResourceAsStream(name);
-            //TODO is BufferedInputStream necessary?
-            buffReader = new BufferedReader(new InputStreamReader(stream));
-            String line = buffReader.readLine();
-            while (line != null)
-            {
-               if (line.indexOf("@Name") != -1 || line.indexOf("@" + Name.class.getName()) != -1)
-               {
-                  //possibly a Seam component
-                  log.debug("Groovy file possibly a Seam component: " + name);
-                  Class<Object> groovyClass = (Class<Object>) classLoader.loadClass(classname);
-                  Install install = groovyClass.getAnnotation(Install.class);
-                  boolean installable = ( install == null || install.value() )
-                        && ( groovyClass.isAnnotationPresent(Name.class)
-                           || classLoader.getResources(filename).hasMoreElements() );
-                  if (installable)
-                  {
-                     log.debug("found groovy component class: " + name);
-                     classes.add(groovyClass);
-                  }
-                  break;
-               }
-               line = buffReader.readLine();
-            }
-         }
-         catch (ClassNotFoundException cnfe)
-         {
-            log.debug("could not load groovy class: " + classname, cnfe);
-
-         }
-         catch (NoClassDefFoundError ncdfe)
-         {
-            log.debug("could not load groovy class (missing dependency): " + classname, ncdfe);
-
-         }
-         catch (IOException ioe)
-         {
-            log.debug("could not load groovy file: " + classname, ioe);
-         }
-         catch( CompilationFailedException e) {
-            log.info("Compilation error in Groovy file:" + classname, e);
-         }
-         catch(GroovyRuntimeException e) {
-            log.info("Unknown error reading Groovy file:" + classname, e);
-         }
-         finally
-         {
-            if (buffReader != null) {
-               try
-               {
-                  buffReader.close();
-               }
-               catch (IOException e)
-               {
-                  log.trace("Could not close stream");
-               }
-            }
-         }
-      }
-   }
-
-   public String filenameToGroovyname(String filename)
-   {
-      return filename.substring(0, filename.lastIndexOf(groovyFileExtension))
-            .replace('/', '.').replace('\\', '.');
-   }
-
-   public String groovyComponentFilename(String name)
-   {
-      return name.substring(0, name.lastIndexOf(groovyFileExtension)) + ".component.xml";
-   }
-}

Deleted: trunk/src/main/org/jboss/seam/deployment/NamespaceScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/NamespaceScanner.java	2008-01-17 21:18:35 UTC (rev 7144)
+++ trunk/src/main/org/jboss/seam/deployment/NamespaceScanner.java	2008-01-17 22:18:17 UTC (rev 7145)
@@ -1,85 +0,0 @@
-package org.jboss.seam.deployment;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.seam.annotations.Namespace;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
-
-/**
- * Scanner for XML namespace declarations
- * 
- * @author Norman Richards
- *
- */
-public class NamespaceScanner extends Scanner 
-{
-    private static final LogProvider log = Logging.getLogProvider(NamespaceScanner.class);
-
-    private Set<Package> packages;
-    
-    public NamespaceScanner(String resourceName)
-    {
-        super(resourceName);
-    }
-    
-    public NamespaceScanner(String resourceName, ClassLoader classLoader)
-    {
-        super(resourceName,classLoader);
-    }
-    
-    /**
-     * Returns packages with @Namespace declarations
-     */
-    public Set<Package> getPackages()
-    {
-        if (packages == null) {
-            packages = new HashSet<Package>();
-            scan();
-        } 
-        return packages;
-    }
-
-    public static String filenameToPackageName(String filename)
-    {
-        return filename.substring(0, filename.lastIndexOf("/package-info.class"))
-            .replace('/', '.').replace('\\', '.');
-    }
-    
-    @Override
-    protected void handleItem(String name)
-    {
-        if ( name.endsWith("/package-info.class") ) 
-        {
-            String packageName = filenameToPackageName(name);
-            Package pkg = getPackage(packageName);
-            if (pkg == null) 
-            {
-                log.warn("Cannot load package Dinfo for " + packageName);
-            } 
-            else 
-            {
-                if (pkg.getAnnotation(Namespace.class) != null) 
-                {
-                    packages.add(pkg);
-                }
-            }
-        }
-    }
-
-    protected Package getPackage(String name) 
-    {
-        try 
-        {
-            Class c = classLoader.loadClass(name + ".package-info");
-            return c != null ? c.getPackage() : null;
-        } 
-        catch (Exception e) 
-        {
-            return null;
-        }
-    }
-
-}
-

Deleted: trunk/src/main/org/jboss/seam/init/GroovyHotRedeployable.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/GroovyHotRedeployable.java	2008-01-17 21:18:35 UTC (rev 7144)
+++ trunk/src/main/org/jboss/seam/init/GroovyHotRedeployable.java	2008-01-17 22:18:17 UTC (rev 7145)
@@ -1,51 +0,0 @@
-//$Id$
-package org.jboss.seam.init;
-
-import groovy.lang.GroovyClassLoader;
-
-import java.io.File;
-
-import org.codehaus.groovy.control.CompilerConfiguration;
-import org.jboss.seam.deployment.ComponentScanner;
-import org.jboss.seam.deployment.GroovyComponentScanner;
-
-/**
- * Support Groovy file loading as well as Java class loading
- * from hot directory
- *
- * @author Emmanuel Bernard
- */
-class GroovyHotRedeployable extends JavaHotRedeployable
-{
-   private static final String DEFAULT_SCRIPT_EXTENSION = new CompilerConfiguration().getDefaultScriptExtension();
-
-   public GroovyHotRedeployable(File hotDeployDir)
-   {
-      super(hotDeployDir);
-      /**
-       * No need for the Groovy Hotdeploy capability since the parent classloader needs
-       * to be replaced to hot deploy classes
-       */
-      if (classLoader != null) 
-      {
-         classLoader = new GroovyClassLoader(classLoader);
-      }
-   }
-
-   @Override
-   public ComponentScanner getScanner()
-   {
-      return classLoader != null ?
-            new GroovyComponentScanner(null, (GroovyClassLoader) getClassLoader(), DEFAULT_SCRIPT_EXTENSION) :
-            null;
-   }
-
-   @Override
-   public boolean isFromHotDeployClassLoader(Class componentClass)
-   {
-      //loaded by groovy or java
-      if (classLoader == null) return false;
-      ClassLoader classClassLoader = componentClass.getClassLoader().getParent(); //Groovy use an Inner Delegate CL
-      return classClassLoader == classLoader || classClassLoader == classLoader.getParent();
-   }
-}

Deleted: trunk/src/main/org/jboss/seam/init/JavaHotRedeployable.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/JavaHotRedeployable.java	2008-01-17 21:18:35 UTC (rev 7144)
+++ trunk/src/main/org/jboss/seam/init/JavaHotRedeployable.java	2008-01-17 22:18:17 UTC (rev 7145)
@@ -1,69 +0,0 @@
-//$Id$
-package org.jboss.seam.init;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import org.jboss.seam.deployment.ComponentScanner;
-
-/**
- * Hot redeployment of Java classes
- *
- * @author Emmanuel Bernard
- */
-class JavaHotRedeployable implements RedeployableStrategy
-{
-
-   protected File[] paths;
-   protected ClassLoader classLoader;
-
-   public JavaHotRedeployable(File directory)
-   {
-      try
-      {
-         if (directory.exists())
-         {
-            URL url = directory.toURL();
-            /*File[] jars = directory.listFiles( new FilenameFilter() {
-                  public boolean accept(File file, String name) { return name.endsWith(".jar"); }
-            } );
-            URL[] urls = new URL[jars.length];
-            for (int i=0; i<jars.length; i++)
-            {
-               urls[i] = jars[i].toURL();
-            }*/
-            URL[] urls = { url };
-            classLoader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
-            paths = new File[] { directory };
-         }
-
-      }
-      catch (MalformedURLException mue)
-      {
-         throw new RuntimeException(mue);
-      }
-   }
-
-   public ClassLoader getClassLoader()
-   {
-      return classLoader;
-   }
-
-   public File[] getPaths()
-   {
-      return paths;
-   }
-
-   public ComponentScanner getScanner()
-   {
-      //no classloader means we did not find the path
-      return classLoader != null ? new ComponentScanner(null, classLoader) : null;
-   }
-
-   public boolean isFromHotDeployClassLoader(Class componentClass)
-   {
-      return componentClass.getClassLoader() == classLoader;
-   }
-}

Deleted: trunk/src/main/org/jboss/seam/init/NoHotRedeployable.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/NoHotRedeployable.java	2008-01-17 21:18:35 UTC (rev 7144)
+++ trunk/src/main/org/jboss/seam/init/NoHotRedeployable.java	2008-01-17 22:18:17 UTC (rev 7145)
@@ -1,38 +0,0 @@
-//$Id$
-package org.jboss.seam.init;
-
-import java.io.File;
-
-import org.jboss.seam.deployment.ComponentScanner;
-
-/**
- * No hot deployment environment
- * 
- * @author Emmanuel Bernard
- */
-class NoHotRedeployable implements RedeployableStrategy
-{
-   public NoHotRedeployable(File resource) {}
-   
-   public NoHotRedeployable() {}
-
-   public ClassLoader getClassLoader()
-   {
-      return null;
-   }
-
-   public File[] getPaths()
-   {
-      return null;
-   }
-
-   public ComponentScanner getScanner()
-   {
-      return null;
-   }
-
-   public boolean isFromHotDeployClassLoader(Class componentClass)
-   {
-      return false;
-   }
-}

Deleted: trunk/src/main/org/jboss/seam/init/RedeployableStrategy.java
===================================================================
--- trunk/src/main/org/jboss/seam/init/RedeployableStrategy.java	2008-01-17 21:18:35 UTC (rev 7144)
+++ trunk/src/main/org/jboss/seam/init/RedeployableStrategy.java	2008-01-17 22:18:17 UTC (rev 7145)
@@ -1,33 +0,0 @@
-//$Id$
-package org.jboss.seam.init;
-
-import java.io.File;
-
-import org.jboss.seam.deployment.ComponentScanner;
-
-/**
- * Abstract the redeployable initialization mechanism
- * to prevent hard dependency between Seam and the
- * scripting language infrastructure
- *
- * @author Emmanuel Bernard
- */
-interface RedeployableStrategy
-{
-   /*
-    * Mandatory constructor
-    *
-    * @param resource url containing the redeployable files
-    */
-   //RedeployableInitialization(URL resource);
-
-
-   public ClassLoader getClassLoader();
-
-   public File[] getPaths();
-
-   public ComponentScanner getScanner();
-
-   public boolean isFromHotDeployClassLoader(Class componentClass);
-   
-}




More information about the seam-commits mailing list