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

Ales Justin ajustin at redhat.com
Wed Jan 2 16:56:02 EST 2008


  User: alesj   
  Date: 08/01/02 16:56:02

  Modified:    src/main/org/jboss/seam/deployment  Scanner.java
  Log:
  Check if JBoss5 and not Embedded, then use VFS.
  
  Revision  Changes    Path
  1.31      +39 -3     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.30
  retrieving revision 1.31
  diff -u -b -r1.30 -r1.31
  --- Scanner.java	3 Dec 2007 20:29:49 -0000	1.30
  +++ Scanner.java	2 Jan 2008 21:56:02 -0000	1.31
  @@ -1,4 +1,4 @@
  -//$Id: Scanner.java,v 1.30 2007/12/03 20:29:49 alesj Exp $
  +//$Id: Scanner.java,v 1.31 2008/01/02 21:56:02 alesj Exp $
   package org.jboss.seam.deployment;
   
   import java.io.DataInputStream;
  @@ -6,6 +6,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.lang.annotation.Annotation;
  +import java.lang.reflect.Method;
   import java.net.URL;
   import java.net.URLClassLoader;
   import java.net.URLDecoder;
  @@ -58,7 +59,10 @@
            try
            {
               Class.forName("org.jboss.virtual.VFS");
  -            useVFS = true;
  +            // OK, we have VFS
  +            // but are we in JBoss5 and also not using Embedded
  +            useVFS = isJBoss5() && !isEmbedded();
  +            if (useVFS)
               log.info("Using JBoss VFS for scanning.");
            }
            catch(Throwable t)
  @@ -70,6 +74,38 @@
         return useVFS;
      }
   
  +   protected static boolean isJBoss5()
  +   {
  +      try
  +      {
  +         Class versionClass = Class.forName("org.jboss.Version");
  +         Method getVersionInstance = versionClass.getMethod("getInstance");
  +         Object versionInstance = getVersionInstance.invoke(null);
  +         Method getMajor = versionClass.getMethod("getMajor");
  +         Object major = getMajor.invoke(versionInstance);
  +         return major != null && major.equals(5);
  +      }
  +      catch (Exception e)
  +      {
  +         return false;
  +      }
  +   }
  +
  +   protected static boolean isEmbedded()
  +   {
  +      try
  +      {
  +         Class.forName("org.jboss.embedded.Bootstrap");
  +         if (log.isTraceEnabled())
  +            log.trace("Using JBoss Embedded.");
  +         return true;
  +      }
  +      catch(Exception e)
  +      {
  +         return false;
  +      }
  +   }
  +
      public static String filenameToClassname(String filename)
      {
         return filename.substring( 0, filename.lastIndexOf(".class") )
  
  
  



More information about the jboss-cvs-commits mailing list