[jboss-cvs] JBossAS SVN: r80641 - in projects/vfs/tags: 2.0.0.CR5 and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 7 06:55:51 EST 2008
Author: alesj
Date: 2008-11-07 06:55:51 -0500 (Fri, 07 Nov 2008)
New Revision: 80641
Added:
projects/vfs/tags/2.0.0.CR5/
projects/vfs/tags/2.0.0.CR5/pom.xml
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
Removed:
projects/vfs/tags/2.0.0.CR5/pom.xml
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java
projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java
projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
Log:
[maven-release-plugin] copy for tag 2.0.0.CR5
Copied: projects/vfs/tags/2.0.0.CR5 (from rev 80637, projects/vfs/branches/Branch_2_0)
Deleted: projects/vfs/tags/2.0.0.CR5/pom.xml
===================================================================
--- projects/vfs/branches/Branch_2_0/pom.xml 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/pom.xml 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,122 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>4</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-vfs</artifactId>
- <packaging>jar</packaging>
- <version>2.0.0-SNAPSHOT</version>
- <name>JBoss VFS</name>
- <url>http://www.jboss.org</url>
- <description>A VFS library</description>
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/vfs/branches/Branch_2_0</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/vfs/branches/Branch_2_0</developerConnection>
- <url>https://svn.jboss.org/repos/jbossas/projects/vfs/branches/Branch_2_0</url>
- </scm>
- <licenses>
- <license>
- <name>lgpl</name>
- <url>http://repository.jboss.org/licenses/lgpl.txt</url>
- </license>
- </licenses>
- <organization>
- <name>JBoss, A division of Red Hat, Inc</name>
- <url>http://www.jboss.org</url>
- </organization>
-
- <properties>
- <version.jboss.common.core>2.2.9.GA</version.jboss.common.core>
- <version.jboss.logging>2.0.5.GA</version.jboss.logging>
- <version.jboss.test>1.1.0.GA</version.jboss.test>
- <version.junit>4.4</version.junit>
- </properties>
-
- <build>
- <sourceDirectory>src/main/java</sourceDirectory>
- <testSourceDirectory>src/test/java</testSourceDirectory>
- <finalName>${artifactId}</finalName>
- <testResources>
- <testResource>
- <directory>src/test/resources</directory>
- </testResource>
- </testResources>
- <plugins>
-
- <!-- define how we want compilation to take place
- here, we accept most of the defaults but say that we want the
- optimization flag set, and define the source and target to be 1.5,
- these setting will be inherited by child projects -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <debug>true</debug>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <!-- define that we wish to create src jars -->
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <inherited>true</inherited>
- <executions>
- <execution>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.3.1</version>
- <configuration>
- <forkMode>always</forkMode> <!-- required to correctly run the PojoServer tests -->
- <useSystemClassLoader>true</useSystemClassLoader>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <testFailureIgnore>true</testFailureIgnore>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.0-beta-7</version>
- <configuration>
- <tagBase>https://svn.jboss.org/repos/jbossas/projects/vfs/tags</tagBase>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>${version.jboss.common.core}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>${version.jboss.logging}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <version>${version.jboss.test}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${version.junit}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
Copied: projects/vfs/tags/2.0.0.CR5/pom.xml (from rev 80640, projects/vfs/branches/Branch_2_0/pom.xml)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/pom.xml (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/pom.xml 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,122 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <packaging>jar</packaging>
+ <version>2.0.0.CR5</version>
+ <name>JBoss VFS</name>
+ <url>http://www.jboss.org</url>
+ <description>A VFS library</description>
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.CR5</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.CR5</developerConnection>
+ <url>https://svn.jboss.org/repos/jbossas/projects/vfs/tags/2.0.0.CR5</url>
+ </scm>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.org/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss, A division of Red Hat, Inc</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+
+ <properties>
+ <version.jboss.common.core>2.2.9.GA</version.jboss.common.core>
+ <version.jboss.logging>2.0.5.GA</version.jboss.logging>
+ <version.jboss.test>1.1.0.GA</version.jboss.test>
+ <version.junit>4.4</version.junit>
+ </properties>
+
+ <build>
+ <sourceDirectory>src/main/java</sourceDirectory>
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+ <finalName>${artifactId}</finalName>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+
+ <!-- define how we want compilation to take place
+ here, we accept most of the defaults but say that we want the
+ optimization flag set, and define the source and target to be 1.5,
+ these setting will be inherited by child projects -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <debug>true</debug>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <!-- define that we wish to create src jars -->
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ <configuration>
+ <forkMode>always</forkMode> <!-- required to correctly run the PojoServer tests -->
+ <useSystemClassLoader>true</useSystemClassLoader>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <testFailureIgnore>true</testFailureIgnore>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ <configuration>
+ <tagBase>https://svn.jboss.org/repos/jbossas/projects/vfs/tags</tagBase>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>${version.jboss.common.core}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>${version.jboss.logging}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>${version.jboss.test}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Deleted: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,171 +0,0 @@
-/*
-* 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.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collections;
-
-import org.jboss.util.CachePolicy;
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * Cache policy vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public abstract class CachePolicyVFSCache extends PathMatchingVFSCache
-{
- private CachePolicy policy;
-
- public Iterable<VFSContext> getCachedContexts()
- {
- // cannot pull all cache entries from policy
- return Collections.emptySet();
- }
-
- public int size()
- {
- return policy != null ? policy.size() : -1;
- }
-
- protected void check()
- {
- if (policy == null)
- throw new IllegalArgumentException("Cache needs to be started first.");
- }
-
- public void start() throws Exception
- {
- policy = createCachePolicy();
- if (policy == null)
- throw new IllegalArgumentException("Policy is null.");
-
- policy.create();
- try
- {
- policy.start();
- }
- catch (Exception e)
- {
- try
- {
- policy.destroy();
- }
- catch (Exception ignored)
- {
- }
- throw e;
- }
- }
-
- public void stop()
- {
- if (policy != null)
- {
- try
- {
- policy.stop();
- }
- catch (Exception ignored)
- {
- }
- try
- {
- policy.destroy();
- }
- catch (Exception ignored)
- {
- }
- finally
- {
- policy = null;
- }
- }
- }
-
- public void flush()
- {
- if (policy != null)
- policy.flush();
- }
-
- protected VFSContext getContext(String path)
- {
- return VFSContext.class.cast(policy.get(path));
- }
-
- protected void putContext(String path, VFSContext context)
- {
- Object result = policy.peek(path);
- if (result == null)
- policy.insert(path, context);
- }
-
- public void removeContext(String key, VFSContext context)
- {
- policy.remove(key);
- }
-
- /**
- * Create cache policy.
- *
- * @return the cache policy
- */
- protected abstract CachePolicy createCachePolicy();
-
- /**
- * Read system property.
- *
- * @param key the property key
- * @param defaultValue the default value
- * @return system property or default value
- */
- protected static String readSystemProperty(final String key, final String defaultValue)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null)
- return System.getProperty(key, defaultValue);
- else
- return AccessController.doPrivileged(new PrivilegedAction<String>()
- {
- public String run()
- {
- return System.getProperty(key, defaultValue);
- }
- });
- }
-
- /**
- * Parse integer.
- *
- * @param value the string int value
- * @return integer value of null
- */
- protected static Integer parseInteger(String value)
- {
- if (value == null)
- return null;
-
- return Integer.parseInt(value);
- }
-}
\ No newline at end of file
Copied: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/CachePolicyVFSCache.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,226 @@
+/*
+* 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.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.Map;
+
+import org.jboss.util.CachePolicy;
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Cache policy vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CachePolicyVFSCache extends PathMatchingVFSCache
+{
+ private CachePolicy policy;
+ private Map<Object, Object> properties;
+
+ protected CachePolicyVFSCache()
+ {
+ }
+
+ protected CachePolicyVFSCache(Map<Object, Object> properties)
+ {
+ this.properties = properties;
+ }
+
+ public Iterable<VFSContext> getCachedContexts()
+ {
+ // cannot pull all cache entries from policy
+ return Collections.emptySet();
+ }
+
+ public int size()
+ {
+ return policy != null ? policy.size() : -1;
+ }
+
+ protected void check()
+ {
+ if (policy == null)
+ throw new IllegalArgumentException("Cache needs to be started first.");
+ }
+
+ public void start() throws Exception
+ {
+ policy = createCachePolicy();
+ if (policy == null)
+ throw new IllegalArgumentException("Policy is null.");
+
+ policy.create();
+ try
+ {
+ policy.start();
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ policy.destroy();
+ }
+ catch (Exception ignored)
+ {
+ }
+ throw e;
+ }
+ }
+
+ public void stop()
+ {
+ if (policy != null)
+ {
+ try
+ {
+ policy.stop();
+ }
+ catch (Exception ignored)
+ {
+ }
+ try
+ {
+ policy.destroy();
+ }
+ catch (Exception ignored)
+ {
+ }
+ finally
+ {
+ policy = null;
+ }
+ }
+ }
+
+ public void flush()
+ {
+ if (policy != null)
+ policy.flush();
+ }
+
+ protected VFSContext getContext(String path)
+ {
+ return VFSContext.class.cast(policy.get(path));
+ }
+
+ protected void putContext(String path, VFSContext context)
+ {
+ Object result = policy.peek(path);
+ if (result == null)
+ policy.insert(path, context);
+ }
+
+ public void removeContext(String key, VFSContext context)
+ {
+ policy.remove(key);
+ }
+
+ /**
+ * Create cache policy.
+ *
+ * @return the cache policy
+ */
+ protected abstract CachePolicy createCachePolicy();
+
+ /**
+ * Read instance properties.
+ *
+ * @param key the property key
+ * @param defaultValue the default value
+ * @param useSystemProperties do we fallback to system properties
+ * @return property or default value
+ */
+ protected Object readInstanceProperties(final String key, final Object defaultValue, final boolean useSystemProperties)
+ {
+ Object result = null;
+ if (properties != null && properties.isEmpty() == false)
+ {
+ result = properties.get(key);
+ }
+ if (result == null)
+ {
+ if (useSystemProperties)
+ {
+ String stringDefaultValue = defaultValue != null ? defaultValue.toString() : null;
+ result = readSystemProperty(key, stringDefaultValue);
+ }
+ else
+ result = defaultValue;
+ }
+ return result;
+ }
+
+ /**
+ * Read system property.
+ *
+ * @param key the property key
+ * @param defaultValue the default value
+ * @return system property or default value
+ */
+ protected static String readSystemProperty(final String key, final String defaultValue)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ return System.getProperty(key, defaultValue);
+ else
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(key, defaultValue);
+ }
+ });
+ }
+
+ /**
+ * Parse integer.
+ *
+ * @param value the string int value
+ * @return integer value or null
+ */
+ protected static Integer parseInteger(String value)
+ {
+ if (value == null)
+ return null;
+
+ return Integer.parseInt(value);
+ }
+
+ /**
+ * Get integer from value.
+ *
+ * @param value the value
+ * @return integer value or null
+ */
+ protected static Integer getInteger(Object value)
+ {
+ if (value == null)
+ return null;
+ else if (value instanceof Number)
+ return Number.class.cast(value).intValue();
+ else
+ return Integer.parseInt(value.toString());
+ }
+}
\ No newline at end of file
Deleted: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,82 +0,0 @@
-/*
-* 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 org.jboss.util.CachePolicy;
-import org.jboss.util.LRUCachePolicy;
-import org.jboss.virtual.VFSUtils;
-
-/**
- * LRU cache policy vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class LRUVFSCache extends CachePolicyVFSCache
-{
- private Integer min;
- private Integer max;
-
- public LRUVFSCache()
- {
- }
-
- public LRUVFSCache(Integer min, Integer max)
- {
- this.min = min;
- this.max = max;
- }
-
- protected CachePolicy createCachePolicy()
- {
- if (min == null)
- min = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.min", null));
- if (max == null)
- max = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.max", null));
-
- if (min == null || max == null)
- throw new IllegalArgumentException("Missing min (" + min + ") or max (" + max + ").");
-
- log.debug("Creating LRU cache policy, min: " + min + ", max: " + max);
-
- return new LRUCachePolicy(min, max);
- }
-
- /**
- * Set min.
- *
- * @param min the min
- */
- public void setMin(Integer min)
- {
- this.min = min;
- }
-
- /**
- * set max.
- *
- * @param max the max
- */
- public void setMax(Integer max)
- {
- this.max = max;
- }
-}
\ No newline at end of file
Copied: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/LRUVFSCache.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,94 @@
+/*
+* 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.util.Map;
+
+import org.jboss.util.CachePolicy;
+import org.jboss.util.LRUCachePolicy;
+import org.jboss.virtual.VFSUtils;
+
+/**
+ * LRU cache policy vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LRUVFSCache extends CachePolicyVFSCache
+{
+ private Integer min;
+ private Integer max;
+
+ public LRUVFSCache()
+ {
+ }
+
+ public LRUVFSCache(Integer min, Integer max)
+ {
+ this.min = min;
+ this.max = max;
+ }
+
+ public LRUVFSCache(Map<Object, Object> properties)
+ {
+ super(properties);
+ }
+
+ protected CachePolicy createCachePolicy()
+ {
+ if (min == null)
+ min = getInteger(readInstanceProperties(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.min", null, true));
+ if (max == null)
+ max = getInteger(readInstanceProperties(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.max", null, true));
+
+ if (min == null || max == null)
+ throw new IllegalArgumentException("Missing min (" + min + ") or max (" + max + ").");
+
+ log.debug("Creating LRU cache policy, min: " + min + ", max: " + max);
+
+ return new LRUCachePolicy(min, max);
+ }
+
+ /**
+ * Set min.
+ *
+ * @param min the min
+ */
+ public void setMin(Integer min)
+ {
+ this.min = min;
+ }
+
+ /**
+ * set max.
+ *
+ * @param max the max
+ */
+ public void setMax(Integer max)
+ {
+ this.max = max;
+ }
+
+ public String toString()
+ {
+ return "LRUVFSCache{min=" + min + ", max=" + max + "}";
+ }
+}
\ No newline at end of file
Deleted: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,103 +0,0 @@
-/*
-* 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 org.jboss.util.CachePolicy;
-import org.jboss.util.TimedCachePolicy;
-import org.jboss.virtual.VFSUtils;
-
-/**
- * Timed cache policy vfs cache.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class TimedVFSCache extends CachePolicyVFSCache
-{
- private Integer defaultLifetime;
- private Boolean threadSafe;
- private Integer resolution;
-
- public TimedVFSCache()
- {
- }
-
- public TimedVFSCache(Integer defaultLifetime)
- {
- this(defaultLifetime, null, null);
- }
-
- public TimedVFSCache(Integer defaultLifetime, Boolean threadSafe, Integer resolution)
- {
- this.defaultLifetime = defaultLifetime;
- this.threadSafe = threadSafe;
- this.resolution = resolution;
- }
-
- protected CachePolicy createCachePolicy()
- {
- if (defaultLifetime == null)
- defaultLifetime = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.lifetime", null));
- if (threadSafe == null)
- threadSafe = Boolean.valueOf(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.threadSafe", Boolean.TRUE.toString()));
- if (resolution == null)
- resolution = parseInteger(readSystemProperty(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.resolution", null));
-
- log.debug("Creating timed cache policy, lifetime: " + defaultLifetime + ", threadSafe: " + threadSafe + ", resolution: " + resolution);
-
- if (defaultLifetime == null)
- return new TimedCachePolicy();
- else if (resolution != null)
- return new TimedCachePolicy(defaultLifetime, threadSafe, resolution);
- else
- return new TimedCachePolicy(defaultLifetime);
- }
-
- /**
- * Set default lifetime.
- *
- * @param defaultLifetime the default lifetime
- */
- public void setDefaultLifetime(Integer defaultLifetime)
- {
- this.defaultLifetime = defaultLifetime;
- }
-
- /**
- * Set threadsafe flag.
- *
- * @param threadSafe the threadsafe flag
- */
- public void setThreadSafe(Boolean threadSafe)
- {
- this.threadSafe = threadSafe;
- }
-
- /**
- * The resollution.
- *
- * @param resolution the resolution
- */
- public void setResolution(Integer resolution)
- {
- this.resolution = resolution;
- }
-}
\ No newline at end of file
Copied: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/cache/TimedVFSCache.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,122 @@
+/*
+* 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.util.Map;
+
+import org.jboss.util.CachePolicy;
+import org.jboss.util.TimedCachePolicy;
+import org.jboss.virtual.VFSUtils;
+
+/**
+ * Timed cache policy vfs cache.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TimedVFSCache extends CachePolicyVFSCache
+{
+ private Integer defaultLifetime;
+ private Boolean threadSafe;
+ private Integer resolution;
+
+ private String info;
+
+ public TimedVFSCache()
+ {
+ }
+
+ public TimedVFSCache(Integer defaultLifetime)
+ {
+ this(defaultLifetime, null, null);
+ }
+
+ public TimedVFSCache(Integer defaultLifetime, Boolean threadSafe, Integer resolution)
+ {
+ this.defaultLifetime = defaultLifetime;
+ this.threadSafe = threadSafe;
+ this.resolution = resolution;
+ }
+
+ public TimedVFSCache(Map<Object, Object> properties)
+ {
+ super(properties);
+ }
+
+ protected CachePolicy createCachePolicy()
+ {
+ if (defaultLifetime == null)
+ defaultLifetime = getInteger(readInstanceProperties(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.lifetime", null, true));
+ if (threadSafe == null)
+ threadSafe = Boolean.valueOf(readInstanceProperties(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.threadSafe", Boolean.TRUE, true).toString());
+ if (resolution == null)
+ resolution = getInteger(readInstanceProperties(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.resolution", null, true));
+
+ log.debug("Creating timed cache policy, lifetime: " + defaultLifetime + ", threadSafe: " + threadSafe + ", resolution: " + resolution);
+
+ TimedCachePolicy tcp;
+ if (defaultLifetime == null)
+ tcp = new TimedCachePolicy();
+ else if (resolution != null)
+ tcp = new TimedCachePolicy(defaultLifetime, threadSafe, resolution);
+ else
+ tcp = new TimedCachePolicy(defaultLifetime);
+
+ info = "TimedVFSCache{lifetime=" + tcp.getDefaultLifetime() + ", resolution=" + tcp.getResolution() + "}";
+
+ return tcp;
+ }
+
+ /**
+ * Set default lifetime.
+ *
+ * @param defaultLifetime the default lifetime
+ */
+ public void setDefaultLifetime(Integer defaultLifetime)
+ {
+ this.defaultLifetime = defaultLifetime;
+ }
+
+ /**
+ * Set threadsafe flag.
+ *
+ * @param threadSafe the threadsafe flag
+ */
+ public void setThreadSafe(Boolean threadSafe)
+ {
+ this.threadSafe = threadSafe;
+ }
+
+ /**
+ * The resollution.
+ *
+ * @param resolution the resolution
+ */
+ public void setResolution(Integer resolution)
+ {
+ this.resolution = resolution;
+ }
+
+ public String toString()
+ {
+ return info;
+ }
+}
\ No newline at end of file
Deleted: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,216 +0,0 @@
-/*
-* 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.vfs.helpers;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * PathTokenizer.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- * @version $Revision: 1.1 $
- */
- at SuppressWarnings({"StringEquality"})
-public class PathTokenizer
-{
- /** The reverse path const */
- private static final String CURRENT_PATH = ".";
-
- /** The reverse path const */
- private static final String REVERSE_PATH = "..";
-
- /**
- * Utility class
- */
- private PathTokenizer()
- {
- }
-
- /**
- * Get the remaining path from some tokens
- *
- * @param tokens the tokens
- * @param i the current location
- * @param end the end index
- * @return the remaining path
- * @throws IllegalArgumentException for null tokens or i is out of range
- */
- protected static String getRemainingPath(List<String> tokens, int i, int end)
- {
- if (tokens == null)
- throw new IllegalArgumentException("Null tokens");
- if (i < 0 || i >= end)
- throw new IllegalArgumentException("i is not in the range of tokens: 0-" + (end-1));
-
- if (i == end-1)
- return tokens.get(end-1);
-
- StringBuilder buffer = new StringBuilder();
- for (; i < end-1; ++i)
- {
- buffer.append(tokens.get(i));
- buffer.append("/");
- }
- buffer.append(tokens.get(end-1));
- return buffer.toString();
- }
-
- /**
- * Get the tokens
- *
- * @param path the path
- * @return the tokens or null if the path is empty
- * @throws IllegalArgumentException if the path is null, it is empty or it is a relative path
- */
- public static List<String> getTokens(String path)
- {
- if (path == null)
- throw new IllegalArgumentException("Null path");
-
- char[] chars = path.toCharArray();
- StringBuilder buffer = new StringBuilder();
- List<String> list = new ArrayList<String>();
- String specialToken = null;
-
- for (int index=0; index < chars.length; index++)
- {
- char ch = chars[index];
-
- if (ch == '/')
- {
- if (index > 0)
- {
- if (buffer.length() == 0 && specialToken == null)
- continue;
-
- if (specialToken != null)
- list.add(specialToken);
- else
- list.add(buffer.toString());
-
- // reset
- buffer.setLength(0);
- specialToken = null;
- }
- }
- else if (ch == '.')
- {
- if (specialToken == null && buffer.length() == 0)
- specialToken = CURRENT_PATH;
- else if (specialToken == CURRENT_PATH && buffer.length() == 0)
- specialToken = REVERSE_PATH;
- else if (specialToken != null && buffer.length() == 0)
- throw new IllegalArgumentException("Illegal token in path: " + path);
- else
- buffer.append(ch);
- }
- else
- {
- // token starts with '.' or '..', but also has some path after that
- if (specialToken != null)
- throw new IllegalArgumentException("Illegal token in path: " + path);
-
- buffer.append(ch);
- }
- }
-
- // add last token
- if (specialToken != null)
- list.add(specialToken);
- else if (buffer.length() > 0)
- list.add(buffer.toString());
-
- return list;
- }
-
- /**
- * Get the remaining path from some tokens
- *
- * @param tokens the tokens
- * @param i the current location
- * @return the remaining path
- * @throws IllegalArgumentException for null tokens or i is out of range
- */
- public static String getRemainingPath(List<String> tokens, int i)
- {
- if (tokens == null)
- throw new IllegalArgumentException("Null tokens");
-
- return getRemainingPath(tokens, i, tokens.size());
- }
-
- /**
- * Apply any . or .. paths in the path param.
- *
- * @param path the path
- * @return simple path, containing no . or .. paths
- * @throws IOException if reverse path goes over the top path
- */
- public static String applySpecialPaths(String path) throws IOException
- {
- List<String> tokens = getTokens(path);
- if (tokens == null)
- return null;
-
- int i = 0;
- for(int j = 0; j < tokens.size(); j++)
- {
- String token = tokens.get(j);
-
- if (isCurrentToken(token))
- continue;
- else if (isReverseToken(token))
- i--;
- else
- tokens.set(i++, token);
-
- if (i < 0)
- throw new IOException("Using reverse path on top path: " + path);
- }
- return getRemainingPath(tokens, 0, i);
- }
-
- /**
- * Is current token.
- *
- * @param token the token to check
- * @return true if token matches current path token
- */
- public static boolean isCurrentToken(String token)
- {
- return CURRENT_PATH == token;
- }
-
- /**
- * Is reverse token.
- *
- * @param token the token to check
- * @return true if token matches reverse path token
- */
- public static boolean isReverseToken(String token)
- {
- return REVERSE_PATH == token;
- }
-}
Copied: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/plugins/vfs/helpers/PathTokenizer.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,225 @@
+/*
+* 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.vfs.helpers;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * PathTokenizer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision: 1.1 $
+ */
+ at SuppressWarnings({"StringEquality"})
+public class PathTokenizer
+{
+ /** The reverse path const */
+ private static final String CURRENT_PATH = ".";
+
+ /** The reverse path const */
+ private static final String REVERSE_PATH = "..";
+
+ /**
+ * Utility class
+ */
+ private PathTokenizer()
+ {
+ }
+
+ /**
+ * Get the remaining path from some tokens
+ *
+ * @param tokens the tokens
+ * @param i the current location
+ * @param end the end index
+ * @return the remaining path
+ * @throws IllegalArgumentException for null tokens or i is out of range
+ */
+ protected static String getRemainingPath(List<String> tokens, int i, int end)
+ {
+ if (tokens == null)
+ throw new IllegalArgumentException("Null tokens");
+ if (i < 0 || i >= end)
+ throw new IllegalArgumentException("i is not in the range of tokens: 0-" + (end-1));
+
+ if (i == end-1)
+ return tokens.get(end-1);
+
+ StringBuilder buffer = new StringBuilder();
+ for (; i < end-1; ++i)
+ {
+ buffer.append(tokens.get(i));
+ buffer.append("/");
+ }
+ buffer.append(tokens.get(end-1));
+ return buffer.toString();
+ }
+
+ /**
+ * Get the tokens
+ *
+ * @param path the path
+ * @return the tokens or null if the path is empty
+ * @throws IllegalArgumentException if the path is null, it is empty or it is a relative path
+ */
+ public static List<String> getTokens(String path)
+ {
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+
+ char[] chars = path.toCharArray();
+ StringBuilder buffer = new StringBuilder();
+ List<String> list = new ArrayList<String>();
+ String specialToken = null;
+
+ for (int index=0; index < chars.length; index++)
+ {
+ char ch = chars[index];
+
+ if (ch == '/')
+ {
+ if (index > 0)
+ {
+ if (buffer.length() == 0 && specialToken == null)
+ continue;
+
+ if (specialToken != null)
+ list.add(specialToken);
+ else
+ list.add(buffer.toString());
+
+ // reset
+ buffer.setLength(0);
+ specialToken = null;
+ }
+ }
+ else if (ch == '.')
+ {
+ int bufferLength = buffer.length();
+
+ if (specialToken == null && bufferLength == 0)
+ specialToken = CURRENT_PATH;
+ else if (specialToken == CURRENT_PATH && bufferLength == 0)
+ specialToken = REVERSE_PATH;
+ else if (specialToken == REVERSE_PATH && bufferLength == 0)
+ throw new IllegalArgumentException("Illegal token (" + specialToken + ch + ") in path: " + path);
+ else
+ buffer.append(ch);
+ }
+ else
+ {
+ // token starts with '.' or '..', but also has some path after that
+ if (specialToken != null)
+ {
+ // we don't allow tokens after '..'
+ if (specialToken == REVERSE_PATH)
+ throw new IllegalArgumentException("Illegal token (" + specialToken + ch + ") in path: " + path);
+
+ // after '.' more path is legal == unix hidden directories
+ buffer.append(specialToken);
+ specialToken = null;
+ }
+ buffer.append(ch);
+ }
+ }
+
+ // add last token
+ if (specialToken != null)
+ list.add(specialToken);
+ else if (buffer.length() > 0)
+ list.add(buffer.toString());
+
+ return list;
+ }
+
+ /**
+ * Get the remaining path from some tokens
+ *
+ * @param tokens the tokens
+ * @param i the current location
+ * @return the remaining path
+ * @throws IllegalArgumentException for null tokens or i is out of range
+ */
+ public static String getRemainingPath(List<String> tokens, int i)
+ {
+ if (tokens == null)
+ throw new IllegalArgumentException("Null tokens");
+
+ return getRemainingPath(tokens, i, tokens.size());
+ }
+
+ /**
+ * Apply any . or .. paths in the path param.
+ *
+ * @param path the path
+ * @return simple path, containing no . or .. paths
+ * @throws IOException if reverse path goes over the top path
+ */
+ public static String applySpecialPaths(String path) throws IOException
+ {
+ List<String> tokens = getTokens(path);
+ if (tokens == null)
+ return null;
+
+ int i = 0;
+ for(int j = 0; j < tokens.size(); j++)
+ {
+ String token = tokens.get(j);
+
+ if (isCurrentToken(token))
+ continue;
+ else if (isReverseToken(token))
+ i--;
+ else
+ tokens.set(i++, token);
+
+ if (i < 0)
+ throw new IOException("Using reverse path on top path: " + path);
+ }
+ return getRemainingPath(tokens, 0, i);
+ }
+
+ /**
+ * Is current token.
+ *
+ * @param token the token to check
+ * @return true if token matches current path token
+ */
+ public static boolean isCurrentToken(String token)
+ {
+ return CURRENT_PATH == token;
+ }
+
+ /**
+ * Is reverse token.
+ *
+ * @param token the token to check
+ * @return true if token matches reverse path token
+ */
+ public static boolean isReverseToken(String token)
+ {
+ return REVERSE_PATH == token;
+ }
+}
Deleted: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,135 +0,0 @@
-/*
-* 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.spi.cache;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import org.jboss.logging.Logger;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.spi.cache.helpers.NoopVFSCache;
-
-/**
- * Simple vfs cache factory.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class VFSCacheFactory
-{
- private static final Object lock = new Object();
- private static Logger log = Logger.getLogger(VFSCacheFactory.class);
-
- private static VFSCache instance;
-
- private VFSCacheFactory()
- {
- }
-
- /**
- * Get VFS cache instance.
- *
- * @return the vfs cache instance
- */
- public static VFSCache getInstance()
- {
- return getInstance(null);
- }
- /**
- *
- * Get VFS cache instance.
- *
- * @param defaultCacheImpl - the possibly null name of the VFSCache
- * implementation to use. If null, the {@linkplain VFSUtils.VFS_CACHE_KEY}
- * system property will be used.
- *
- * @return the vfs cache instance
- */
- public static VFSCache getInstance(String defaultCacheImpl)
- {
- if (instance == null)
- {
- synchronized (lock)
- {
- if (instance == null)
- instance = AccessController.doPrivileged(new VFSCacheCreatorAction(defaultCacheImpl));
- }
- }
- return instance;
- }
-
- /**
- * Set instance.
- *
- * This should be used with care.
- * Better to leave it to getInstance method creation.
- *
- * @param cache cache instance to set
- */
- public static void setInstance(VFSCache cache)
- {
- if (cache != null && instance != null && instance instanceof NoopVFSCache == false)
- throw new IllegalArgumentException("Instance already set!");
-
- instance = cache;
- }
-
- private static class VFSCacheCreatorAction implements PrivilegedAction<VFSCache>
- {
- private String defaultCacheImpl;
- VFSCacheCreatorAction(String defaultCacheImpl)
- {
- this.defaultCacheImpl = defaultCacheImpl;
- }
-
- public VFSCache run()
- {
- try
- {
- // First look to the input cache imple
- String className = defaultCacheImpl;
- if(className == null || className.length() == 0)
- {
- // Else look at the VFS_CACHE_KEY system property
- className = System.getProperty(VFSUtils.VFS_CACHE_KEY);
- }
- if (className != null)
- {
- log.info("Initializing VFSCache [" + className + "] ...");
- ClassLoader cl = VFSCacheFactory.class.getClassLoader();
- Class<?> clazz = cl.loadClass(className);
- VFSCache cache = VFSCache.class.cast(clazz.newInstance());
- cache.start(); // start here, so we fall back to default no-op in case start fails
- log.info("Using VFSCache [" + cache + "] ...");
- return cache;
- }
- }
- catch (Throwable t)
- {
- log.warn("Exception instantiating VFS cache: ", t);
- }
- log.info("Using VFSCache [NoopVFSCache] ...");
- return new NoopVFSCache();
- }
- }
-}
Copied: projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/main/java/org/jboss/virtual/spi/cache/VFSCacheFactory.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,167 @@
+/*
+* 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.spi.cache;
+
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.spi.cache.helpers.NoopVFSCache;
+
+/**
+ * Simple vfs cache factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 80615 $
+ */
+public class VFSCacheFactory
+{
+ private static final Object lock = new Object();
+ private static Logger log = Logger.getLogger(VFSCacheFactory.class);
+
+ private static VFSCache instance;
+
+ private VFSCacheFactory()
+ {
+ }
+
+ /**
+ * Get VFS cache instance.
+ *
+ * @return the vfs cache instance
+ */
+ public static VFSCache getInstance()
+ {
+ return getInstance(null, null);
+ }
+
+ /**
+ *
+ * Get VFS cache instance.
+ *
+ * @param defaultCacheImpl - the possibly null name of the VFSCache
+ * implementation to use. If null, the {@linkplain VFSUtils.VFS_CACHE_KEY}
+ * system property will be used.
+ *
+ * @return the vfs cache instance
+ */
+ public static VFSCache getInstance(String defaultCacheImpl)
+ {
+ return getInstance(defaultCacheImpl, null);
+ }
+
+ /**
+ *
+ * Get VFS cache instance.
+ *
+ * @param defaultCacheImpl - the possibly null name of the VFSCache
+ * implementation to use. If null, the {@linkplain VFSUtils.VFS_CACHE_KEY}
+ * system property will be used.
+ * @param properties the possible vfs cache impl properties
+ *
+ * @return the vfs cache instance
+ */
+ public static VFSCache getInstance(String defaultCacheImpl, Map<Object, Object> properties)
+ {
+ if (instance == null)
+ {
+ synchronized (lock)
+ {
+ if (instance == null)
+ instance = AccessController.doPrivileged(new VFSCacheCreatorAction(defaultCacheImpl, properties));
+ }
+ }
+ return instance;
+ }
+
+ /**
+ * Set instance.
+ *
+ * This should be used with care.
+ * Better to leave it to getInstance method creation.
+ *
+ * @param cache cache instance to set
+ */
+ public static void setInstance(VFSCache cache)
+ {
+ if (cache != null && instance != null && instance instanceof NoopVFSCache == false)
+ throw new IllegalArgumentException("Instance already set!");
+
+ instance = cache;
+ }
+
+ private static class VFSCacheCreatorAction implements PrivilegedAction<VFSCache>
+ {
+ private String defaultCacheImpl;
+ private Map<Object, Object> properties;
+
+ VFSCacheCreatorAction(String defaultCacheImpl, Map<Object, Object> properties)
+ {
+ this.defaultCacheImpl = defaultCacheImpl;
+ this.properties = properties;
+ }
+
+ public VFSCache run()
+ {
+ try
+ {
+ // First look to the input cache imple
+ String className = defaultCacheImpl;
+ if(className == null || className.length() == 0)
+ {
+ // Else look at the VFS_CACHE_KEY system property
+ className = System.getProperty(VFSUtils.VFS_CACHE_KEY);
+ }
+ if (className != null)
+ {
+ log.info("Initializing VFSCache [" + className + "]");
+ ClassLoader cl = VFSCacheFactory.class.getClassLoader();
+ Class<?> clazz = cl.loadClass(className);
+ Object result;
+ if (properties != null)
+ {
+ Constructor<?> constructor = clazz.getConstructor(Map.class);
+ result = constructor.newInstance(properties);
+ }
+ else
+ {
+ result = clazz.newInstance();
+ }
+ VFSCache cache = VFSCache.class.cast(result);
+ cache.start(); // start here, so we fall back to default no-op in case start fails
+ log.info("Using VFSCache [" + cache + "]");
+ return cache;
+ }
+ }
+ catch (Throwable t)
+ {
+ log.warn("Exception instantiating VFS cache: ", t);
+ }
+ log.info("Using VFSCache [NoopVFSCache]");
+ return new NoopVFSCache();
+ }
+ }
+}
Deleted: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,49 +0,0 @@
-/*
-* 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.test.virtual.test;
-
-import junit.framework.Test;
-import org.jboss.virtual.plugins.cache.LRUVFSCache;
-import org.jboss.virtual.spi.cache.VFSCache;
-
-/**
- * LRU VFSCache Test.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- */
-public class LRUCacheTestCase extends CachePolicyVFSCacheTest
-{
- public LRUCacheTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(LRUCacheTestCase.class);
- }
-
- protected VFSCache createCache()
- {
- return new LRUVFSCache(2, 10);
- }
-}
\ No newline at end of file
Copied: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/LRUCacheTestCase.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,69 @@
+/*
+* 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.test.virtual.test;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.plugins.cache.LRUVFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
+
+/**
+ * LRU VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LRUCacheTestCase extends CachePolicyVFSCacheTest
+{
+ public LRUCacheTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(LRUCacheTestCase.class);
+ }
+
+ protected VFSCache createCache()
+ {
+ return new LRUVFSCache(2, 10);
+ }
+
+ protected Iterable<String> populateRequiredSystemProperties()
+ {
+ System.setProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.min", "2");
+ System.setProperty(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.max", "10");
+ return Arrays.asList(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.min", VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.max");
+ }
+
+ protected Map<Object, Object> getMap()
+ {
+ Map<Object, Object> map = new HashMap<Object, Object>();
+ map.put(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.min", 2);
+ map.put(VFSUtils.VFS_CACHE_KEY + ".LRUPolicyCaching.max", 10);
+ return map;
+ }
+}
\ No newline at end of file
Deleted: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,43 +0,0 @@
-/*
-* 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.test.virtual.test;
-
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * Map VFSCache Test.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- */
-public abstract class MapVFSCacheTest extends VFSCacheTest
-{
- public MapVFSCacheTest(String name)
- {
- super(name);
- }
-
- protected void testCachedContexts(Iterable<VFSContext> iter)
- {
- VFSContext context = iter.iterator().next();
- assertNotNull(context);
- }
-}
\ No newline at end of file
Copied: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/MapVFSCacheTest.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,50 @@
+/*
+* 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.test.virtual.test;
+
+import java.util.Map;
+
+import org.jboss.virtual.spi.VFSContext;
+
+/**
+ * Map VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class MapVFSCacheTest extends VFSCacheTest
+{
+ public MapVFSCacheTest(String name)
+ {
+ super(name);
+ }
+
+ protected Map<Object, Object> getMap()
+ {
+ return null;
+ }
+
+ protected void testCachedContexts(Iterable<VFSContext> iter)
+ {
+ VFSContext context = iter.iterator().next();
+ assertNotNull(context);
+ }
+}
\ No newline at end of file
Deleted: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,106 +0,0 @@
-/*
-* 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.test.virtual.test;
-
-import java.io.IOException;
-import java.net.URL;
-
-import junit.framework.Test;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Test path tokens.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class PathTokensTestCase extends AbstractVFSTest
-{
- public PathTokensTestCase(String s)
- {
- super(s);
- }
-
- public static Test suite()
- {
- return suite(PathTokensTestCase.class);
- }
-
- protected VirtualFile testPath(String path) throws IOException
- {
- return testPath("/vfs", path);
- }
-
- protected VirtualFile testPath(String context, String path) throws IOException
- {
- URL url = getResource(context);
- VirtualFile vf = VFS.getRoot(url);
- return vf.getChild(path);
- }
-
- protected void testValidPath(String path) throws Throwable
- {
- assertNotNull("No such path: " + path, testPath(path));
- }
-
- protected void testBrokenPath(String path) throws Throwable
- {
- try
- {
- testPath(path);
- fail("Should not be here");
- }
- catch (Throwable t)
- {
- assertInstanceOf(t, IllegalArgumentException.class, false);
- }
- }
-
- public void testSpecialTokens() throws Throwable
- {
- testBrokenPath("/.../");
- testBrokenPath(".../");
- testBrokenPath("/...");
- testBrokenPath("...");
- testBrokenPath("/..somemorepath/");
- testBrokenPath("..somemorepath/");
- testBrokenPath("/..somemorepath");
- testBrokenPath("..somemorepath");
- }
-
- public void testRepeatedSlashes() throws Throwable
- {
- testValidPath("/");
- testValidPath("//");
- testValidPath("///");
- testValidPath("////");
- testValidPath("//context");
- testValidPath("//context//");
- testValidPath("context//file");
- testValidPath("context///file");
- testValidPath("//context//file");
- testValidPath("//context///file");
- testValidPath("//context////file");
- testValidPath("//context///jar//");
- testValidPath("//context///jar///");
- }
-}
\ No newline at end of file
Copied: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/PathTokensTestCase.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,118 @@
+/*
+* 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.test.virtual.test;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+import java.util.Arrays;
+
+import junit.framework.Test;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.vfs.helpers.PathTokenizer;
+
+/**
+ * Test path tokens.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PathTokensTestCase extends AbstractVFSTest
+{
+ public PathTokensTestCase(String s)
+ {
+ super(s);
+ }
+
+ public static Test suite()
+ {
+ return suite(PathTokensTestCase.class);
+ }
+
+ protected VirtualFile testPath(String path) throws IOException
+ {
+ return testPath("/vfs", path);
+ }
+
+ protected VirtualFile testPath(String context, String path) throws IOException
+ {
+ URL url = getResource(context);
+ VirtualFile vf = VFS.getRoot(url);
+ return vf.getChild(path);
+ }
+
+ protected void testValidPath(String path) throws Throwable
+ {
+ assertNotNull("No such path: " + path, testPath(path));
+ }
+
+ protected void testBrokenPath(String path) throws Throwable
+ {
+ try
+ {
+ testPath(path);
+ fail("Should not be here");
+ }
+ catch (Throwable t)
+ {
+ assertInstanceOf(t, IllegalArgumentException.class, false);
+ }
+ }
+
+ public void testSpecialTokens() throws Throwable
+ {
+ testBrokenPath("/.../");
+ testBrokenPath(".../");
+ testBrokenPath("/...");
+ testBrokenPath("...");
+ testBrokenPath("/..somemorepath/");
+ testBrokenPath("..somemorepath/");
+ testBrokenPath("/..somemorepath");
+ testBrokenPath("..somemorepath");
+ }
+
+ public void testRepeatedSlashes() throws Throwable
+ {
+ testValidPath("/");
+ testValidPath("//");
+ testValidPath("///");
+ testValidPath("////");
+ testValidPath("//context");
+ testValidPath("//context//");
+ testValidPath("context//file");
+ testValidPath("context///file");
+ testValidPath("//context//file");
+ testValidPath("//context///file");
+ testValidPath("//context////file");
+ testValidPath("//context///jar//");
+ testValidPath("//context///jar///");
+ }
+
+ public void testHiddenUnixPath() throws Throwable
+ {
+ // the trick is the .hudson bit
+ String path = "/home/hudson/.hudson/";
+ List<String> tokens = PathTokenizer.getTokens(path);
+ List<String> expected = Arrays.asList("home", "hudson", ".hudson");
+ assertEquals(expected, tokens);
+ }
+}
\ No newline at end of file
Deleted: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,49 +0,0 @@
-/*
-* 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.test.virtual.test;
-
-import org.jboss.virtual.plugins.cache.TimedVFSCache;
-import org.jboss.virtual.spi.cache.VFSCache;
-import junit.framework.Test;
-
-/**
- * Timed VFSCache Test.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- */
-public class TimedCacheTestCase extends CachePolicyVFSCacheTest
-{
- public TimedCacheTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(TimedCacheTestCase.class);
- }
-
- protected VFSCache createCache()
- {
- return new TimedVFSCache(60);
- }
-}
\ No newline at end of file
Copied: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/TimedCacheTestCase.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,60 @@
+/*
+* 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.test.virtual.test;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import org.jboss.virtual.plugins.cache.TimedVFSCache;
+import org.jboss.virtual.spi.cache.VFSCache;
+import org.jboss.virtual.VFSUtils;
+import junit.framework.Test;
+
+/**
+ * Timed VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TimedCacheTestCase extends CachePolicyVFSCacheTest
+{
+ public TimedCacheTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(TimedCacheTestCase.class);
+ }
+
+ protected VFSCache createCache()
+ {
+ return new TimedVFSCache(5);
+ }
+
+ protected Map<Object, Object> getMap()
+ {
+ Map<Object, Object> map = new HashMap<Object, Object>();
+ map.put(VFSUtils.VFS_CACHE_KEY + ".TimedPolicyCaching.lifetime", 5);
+ return map;
+ }
+}
\ No newline at end of file
Deleted: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java
===================================================================
--- projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java 2008-11-07 10:57:33 UTC (rev 80637)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -1,166 +0,0 @@
-/*
-* 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.test.virtual.test;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.spi.cache.VFSCache;
-import org.jboss.virtual.spi.cache.VFSCacheFactory;
-import org.jboss.virtual.spi.cache.CacheStatistics;
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * VFSCache Test.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- */
-public abstract class VFSCacheTest extends AbstractVFSTest
-{
- public VFSCacheTest(String name)
- {
- super(name);
- }
-
- protected abstract VFSCache createCache();
-
- @SuppressWarnings("deprecation")
- public void testCache() throws Exception
- {
- URL url = getResource("/vfs/test/nested");
-
- VFSCache cache = createCache();
- cache.start();
- try
- {
- VFSCacheFactory.setInstance(cache);
- try
- {
- VirtualFile root = VFS.getRoot(url);
-
- VirtualFile file = root.findChild("/nested.jar/META-INF/empty.txt");
- URL fileURL = file.toURL();
- VirtualFile nested = root.findChild("/nested.jar/complex.jar/subfolder/subsubfolder/subsubchild");
- URL nestedURL = nested.toURL();
-
- assertEquals(file, cache.getFile(fileURL));
- assertEquals(nested, cache.getFile(nestedURL));
-
- VFSCacheFactory.setInstance(null);
- VFSCache wrapper = new WrapperVFSCache(cache);
- VFSCacheFactory.setInstance(wrapper);
-
- assertEquals(file, wrapper.getFile(fileURL));
- assertEquals(nested, wrapper.getFile(nestedURL));
- }
- finally
- {
- VFSCacheFactory.setInstance(null);
- }
- }
- finally
- {
- cache.stop();
- }
- }
-
- protected abstract void testCachedContexts(Iterable<VFSContext> iter);
-
- public void testCacheStatistics() throws Exception
- {
- URL url = getResource("/vfs/test/nested");
-
- VFSCache cache = createCache();
- cache.start();
- try
- {
- if (cache instanceof CacheStatistics)
- {
- CacheStatistics statistics = CacheStatistics.class.cast(cache);
- VFSCacheFactory.setInstance(cache);
- try
- {
- VirtualFile root = VFS.getRoot(url);
- assertNotNull(root);
-
- Iterable<VFSContext> iter = statistics.getCachedContexts();
- testCachedContexts(iter);
-
- assertEquals(1, statistics.size());
- assertTrue(statistics.lastInsert() != 0);
- }
- finally
- {
- VFSCacheFactory.setInstance(null);
- }
- }
- }
- finally
- {
- cache.stop();
- }
- }
-
- private class WrapperVFSCache implements VFSCache
- {
- private VFSCache delegate;
-
- private WrapperVFSCache(VFSCache delegate)
- {
- this.delegate = delegate;
- }
-
- public VirtualFile getFile(URI uri) throws IOException
- {
- return delegate.getFile(uri);
- }
-
- public VirtualFile getFile(URL url) throws IOException
- {
- return delegate.getFile(url);
- }
-
- public void putContext(VFSContext context)
- {
- throw new IllegalArgumentException("Context should already be there: " + context);
- }
-
- public void removeContext(VFSContext context)
- {
- }
-
- public void start() throws Exception
- {
- }
-
- public void stop()
- {
- }
-
- public void flush()
- {
- }
- }
-}
\ No newline at end of file
Copied: projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java (from rev 80639, projects/vfs/branches/Branch_2_0/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java)
===================================================================
--- projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java (rev 0)
+++ projects/vfs/tags/2.0.0.CR5/src/test/java/org/jboss/test/virtual/test/VFSCacheTest.java 2008-11-07 11:55:51 UTC (rev 80641)
@@ -0,0 +1,220 @@
+/*
+* 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.test.virtual.test;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Map;
+
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.spi.VFSContext;
+import org.jboss.virtual.spi.cache.CacheStatistics;
+import org.jboss.virtual.spi.cache.VFSCache;
+import org.jboss.virtual.spi.cache.VFSCacheFactory;
+import org.jboss.virtual.spi.cache.helpers.NoopVFSCache;
+
+/**
+ * VFSCache Test.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class VFSCacheTest extends AbstractVFSTest
+{
+ public VFSCacheTest(String name)
+ {
+ super(name);
+ }
+
+ protected abstract VFSCache createCache();
+
+ @SuppressWarnings("deprecation")
+ public void testCache() throws Exception
+ {
+ URL url = getResource("/vfs/test/nested");
+
+ VFSCache cache = createCache();
+ cache.start();
+ try
+ {
+ VFSCacheFactory.setInstance(cache);
+ try
+ {
+ VirtualFile root = VFS.getRoot(url);
+
+ VirtualFile file = root.findChild("/nested.jar/META-INF/empty.txt");
+ URL fileURL = file.toURL();
+ VirtualFile nested = root.findChild("/nested.jar/complex.jar/subfolder/subsubfolder/subsubchild");
+ URL nestedURL = nested.toURL();
+
+ assertEquals(file, cache.getFile(fileURL));
+ assertEquals(nested, cache.getFile(nestedURL));
+
+ VFSCacheFactory.setInstance(null);
+ VFSCache wrapper = new WrapperVFSCache(cache);
+ VFSCacheFactory.setInstance(wrapper);
+
+ assertEquals(file, wrapper.getFile(fileURL));
+ assertEquals(nested, wrapper.getFile(nestedURL));
+ }
+ finally
+ {
+ VFSCacheFactory.setInstance(null);
+ }
+ }
+ finally
+ {
+ cache.stop();
+ }
+ }
+
+ protected abstract void testCachedContexts(Iterable<VFSContext> iter);
+
+ public void testCacheStatistics() throws Exception
+ {
+ URL url = getResource("/vfs/test/nested");
+
+ VFSCache cache = createCache();
+ cache.start();
+ try
+ {
+ if (cache instanceof CacheStatistics)
+ {
+ CacheStatistics statistics = CacheStatistics.class.cast(cache);
+ VFSCacheFactory.setInstance(cache);
+ try
+ {
+ VirtualFile root = VFS.getRoot(url);
+ assertNotNull(root);
+
+ Iterable<VFSContext> iter = statistics.getCachedContexts();
+ testCachedContexts(iter);
+
+ assertEquals(1, statistics.size());
+ assertTrue(statistics.lastInsert() != 0);
+ }
+ finally
+ {
+ VFSCacheFactory.setInstance(null);
+ }
+ }
+ }
+ finally
+ {
+ cache.stop();
+ }
+ }
+
+ protected Class<? extends VFSCache> getCacheClass()
+ {
+ VFSCache cache = createCache();
+ return cache.getClass();
+ }
+
+ protected Iterable<String> populateRequiredSystemProperties()
+ {
+ return Collections.emptySet();
+ }
+
+ protected abstract Map<Object, Object> getMap();
+
+ public void testCacheFactory() throws Exception
+ {
+ VFSCache cache;
+ String cacheClassName = getCacheClass().getName();
+
+ VFSCacheFactory.setInstance(null);
+ try
+ {
+ Iterable<String> keys = populateRequiredSystemProperties();
+ try
+ {
+ cache = VFSCacheFactory.getInstance(cacheClassName);
+ assertNotNull(cache);
+ assertTrue(cache instanceof NoopVFSCache == false);
+ cache.flush();
+ }
+ finally
+ {
+ for (String key : keys)
+ System.clearProperty(key);
+ }
+
+ VFSCacheFactory.setInstance(null);
+
+ VFSCache mapParamCache = VFSCacheFactory.getInstance(cacheClassName, getMap());
+ // need new instance, so we know we're really testing map parameter
+ assertNotSame(cache, mapParamCache);
+ cache = mapParamCache;
+ assertNotNull(cache);
+ assertTrue(cache instanceof NoopVFSCache == false);
+ cache.flush();
+ }
+ finally
+ {
+ VFSCacheFactory.setInstance(null);
+ }
+ }
+
+ private class WrapperVFSCache implements VFSCache
+ {
+ private VFSCache delegate;
+
+ private WrapperVFSCache(VFSCache delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public VirtualFile getFile(URI uri) throws IOException
+ {
+ return delegate.getFile(uri);
+ }
+
+ public VirtualFile getFile(URL url) throws IOException
+ {
+ return delegate.getFile(url);
+ }
+
+ public void putContext(VFSContext context)
+ {
+ throw new IllegalArgumentException("Context should already be there: " + context);
+ }
+
+ public void removeContext(VFSContext context)
+ {
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public void flush()
+ {
+ }
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list