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

Gavin King gavin.king at jboss.com
Fri May 18 02:44:04 EDT 2007


  User: gavin   
  Date: 07/05/18 02:44:03

  Modified:    src/main/org/jboss/seam/init     GroovyHotRedeployable.java
                        Initialization.java JavaHotRedeployable.java
                        NoHotRedeployable.java
  Log:
  JBSEAM-1327
  
  Revision  Changes    Path
  1.3       +8 -5      jboss-seam/src/main/org/jboss/seam/init/GroovyHotRedeployable.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: GroovyHotRedeployable.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/GroovyHotRedeployable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- GroovyHotRedeployable.java	24 Apr 2007 00:06:40 -0000	1.2
  +++ GroovyHotRedeployable.java	18 May 2007 06:44:03 -0000	1.3
  @@ -1,9 +1,9 @@
  -//$Id: GroovyHotRedeployable.java,v 1.2 2007/04/24 00:06:40 gavin Exp $
  +//$Id: GroovyHotRedeployable.java,v 1.3 2007/05/18 06:44:03 gavin Exp $
   package org.jboss.seam.init;
   
   import groovy.lang.GroovyClassLoader;
   
  -import java.net.URL;
  +import java.io.File;
   
   import org.codehaus.groovy.control.CompilerConfiguration;
   import org.jboss.seam.deployment.ComponentScanner;
  @@ -19,14 +19,17 @@
   {
      private static final String DEFAULT_SCRIPT_EXTENSION = new CompilerConfiguration().getDefaultScriptExtension();
   
  -   public GroovyHotRedeployable(URL resource)
  +   public GroovyHotRedeployable(File hotDeployDir)
      {
  -      super(resource);
  +      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);
  +      if (classLoader != null) 
  +      {
  +         classLoader = new GroovyClassLoader(classLoader);
  +      }
      }
   
      @Override
  
  
  
  1.171     +46 -33    jboss-seam/src/main/org/jboss/seam/init/Initialization.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Initialization.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/Initialization.java,v
  retrieving revision 1.170
  retrieving revision 1.171
  diff -u -b -r1.170 -r1.171
  --- Initialization.java	1 May 2007 16:43:52 -0000	1.170
  +++ Initialization.java	18 May 2007 06:44:03 -0000	1.171
  @@ -5,6 +5,7 @@
    */
   package org.jboss.seam.init;
   
  +import java.io.File;
   import java.io.IOException;
   import java.io.InputStream;
   import java.lang.reflect.Constructor;
  @@ -55,7 +56,7 @@
   /**
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.170 $
  + * @version $Revision: 1.171 $
    */
   public class Initialization
   {
  @@ -527,54 +528,66 @@
         return this;
      }
   
  -   private RedeployableStrategy getRedeployableInitialization() {
  -      //really a factory
  -      ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
  -      URL resource = contextClassLoader.getResource("META-INF/debug.xhtml");
  -      boolean isGroovy = false;
  -      try {
  +   private RedeployableStrategy getRedeployableInitialization() 
  +   {
  +      File hotDeployDir = new File( servletContext.getRealPath("/WEB-INF/dev") );
  +      String strategy = getRedeployableStrategyName(hotDeployDir);
  +      try
  +      {
  +         Class initializer = Reflections.classForName(strategy);
  +         Constructor ctr = initializer.getConstructor(File.class);
  +         return (RedeployableStrategy) ctr.newInstance(hotDeployDir);
  +      }
  +      catch (Exception e)
  +      {
  +         throw new RuntimeException( "Unable to instantiate redeployable strategy: " + strategy );
  +      }
  +   }
  +
  +   private String getRedeployableStrategyName(File hotDeployDir)
  +   {
  +      boolean debugEnabled = Thread.currentThread().getContextClassLoader()
  +                  .getResource("META-INF/debug.xhtml")!=null;
  +      boolean isGroovy;
  +      try 
  +      {
            Reflections.classForName( "groovy.lang.GroovyObject" );
            isGroovy = true;
         }
         catch (ClassNotFoundException e)
         {
            //groovy is not there
  +         isGroovy = false;
         }
  -      if (resource!=null && isGroovy)
  +
  +      if ( debugEnabled && hotDeployDir.exists() )
  +      {
  +         if (isGroovy)
         {
            log.debug("Using Java+Groovy hot deploy");
  -         return buildRedeployableInitializer( "org.jboss.seam.init.GroovyHotRedeployable", resource );
  +            return "org.jboss.seam.init.GroovyHotRedeployable";
         }
  -      else if (resource!=null) {
  +         else 
  +         {
            log.debug("Using Java hot deploy");
  -         return buildRedeployableInitializer( "org.jboss.seam.init.JavaHotRedeployable", resource );
  +            return "org.jboss.seam.init.JavaHotRedeployable";
  +         }
         }
   //      else if (isGroovy) {
  -//         //TODO Implement it even when debug is not set up
  +//       TODO Implement it even when debug is not set up
   //      }
  -      else {
  -         log.debug("No hot deploy used");
  -         return buildRedeployableInitializer( "org.jboss.seam.init.NoHotRedeployable", resource );
  -      }
  -   }
  -
  -   private RedeployableStrategy buildRedeployableInitializer(String classname, URL resource)
  -   {
  -      try {
  -         Class initializer = Reflections.classForName( classname );
  -         Constructor ctr = initializer.getConstructor( URL.class );
  -         return (RedeployableStrategy) ctr.newInstance( resource );
  -      }
  -      catch (Exception e)
  +      else 
         {
  -         throw new RuntimeException( "Unable to instanciate redeployable strategy: " + classname );
  +         log.debug("No hot deploy used");
  +         return "org.jboss.seam.init.NoHotRedeployable";
         }
      }
   
      private void scanForHotDeployableComponents(RedeployableStrategy redeployStrategy)
      {
         ComponentScanner scanner = redeployStrategy.getScanner();
  -      if (scanner != null) {
  +      if (scanner != null) 
  +      {
            Set<Class<Object>> scannedClasses = new HashSet<Class<Object>>();
            scannedClasses.addAll(scanner.getClasses());
            Set<Package> scannedPackages = new HashSet<Package>();
  
  
  
  1.3       +2 -5      jboss-seam/src/main/org/jboss/seam/init/JavaHotRedeployable.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JavaHotRedeployable.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/JavaHotRedeployable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- JavaHotRedeployable.java	24 Apr 2007 00:06:40 -0000	1.2
  +++ JavaHotRedeployable.java	18 May 2007 06:44:03 -0000	1.3
  @@ -1,4 +1,4 @@
  -//$Id: JavaHotRedeployable.java,v 1.2 2007/04/24 00:06:40 gavin Exp $
  +//$Id: JavaHotRedeployable.java,v 1.3 2007/05/18 06:44:03 gavin Exp $
   package org.jboss.seam.init;
   
   import java.io.File;
  @@ -19,13 +19,10 @@
      protected File[] paths;
      protected ClassLoader classLoader;
   
  -   public JavaHotRedeployable(URL resource)
  +   public JavaHotRedeployable(File directory)
      {
         try
         {
  -         String path = resource.toExternalForm();
  -         String hotDeployDirectory = path.substring(9, path.length() - 46) + "dev";
  -         File directory = new File(hotDeployDirectory);
            if (directory.exists())
            {
               URL url = directory.toURL();
  
  
  
  1.2       +2 -4      jboss-seam/src/main/org/jboss/seam/init/NoHotRedeployable.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NoHotRedeployable.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/init/NoHotRedeployable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- NoHotRedeployable.java	18 Apr 2007 06:40:04 -0000	1.1
  +++ NoHotRedeployable.java	18 May 2007 06:44:03 -0000	1.2
  @@ -1,8 +1,7 @@
  -//$Id: NoHotRedeployable.java,v 1.1 2007/04/18 06:40:04 ebernard Exp $
  +//$Id: NoHotRedeployable.java,v 1.2 2007/05/18 06:44:03 gavin Exp $
   package org.jboss.seam.init;
   
   import java.io.File;
  -import java.net.URL;
   
   import org.jboss.seam.deployment.ComponentScanner;
   
  @@ -13,8 +12,7 @@
    */
   public class NoHotRedeployable implements RedeployableStrategy
   {
  -   public NoHotRedeployable(URL resource) {
  -   }
  +   public NoHotRedeployable(File resource) {}
   
      public ClassLoader getClassLoader()
      {
  
  
  



More information about the jboss-cvs-commits mailing list