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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 11 03:16:14 EDT 2009


Author: ALRubinger
Date: 2009-05-11 03:16:14 -0400 (Mon, 11 May 2009)
New Revision: 88598

Added:
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/VfsInitializingLifecycleEventHandler.java
Modified:
   projects/bootstrap/trunk/impl-as/pom.xml
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java
Log:
[JBBOOT-67] Hack in a lifecycle event handler to init VFS

Modified: projects/bootstrap/trunk/impl-as/pom.xml
===================================================================
--- projects/bootstrap/trunk/impl-as/pom.xml	2009-05-11 07:07:03 UTC (rev 88597)
+++ projects/bootstrap/trunk/impl-as/pom.xml	2009-05-11 07:16:14 UTC (rev 88598)
@@ -28,6 +28,8 @@
     <!-- Versions -->
     <version.org.jboss.bootstrap_jboss.bootstrap.impl.mc>0.1.2-SNAPSHOT</version.org.jboss.bootstrap_jboss.bootstrap.impl.mc>
     <version.org.jboss.bootstrap_jboss.bootstrap.spi.as>0.1.2-SNAPSHOT</version.org.jboss.bootstrap_jboss.bootstrap.spi.as>
+    <!-- REMOVE: JBBOOT-68 -->
+    <version.org.jboss_jboss.vfs>2.2.0.M4</version.org.jboss_jboss.vfs>
 
   </properties>
 
@@ -65,6 +67,15 @@
       <groupId>org.jboss.logging</groupId>
       <artifactId>jboss-logging-spi</artifactId>
     </dependency>
+    
+    <!-- Remove: JBBOOT-68 -->
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-vfs</artifactId>
+      <version>${version.org.jboss_jboss.vfs}</version>
+      <scope>provided</scope>
+    </dependency>
+    
 
   </dependencies>
 

Added: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/VfsInitializingLifecycleEventHandler.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/VfsInitializingLifecycleEventHandler.java	                        (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/lifecycle/VfsInitializingLifecycleEventHandler.java	2009-05-11 07:16:14 UTC (rev 88598)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.bootstrap.impl.as.lifecycle;
+
+import java.net.URL;
+
+import org.jboss.bootstrap.spi.lifecycle.LifecycleEventException;
+import org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler;
+import org.jboss.bootstrap.spi.lifecycle.LifecycleState;
+import org.jboss.logging.Logger;
+import org.jboss.net.protocol.URLStreamHandlerFactory;
+import org.jboss.virtual.VFS;
+
+/**
+ * VfsInitializingLifecycleEventHandler
+ * 
+ * Initializes VFS via an explicit call to {@link VFS#init()}
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ * @deprecated JBBOOT-67 -This is in place only until we've got a mechanism to initialize
+ * VFS explictly via a configurable deployable bootstrap XML, not this built-in hack
+ * (which supports the legacy behaviour).
+ */
+ at Deprecated
+//TODO Remove JBBOOT-67, JBBOOT-68
+public class VfsInitializingLifecycleEventHandler implements LifecycleEventHandler
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(VfsInitializingLifecycleEventHandler.class);
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Flag to indicate whether this has yet been run
+    */
+   private boolean beenRun;
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /* (non-Javadoc)
+    * @see org.jboss.bootstrap.spi.lifecycle.LifecycleEventHandler#handleEvent(org.jboss.bootstrap.spi.lifecycle.LifecycleState)
+    */
+   public void handleEvent(final LifecycleState state) throws LifecycleEventException
+   {
+      // Only run this instance once
+      if (!beenRun)
+      {
+         // Log
+         log.debug("Initializing the virtual filesystem...");
+
+         // Init the virtual filesystem
+         VFS.init();
+
+         // This bit was copied from the legacy AbstractServerImpl
+         try
+         {
+            // Install a URLStreamHandlerFactory that uses the TCL
+            URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory());
+
+            // Preload JBoss URL handlers
+            URLStreamHandlerFactory.preload();
+         }
+         catch (final Exception e)
+         {
+            // very naughty but we HAVE to do this or
+            // we'll fail if we ever try to do this again
+            log.warn("Caught Throwable Error, this probably means "
+                  + "we've already set the URLStreamHAndlerFactory before", e);
+         }
+
+         // Mark
+         beenRun = true;
+      }
+   }
+}
\ No newline at end of file

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java	2009-05-11 07:07:03 UTC (rev 88597)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java	2009-05-11 07:16:14 UTC (rev 88598)
@@ -31,6 +31,7 @@
 import org.jboss.bootstrap.impl.as.config.JBossASConfigurationValidator;
 import org.jboss.bootstrap.impl.as.lifecycle.KernelStartEventLifecycleEventHandler;
 import org.jboss.bootstrap.impl.as.lifecycle.KernelStopEventLifecycleEventHandler;
+import org.jboss.bootstrap.impl.as.lifecycle.VfsInitializingLifecycleEventHandler;
 import org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase;
 import org.jboss.bootstrap.spi.as.config.JBossASConfigurationInitializer;
 import org.jboss.bootstrap.spi.as.config.JBossASServerConfig;
@@ -144,6 +145,12 @@
       final LifecycleEventHandler stopHandler = new KernelStopEventLifecycleEventHandler(bootstrap);
       this.registerEventHandler(startHandler, LifecycleState.STARTED);
       this.registerEventHandler(stopHandler, LifecycleState.STOPPED);
+
+      // JBBOOT-68
+      //TODO Remove once VFS is init'd from something else
+      @SuppressWarnings("deprecation")
+      final LifecycleEventHandler initVfsHandler = new VfsInitializingLifecycleEventHandler();
+      this.registerEventHandler(initVfsHandler, LifecycleState.STARTING);
    }
 
    //-------------------------------------------------------------------------------||




More information about the jboss-cvs-commits mailing list