[jboss-cvs] JBossAS SVN: r81346 - in projects/bootstrap/trunk: src/main/java/org/jboss/bootstrap and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 20 03:09:00 EST 2008


Author: ALRubinger
Date: 2008-11-20 03:09:00 -0500 (Thu, 20 Nov 2008)
New Revision: 81346

Modified:
   projects/bootstrap/trunk/pom.xml
   projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java
   projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java
   projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/ServerConfig.java
Log:
[JBBOOT-4] Refactor ServerConfig SPI to VFS in favor of java.io.File

Modified: projects/bootstrap/trunk/pom.xml
===================================================================
--- projects/bootstrap/trunk/pom.xml	2008-11-20 07:42:55 UTC (rev 81345)
+++ projects/bootstrap/trunk/pom.xml	2008-11-20 08:09:00 UTC (rev 81346)
@@ -24,6 +24,7 @@
   <properties>
   
     <!-- Versioning -->
+    <version.org.jboss_jboss.vfs>2.0.0.CR5</version.org.jboss_jboss.vfs>
     <version.org.jboss.man_jboss.managed>2.0.0.CR4</version.org.jboss.man_jboss.managed>
     <version.org.jboss.microcontainer_jboss.kernel>2.0.0.CR5</version.org.jboss.microcontainer_jboss.kernel>
   
@@ -61,6 +62,12 @@
       <artifactId>jboss-kernel</artifactId>
       <version>${version.org.jboss.microcontainer_jboss.kernel}</version>
     </dependency>
+    
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-vfs</artifactId>
+      <version>${version.org.jboss_jboss.vfs}</version>
+    </dependency>
 
   </dependencies>
   

Modified: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java	2008-11-20 07:42:55 UTC (rev 81345)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/AbstractServerImpl.java	2008-11-20 08:09:00 UTC (rev 81346)
@@ -41,6 +41,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.net.protocol.URLStreamHandlerFactory;
 import org.jboss.util.StopWatch;
+import org.jboss.virtual.VirtualFile;
 
 /**
  * A Server implementation that uses the deployer-beans.xml and ProfileService
@@ -172,8 +173,8 @@
       boolean overrideTmpDir = Boolean.getBoolean("jboss.server.temp.dir.overrideJavaTmpDir");
       if (overrideTmpDir)
       {
-         File serverTmpDir = config.getServerTempDir();
-         System.setProperty("java.io.tmpdir", serverTmpDir.getCanonicalPath());
+         VirtualFile serverTmpDir = config.getServerTempDir();
+         System.setProperty("java.io.tmpdir", serverTmpDir.getPathName());
       }
 
       // Initialize the logging layer using the ServerImpl class. The server log

Modified: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java	2008-11-20 07:42:55 UTC (rev 81345)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java	2008-11-20 08:09:00 UTC (rev 81346)
@@ -21,9 +21,9 @@
  */
 package org.jboss.bootstrap;
 
-import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Properties;
 
@@ -33,6 +33,8 @@
 import org.jboss.util.Null;
 import org.jboss.util.Primitives;
 import org.jboss.util.platform.Java;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
 
 /**
  * A container for the basic configuration elements required to create
@@ -56,7 +58,7 @@
    private Properties props;
 
    private URL bootstrapURL;
-   private File homeDir;
+   private VirtualFile homeDir;
    private URL homeURL;
    private URL libraryURL;
 
@@ -72,11 +74,11 @@
    private String serverSpecificationVersion;
 
    private String serverName;
-   private File serverBaseDir;
-   private File serverHomeDir;
-   private File serverLogDir;
-   private File serverTempDir;
-   private File serverDataDir;
+   private VirtualFile serverBaseDir;
+   private VirtualFile serverHomeDir;
+   private VirtualFile serverLogDir;
+   private VirtualFile serverTempDir;
+   private VirtualFile serverDataDir;
    private URL serverBaseURL;
    private URL serverHomeURL;
    private URL serverLibraryURL;
@@ -129,7 +131,14 @@
       // If not set then default to homeDir
       homeURL = getURL(ServerConfig.HOME_URL);
       if (homeURL == null)
-         homeURL = homeDir.toURL();
+         try
+         {
+            homeURL = homeDir.toURL();
+         }
+         catch (URISyntaxException e)
+         {
+            throw new RuntimeException(e);
+         }
       System.setProperty(ServerConfig.HOME_URL, homeURL.toString());
    }
 
@@ -156,7 +165,7 @@
       return bootstrapURL;
    }
 
-   public File getHomeDir()
+   public VirtualFile getHomeDir()
    {
       return homeDir;
    }
@@ -225,28 +234,42 @@
       return serverName;
    }
 
-   public File getServerBaseDir()
+   public VirtualFile getServerBaseDir()
    {
       if (serverBaseDir == null)
       {
          serverBaseDir = getFile(ServerConfig.SERVER_BASE_DIR);
          if (serverBaseDir == null)
          {
-            serverBaseDir = new File(homeDir, ServerConfig.SERVER_BASE_DIR_SUFFIX);
+            try
+            {
+               serverBaseDir = VFS.getVirtualFile(homeDir.toURL(), ServerConfig.SERVER_BASE_DIR_SUFFIX);
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException(e);
+            }
             System.setProperty(ServerConfig.SERVER_BASE_DIR, serverBaseDir.toString());
          }
       }
       return serverBaseDir;
    }
 
-   public File getServerHomeDir()
+   public VirtualFile getServerHomeDir()
    {
       if (serverHomeDir == null)
       {
          serverHomeDir = getFile(ServerConfig.SERVER_HOME_DIR);
          if (serverHomeDir == null)
          {
-            serverHomeDir = new File(getServerBaseDir(), getServerName());
+            try
+            {
+               serverHomeDir = VFS.getVirtualFile(getServerBaseDir().toURL(), getServerName());
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException(e);
+            }
             System.setProperty(ServerConfig.SERVER_HOME_DIR, serverHomeDir.toString());
          }
       }
@@ -261,14 +284,21 @@
     * @see ServerConfig#SERVER_LOG_DIR
     * @return the writable temp directory
     */
-   public File getServerLogDir()
+   public VirtualFile getServerLogDir()
    {
       if (serverLogDir == null)
       {
          serverLogDir = getFile(ServerConfig.SERVER_LOG_DIR);
          if (serverLogDir == null)
          {
-            serverLogDir = new File(getServerHomeDir(), ServerConfig.SERVER_LOG_DIR_SUFFIX);
+            try
+            {
+               serverLogDir = VFS.getVirtualFile(getServerHomeDir().toURL(), ServerConfig.SERVER_LOG_DIR_SUFFIX);
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException(e);
+            }
             System.setProperty(ServerConfig.SERVER_LOG_DIR, serverLogDir.toString());
          }
       }
@@ -280,14 +310,21 @@
     *
     * @return the writable temp directory
     */
-   public File getServerTempDir()
+   public VirtualFile getServerTempDir()
    {
       if (serverTempDir == null)
       {
          serverTempDir = getFile(ServerConfig.SERVER_TEMP_DIR);
          if (serverTempDir == null)
          {
-            serverTempDir = new File(getServerHomeDir(), ServerConfig.SERVER_TEMP_DIR_SUFFIX);
+            try
+            {
+               serverTempDir = VFS.getVirtualFile(getServerHomeDir().toURL(), ServerConfig.SERVER_TEMP_DIR_SUFFIX);
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException(e);
+            }
             System.setProperty(ServerConfig.SERVER_TEMP_DIR, serverTempDir.toString());
          }
       }
@@ -299,14 +336,21 @@
     *
     * @return the data directory
     */
-   public File getServerDataDir()
+   public VirtualFile getServerDataDir()
    {
       if (serverDataDir == null)
       {
          serverDataDir = getFile(ServerConfig.SERVER_DATA_DIR);
          if (serverDataDir == null)
          {
-            serverDataDir = new File(getServerHomeDir(), ServerConfig.SERVER_DATA_DIR_SUFFIX);
+            try
+            {
+               serverDataDir = VFS.getVirtualFile(getServerHomeDir().toURL(), ServerConfig.SERVER_DATA_DIR_SUFFIX);
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException(e);
+            }
             System.setProperty(ServerConfig.SERVER_DATA_DIR, serverDataDir.toString());
          }
       }
@@ -318,12 +362,22 @@
     * 
     * @return the directory
     */
-   public File getServerNativeDir()
+   public VirtualFile getServerNativeDir()
    {
-      String fileName = System.getProperty(NATIVE_DIR_PROPERTY);
-      if (fileName != null)
-         return new File(fileName);
-      return new File(getServerTempDir(), "native");
+      try
+      {
+         String fileName = System.getProperty(NATIVE_DIR_PROPERTY);
+         if (fileName != null)
+         {
+            URL url = new URL(fileName);
+            return VFS.getCachedFile(url);
+         }
+         return VFS.getVirtualFile(getServerTempDir().toURL(), "native");
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
    }
 
    /**
@@ -331,9 +385,16 @@
     * 
     * @return the directory
     */
-   public File getServerTempDeployDir()
+   public VirtualFile getServerTempDeployDir()
    {
-      return new File(getServerTempDir(), "deploy");
+      try
+      {
+         return VFS.getVirtualFile(getServerTempDir().toURL(), "deploy");
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
    }
 
    public URL getServerBaseURL()
@@ -668,19 +729,20 @@
     * Get a File from configuration.
     * @return the CanonicalFile form for the given name.
     */
-   private File getFile(final String name)
+   private VirtualFile getFile(final String name)
    {
       String value = props.getProperty(name, null);
       if (value != null)
       {
          try
          {
-            File f = new File(value);
-            return f.getCanonicalFile();
+            URL url = new URL(value);
+            VirtualFile f = VFS.getCachedFile(url);
+            return f;
          }
-         catch(IOException e)
+         catch (IOException e)
          {
-            return new File(value);
+            throw new RuntimeException("Could not get " + VirtualFile.class.getName() + " for URL: " + name, e);
          }
       }
 

Modified: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/ServerConfig.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/ServerConfig.java	2008-11-20 07:42:55 UTC (rev 81345)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/spi/ServerConfig.java	2008-11-20 08:09:00 UTC (rev 81346)
@@ -21,9 +21,10 @@
  */
 package org.jboss.bootstrap.spi;
 
-import java.io.File;
 import java.net.URL;
 
+import org.jboss.virtual.VirtualFile;
+
 /**
  * The interface of the basic <em>typed</em> JBoss server configuration.
  *
@@ -371,7 +372,7 @@
     *
     * @return    The local server home directory.
     */
-   File getHomeDir();
+   VirtualFile getHomeDir();
 
    /**
     * Get the home URL which the server is running from.
@@ -406,35 +407,35 @@
     *
     * @return    Base server home directory.
     */
-   File getServerBaseDir();
+   VirtualFile getServerBaseDir();
 
    /**
     * Get the server home directory.
     *
     * @return    Server home directory.
     */
-   File getServerHomeDir();
+   VirtualFile getServerHomeDir();
 
    /**
     * Get the directory where log files will be stored.
     *
     * @return    The directory where the server writes log files.
     */
-   File getServerLogDir();
+   VirtualFile getServerLogDir();
 
    /**
     * Get the directory where temporary files will be stored.
     *
     * @return    The directory where the server stores temporary files.
     */
-   File getServerTempDir();
+   VirtualFile getServerTempDir();
 
    /**
     * Get the directory where local data will be stored.
     *
     * @return    The directory where the server stores local data.
     */
-   File getServerDataDir();
+   VirtualFile getServerDataDir();
 
    /**
     * Get the base directory for calculating server home URLs.
@@ -557,14 +558,14 @@
     * 
     * @return the directory
     */
-   File getServerNativeDir();
+   VirtualFile getServerNativeDir();
 
    /**
     * Get the temporary deployment dir for unpacking
     * 
     * @return the directory
     */   
-   File getServerTempDeployDir();
+   VirtualFile getServerTempDeployDir();
 
    /**
     * Get the server Specification-Version




More information about the jboss-cvs-commits mailing list