[jboss-cvs] JBossAS SVN: r80382 - in projects/vfs/trunk/src/main/java/org/jboss/virtual: spi/cache and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 3 08:18:02 EST 2008
Author: alesj
Date: 2008-11-03 08:18:01 -0500 (Mon, 03 Nov 2008)
New Revision: 80382
Added:
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java
Log:
Ignore start if already started.
Make cache init use double check.
Add pre-initializer; vfs context caching.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java 2008-11-03 13:14:34 UTC (rev 80381)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java 2008-11-03 13:18:01 UTC (rev 80382)
@@ -57,12 +57,15 @@
public void start() throws Exception
{
- policy = createCachePolicy();
+ if (started == false)
+ {
+ policy = createCachePolicy();
- policy.create();
- policy.start();
+ policy.create();
+ policy.start();
- started = true;
+ started = true;
+ }
}
public void stop()
@@ -72,6 +75,7 @@
policy.stop();
policy.destroy();
}
+ policy = null;
}
public void flush()
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java 2008-11-03 13:14:34 UTC (rev 80381)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/MapVFSCache.java 2008-11-03 13:18:01 UTC (rev 80382)
@@ -83,12 +83,14 @@
public void start() throws Exception
{
- cache = createMap();
+ if (cache == null)
+ cache = createMap();
}
public void stop()
{
flush();
+ cache = null;
}
public void flush()
Added: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java (rev 0)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/cache/PreInitializeVFSContexts.java 2008-11-03 13:18:01 UTC (rev 80382)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.virtual.plugins.cache;
+
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFS;
+
+/**
+ * Initialize vfs contexts - performance improvements.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PreInitializeVFSContexts
+{
+ private Logger log = Logger.getLogger(PreInitializeVFSContexts.class);
+ private List<URL> initializedVFSContexts;
+
+ /**
+ * Start initializer.
+ *
+ * @throws Exception for any exception
+ */
+ public void start() throws Exception
+ {
+ if (initializedVFSContexts != null && initializedVFSContexts.isEmpty() == false)
+ {
+ for (URL url : initializedVFSContexts)
+ {
+ VFS vfs = VFS.getVFS(url);
+ log.debug("Initialized Virtual File: " + vfs.getRoot());
+ }
+ }
+ }
+
+ /**
+ * Set URLs that need to be initialized before anything else.
+ *
+ * @param initializedVFSContexts the URLs to be initialized
+ */
+ public void setInitializedVFSContexts(List<URL> initializedVFSContexts)
+ {
+ this.initializedVFSContexts = initializedVFSContexts;
+ }
+}
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java 2008-11-03 13:14:34 UTC (rev 80381)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java 2008-11-03 13:18:01 UTC (rev 80382)
@@ -60,7 +60,8 @@
{
synchronized (lock)
{
- instance = AccessController.doPrivileged(new VFSCacheCreatorAction());
+ if (instance == null)
+ instance = AccessController.doPrivileged(new VFSCacheCreatorAction());
}
}
More information about the jboss-cvs-commits
mailing list