You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2012/06/20 22:27:40 UTC

svn commit: r1352301 - in /struts/struts2/trunk: core/src/main/java/org/apache/struts2/ core/src/main/java/org/apache/struts2/dispatcher/ core/src/main/java/org/apache/struts2/util/fs/ core/src/main/resources/ core/src/test/java/org/apache/struts2/disp...

Author: lukaszlenart
Date: Wed Jun 20 20:27:39 2012
New Revision: 1352301

URL: http://svn.apache.org/viewvc?rev=1352301&view=rev
Log:
WW-3818 - extracts JBoss specific code into JBossFileManager and some code clean ups

Added:
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java
Removed:
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JBossFileRevision.java
Modified:
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
    struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/fs/JBossFileManager.java
    struts/struts2/trunk/core/src/main/resources/struts-default.xml
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
    struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java
    struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
    struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
    struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPLoader.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/FileRevision.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/Revision.java
    struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java
    struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java
    struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactoryTest.java
    struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java Wed Jun 20 20:27:39 2012
@@ -67,6 +67,9 @@ public final class StrutsConstants {
     /** The com.opensymphony.xwork2.util.FileManager implementation class */
     public static final String STRUTS_FILE_MANAGER_FACTORY = "struts.fileManagerFactory";
 
+    /** The com.opensymphony.xwork2.util.fs.FileManager implementation class */
+    public static final String STRUTS_FILE_MANAGER = "struts.fileManager";
+
     /** The com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation class */
     public static final String STRUTS_OBJECTTYPEDETERMINER = "struts.objectTypeDeterminer";
 

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java Wed Jun 20 20:27:39 2012
@@ -32,6 +32,8 @@ import com.opensymphony.xwork2.config.Co
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
+import com.opensymphony.xwork2.config.FileManagerFactoryProvider;
+import com.opensymphony.xwork2.config.FileManagerProvider;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.entities.InterceptorStackConfig;
 import com.opensymphony.xwork2.config.entities.PackageConfig;
@@ -64,6 +66,7 @@ import org.apache.struts2.dispatcher.mul
 import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
 import org.apache.struts2.util.AttributeMap;
 import org.apache.struts2.util.ObjectFactoryDestroyable;
+import org.apache.struts2.util.fs.JBossFileManager;
 import org.apache.struts2.views.freemarker.FreemarkerManager;
 
 import javax.servlet.ServletContext;
@@ -306,6 +309,28 @@ public class Dispatcher {
     	configurationManager = null;
     }
 
+    private void init_FileManager() throws ClassNotFoundException {
+        if (initParams.containsKey(StrutsConstants.STRUTS_FILE_MANAGER)) {
+            final String fileManagerClassName = initParams.get(StrutsConstants.STRUTS_FILE_MANAGER);
+            final Class<FileManager> fileManagerClass = (Class<FileManager>) Class.forName(fileManagerClassName);
+            if (LOG.isInfoEnabled()) {
+                LOG.info("Custom FileManager specified: #0", fileManagerClassName);
+            }
+            configurationManager.addContainerProvider(new FileManagerProvider(fileManagerClass, fileManagerClass.getSimpleName()));
+        } else {
+            // add any other Struts 2 provided implementations of FileManager
+            configurationManager.addContainerProvider(new FileManagerProvider(JBossFileManager.class, "jboss"));
+        }
+        if (initParams.containsKey(StrutsConstants.STRUTS_FILE_MANAGER_FACTORY)) {
+            final String fileManagerFactoryClassName = initParams.get(StrutsConstants.STRUTS_FILE_MANAGER_FACTORY);
+            final Class<FileManagerFactory> fileManagerFactoryClass = (Class<FileManagerFactory>) Class.forName(fileManagerFactoryClassName);
+            if (LOG.isInfoEnabled()) {
+                LOG.info("Custom FileManagerFactory specified: #0", fileManagerFactoryClassName);
+            }
+            configurationManager.addContainerProvider(new FileManagerFactoryProvider(fileManagerFactoryClass));
+        }
+    }
+
     private void init_DefaultProperties() {
         configurationManager.addContainerProvider(new DefaultPropertiesProvider());
     }
@@ -427,6 +452,7 @@ public class Dispatcher {
     	}
 
         try {
+            init_FileManager();
             init_DefaultProperties(); // [1]
             init_TraditionalXmlConfigurations(); // [2]
             init_LegacyStrutsProperties(); // [3]

Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/fs/JBossFileManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/fs/JBossFileManager.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/fs/JBossFileManager.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/fs/JBossFileManager.java Wed Jun 20 20:27:39 2012
@@ -1,10 +1,172 @@
 package org.apache.struts2.util.fs;
 
 import com.opensymphony.xwork2.util.fs.DefaultFileManager;
+import com.opensymphony.xwork2.util.fs.FileRevision;
+import com.opensymphony.xwork2.util.fs.Revision;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 /**
- * TODO lukaszlenart: move implementation from DefaultFileManager
+ * FileManager implementation used with JBoss AS
  */
 public class JBossFileManager extends DefaultFileManager {
 
+    private static final Logger LOG = LoggerFactory.getLogger(JBossFileManager.class);
+
+    private static final String JBOSS5_VFS = "vfs";
+    private static final String JBOSS5_VFSZIP = "vfszip";
+    private static final String JBOSS5_VFSMEMORY = "vfsmemory";
+    private static final String JBOSS5_VFSFILE = "vfsfile";
+
+    private static final String VFS_JBOSS7 = "org.jboss.vfs.VirtualFile";
+    private static final String VFS_JBOSS5 = "org.jboss.virtual.VirtualFile";
+
+    @Override
+    public boolean support() {
+        boolean supports = isJBoss7() || isJBoss5();
+        if (supports && LOG.isInfoEnabled()) {
+            LOG.info("JBoss server detected, Struts 2 will use [#0] to support file system operations!", JBossFileManager.class.getSimpleName());
+        }
+        return supports;
+    }
+
+    private boolean isJBoss5() {
+        try {
+            Class.forName(VFS_JBOSS5);
+            return true;
+        } catch (ClassNotFoundException e) {
+            LOG.debug("Cannot load [#0] class, not a JBoss 5!", VFS_JBOSS7);
+            return false;
+        }
+    }
+
+    private boolean isJBoss7() {
+        try {
+            Class.forName(VFS_JBOSS7);
+            return true;
+        } catch (ClassNotFoundException e) {
+            LOG.debug("Cannot load [#0] class, not a JBoss 7!", VFS_JBOSS7);
+            return false;
+        }
+    }
+
+    @Override
+    public void monitorFile(URL fileUrl) {
+        if (isReloadingConfigs()) {
+            if (isJBossUrl(fileUrl)) {
+                Revision revision = FileRevision.build(normalizeToFileProtocol(fileUrl));
+                files.put(fileUrl.toString(), revision);
+            } else {
+                super.monitorFile(fileUrl);
+            }
+        }
+    }
+
+    @Override
+    public URL normalizeToFileProtocol(URL url) {
+        if (isJBossUrl(url))                {
+            try {
+                return getJBossPhysicalUrl(url);
+            } catch (IOException e) {
+                LOG.error(e.getMessage(), e);
+                return null;
+            }
+        } else {
+            return super.normalizeToFileProtocol(url);
+        }
+    }
+
+    @Override
+    public Collection<? extends URL> getAllPhysicalUrls(URL url) throws IOException {
+        if (isJBossUrl(url)) {
+            return getAllJBossPhysicalUrls(url);
+        } else {
+            return super.getAllPhysicalUrls(url);
+        }
+    }
+
+    /**
+     * Check if given URL is pointing to JBoss 5 VFS resource
+     * @param fileUrl
+     * @return
+     */
+    protected boolean isJBossUrl(URL fileUrl) {
+        final String protocol = fileUrl.getProtocol();
+        return JBOSS5_VFSZIP.equals(protocol) || JBOSS5_VFSMEMORY.equals(protocol) || JBOSS5_VFS.equals(protocol)
+                || ("true".equals(System.getProperty("jboss.vfs.forceVfsJar")) && JBOSS5_VFSFILE.equals(protocol));
+    }
+
+    /**
+     * Try to determine physical file location.
+     *
+     * @param url JBoss VFS URL
+     * @return URL pointing to physical file or original URL
+     * @throws java.io.IOException If conversion fails
+     */
+    protected URL getJBossPhysicalUrl(URL url) throws IOException {
+        Object content = url.openConnection().getContent();
+        try {
+            String s = content.getClass().toString();
+            if (s.startsWith("class org.jboss.vfs.VirtualFile")) { // JBoss 7 and probably 6
+                File physicalFile = readJBossPhysicalFile(content);
+                return physicalFile.toURI().toURL();
+            } else if (s.startsWith("class org.jboss.virtual.VirtualFile")) { // JBoss 5
+                String fileName = url.toExternalForm();
+                return new URL("file", null, fileName.substring(fileName.indexOf(":") + 1));
+            }
+        } catch (Exception e) {
+            LOG.warn("Error calling getPhysicalFile() on JBoss VirtualFile.", e);
+        }
+        return url;
+    }
+
+    private File readJBossPhysicalFile(Object content) throws Exception {
+        Method method = content.getClass().getDeclaredMethod("getPhysicalFile");
+        return (File) method.invoke(content);
+    }
+
+    private List<URL> getAllJBossPhysicalUrls(URL url) throws IOException {
+        List<URL> urls = new ArrayList<URL>();
+        Object content = url.openConnection().getContent();
+        try {
+            if (content.getClass().toString().startsWith("class org.jboss.vfs.VirtualFile")) {
+                File physicalFile = readJBossPhysicalFile(content);
+                readFile(urls, physicalFile);
+                readFile(urls, physicalFile.getParentFile());
+            } else {
+                urls.add(url);
+            }
+        } catch (Exception e) {
+            LOG.warn("Error calling getPhysicalFile() on JBoss VirtualFile.", e);
+        }
+        return urls;
+    }
+
+    private void readFile(List<URL> urls, File physicalFile) throws MalformedURLException {
+        if (physicalFile.isDirectory()) {
+            for (File file : physicalFile.listFiles()) {
+                if (file.isFile()) {
+                    addIfAbsent(urls, file.toURI().toURL());
+                } else if (file.isDirectory()) {
+                    readFile(urls, file);
+                }
+            }
+        }
+    }
+
+    private void addIfAbsent(List<URL> urls, URL fileUrl) {
+        if (!urls.contains(fileUrl)) {
+            urls.add(fileUrl);
+        }
+    }
+
 }

Modified: struts/struts2/trunk/core/src/main/resources/struts-default.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/struts-default.xml?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/struts-default.xml (original)
+++ struts/struts2/trunk/core/src/main/resources/struts-default.xml Wed Jun 20 20:27:39 2012
@@ -29,6 +29,8 @@
     <bean class="com.opensymphony.xwork2.ObjectFactory" name="xwork" />
     <bean type="com.opensymphony.xwork2.ObjectFactory" name="struts" class="org.apache.struts2.impl.StrutsObjectFactory" />
 
+    <bean type="com.opensymphony.xwork2.FileManager" class="com.opensymphony.xwork2.util.fs.DefaultFileManager" name="system"/>
+
     <bean type="com.opensymphony.xwork2.FileManagerFactory" class="com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory" name="xwork"/>
     <bean type="com.opensymphony.xwork2.FileManagerFactory" class="com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory" name="struts"/>
 

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java Wed Jun 20 20:27:39 2012
@@ -198,7 +198,8 @@ public class DispatcherTest extends Stru
         mockContainer.expectAndReturn("getInstance", C.args(C.eq(ObjectFactory.class)), destroyedObjectFactory);
         mockConfiguration.expectAndReturn("getContainer", mockContainer.proxy());
         mockConfiguration.expectAndReturn("getContainer", mockContainer.proxy());
-        FileManagerFactory fileManagerFactory = new DefaultFileManagerFactory(container);
+        FileManagerFactory fileManagerFactory = new DefaultFileManagerFactory();
+        container.inject(fileManagerFactory);
         mockContainer.expectAndReturn("getInstance", C.args(C.eq(FileManagerFactory.class)), fileManagerFactory);
         mockContainer.expectAndReturn("getInstance", C.args(C.eq(FileManagerFactory.class)), fileManagerFactory);
         mockConfiguration.expect("destroy");
@@ -228,7 +229,9 @@ public class DispatcherTest extends Stru
         
         Mock mockContainer = new Mock(Container.class);
         mockContainer.matchAndReturn("getInstance", C.args(C.eq(ObjectFactory.class)), new ObjectFactory());
-        mockContainer.matchAndReturn("getInstance", C.args(C.eq(FileManagerFactory.class)), new DefaultFileManagerFactory(container));
+        DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
+        container.inject(factory);
+        mockContainer.matchAndReturn("getInstance", C.args(C.eq(FileManagerFactory.class)), factory);
 
         Mock mockConfiguration = new Mock(Configuration.class);
         mockConfiguration.matchAndReturn("getPackageConfigs", packageConfigs);

Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java (original)
+++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java Wed Jun 20 20:27:39 2012
@@ -34,7 +34,9 @@ public class FreemarkerManagerTest exten
     public void testIfStrutsEncodingIsSetProperty() throws Exception {
         FreemarkerManager mgr = new FreemarkerManager();
         mgr.setEncoding("UTF-8");
-        mgr.setFileManagerFactory(new DefaultFileManagerFactory(container));
+        DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
+        container.inject(factory);
+        mgr.setFileManagerFactory(factory);
         StrutsMockServletContext servletContext = new StrutsMockServletContext();
         servletContext.setAttribute(FreemarkerManager.CONFIG_SERVLET_CONTEXT_KEY, null);
         freemarker.template.Configuration conf = mgr.getConfiguration(servletContext);

Modified: struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java (original)
+++ struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java Wed Jun 20 20:27:39 2012
@@ -399,7 +399,7 @@ public class PackageBasedActionConfigBui
 
     private UrlSet buildUrlSet() throws IOException {
         ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
-        UrlSet urlSet = new UrlSet(classLoaderInterface, this.fileProtocols);
+        UrlSet urlSet = new UrlSet(fileManager, classLoaderInterface, this.fileProtocols);
 
         //excluding the urls found by the parent class loader is desired, but fails in JBoss (all urls are removed)
         if (excludeParentClassLoader) {
@@ -472,7 +472,7 @@ public class PackageBasedActionConfigBui
                     }
                 }
             }
-            return new UrlSet(includeUrls);
+            return new UrlSet(fileManager, includeUrls);
         }
 
         return urlSet;

Modified: struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java (original)
+++ struts/struts2/trunk/plugins/convention/src/test/java/org/apache/struts2/convention/PackageBasedActionConfigBuilderTest.java Wed Jun 20 20:27:39 2012
@@ -39,6 +39,7 @@ import com.opensymphony.xwork2.config.im
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Scope.Strategy;
 import com.opensymphony.xwork2.ognl.OgnlReflectionProvider;
+import com.opensymphony.xwork2.util.fs.DefaultFileManager;
 import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
 import com.opensymphony.xwork2.util.reflection.ReflectionException;
 import junit.framework.TestCase;
@@ -350,6 +351,10 @@ public class PackageBasedActionConfigBui
         if (excludePackages != null) {
             builder.setExcludePackages(excludePackages);
         }
+        DefaultFileManagerFactory fileManagerFactory = new DefaultFileManagerFactory();
+        fileManagerFactory.setContainer(ActionContext.getContext().getContainer());
+        fileManagerFactory.setFileManager(new DefaultFileManager());
+        builder.setFileManagerFactory(fileManagerFactory);
         builder.setPackageLocatorsBase("org.apache.struts2.convention.actions");
         builder.buildActionConfigs();
         verify(resultMapBuilder);
@@ -694,7 +699,9 @@ public class PackageBasedActionConfigBui
         private DefaultFileManagerFactory fileManagerFactory;
 
         public DummyContainer() {
-            fileManagerFactory = new DefaultFileManagerFactory(this);
+            fileManagerFactory = new DefaultFileManagerFactory();
+            fileManagerFactory.setContainer(this);
+            fileManagerFactory.setFileManager(new DefaultFileManager());
         }
 
         public void setActionNameBuilder(ActionNameBuilder actionNameBuilder) {

Modified: struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPLoader.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPLoader.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPLoader.java (original)
+++ struts/struts2/trunk/plugins/embeddedjsp/src/main/java/org/apache/struts2/JSPLoader.java Wed Jun 20 20:27:39 2012
@@ -180,14 +180,15 @@ public class JSPLoader {
         List<String> optionList = new ArrayList<String>();
         Set<String> classPath = new HashSet<String>();
 
+        FileManager fileManager = ServletActionContext.getContext().getInstance(FileManagerFactory.class).getFileManager();
+
         //find available jars
         ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
-        UrlSet urlSet = new UrlSet(classLoaderInterface);
+        UrlSet urlSet = new UrlSet(fileManager, classLoaderInterface);
 
         //find jars
         List<URL> urls = urlSet.getUrls();
 
-        FileManager fileManager = ServletActionContext.getContext().getInstance(FileManagerFactory.class).getFileManager();
         for (URL url : urls) {
             URL normalizedUrl = fileManager.normalizeToFileProtocol(url);
             File file = FileUtils.toFile(ObjectUtils.defaultIfNull(normalizedUrl, url));

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/FileManager.java Wed Jun 20 20:27:39 2012
@@ -60,5 +60,13 @@ public interface FileManager {
      */
     boolean support();
 
+    /**
+     * User's implementation should return false as then it will be taken in first place
+     *
+     * @return true if it's a framework provided implementation
+     */
+    boolean internal();
+
     Collection<? extends URL> getAllPhysicalUrls(URL url) throws IOException;
+
 }

Added: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java?rev=1352301&view=auto
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java (added)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerFactoryProvider.java Wed Jun 20 20:27:39 2012
@@ -0,0 +1,33 @@
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.FileManagerFactory;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.inject.Scope;
+import com.opensymphony.xwork2.util.location.LocatableProperties;
+
+/**
+ * Allows to specify custom {@link FileManagerFactory}
+ */
+public class FileManagerFactoryProvider implements ContainerProvider {
+
+    private Class<? extends FileManagerFactory> factoryClass;
+
+    public FileManagerFactoryProvider(Class<? extends FileManagerFactory> factoryClass) {
+        this.factoryClass = factoryClass;
+    }
+
+    public void destroy() {
+    }
+
+    public void init(Configuration configuration) throws ConfigurationException {
+    }
+
+    public boolean needsReload() {
+        return false;
+    }
+
+    public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
+        builder.factory(FileManagerFactory.class, factoryClass.getSimpleName(), factoryClass, Scope.SINGLETON);
+    }
+
+}

Added: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java?rev=1352301&view=auto
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java (added)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/FileManagerProvider.java Wed Jun 20 20:27:39 2012
@@ -0,0 +1,35 @@
+package com.opensymphony.xwork2.config;
+
+import com.opensymphony.xwork2.FileManager;
+import com.opensymphony.xwork2.inject.ContainerBuilder;
+import com.opensymphony.xwork2.inject.Scope;
+import com.opensymphony.xwork2.util.location.LocatableProperties;
+
+/**
+ * Allows to specify custom {@link FileManager} by user
+ */
+public class FileManagerProvider implements ContainerProvider {
+
+    private Class<? extends FileManager> fileManagerClass;
+    private String name;
+
+    public FileManagerProvider(Class<? extends FileManager> fileManagerClass, String name) {
+        this.fileManagerClass = fileManagerClass;
+        this.name = name;
+    }
+
+    public void destroy() {
+    }
+
+    public void init(Configuration configuration) throws ConfigurationException {
+    }
+
+    public boolean needsReload() {
+        return false;
+    }
+
+    public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
+        builder.factory(FileManager.class, name, fileManagerClass, Scope.SINGLETON);
+    }
+
+}

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java Wed Jun 20 20:27:39 2012
@@ -17,6 +17,7 @@ package com.opensymphony.xwork2.config.i
 
 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.DefaultTextProvider;
+import com.opensymphony.xwork2.FileManager;
 import com.opensymphony.xwork2.FileManagerFactory;
 import com.opensymphony.xwork2.ObjectFactory;
 import com.opensymphony.xwork2.TextProvider;
@@ -24,6 +25,8 @@ import com.opensymphony.xwork2.config.Co
 import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.ContainerProvider;
+import com.opensymphony.xwork2.config.FileManagerFactoryProvider;
+import com.opensymphony.xwork2.config.FileManagerProvider;
 import com.opensymphony.xwork2.config.PackageProvider;
 import com.opensymphony.xwork2.config.RuntimeConfiguration;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
@@ -56,6 +59,7 @@ import com.opensymphony.xwork2.util.Comp
 import com.opensymphony.xwork2.util.PatternMatcher;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
+import com.opensymphony.xwork2.util.fs.DefaultFileManager;
 import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 import com.opensymphony.xwork2.util.logging.Logger;
@@ -202,7 +206,7 @@ public class DefaultConfiguration implem
 
         ContainerProperties props = new ContainerProperties();
         ContainerBuilder builder = new ContainerBuilder();
-        Container bootstrap = createBootstrapContainer();
+        Container bootstrap = createBootstrapContainer(providers);
         for (final ContainerProvider containerProvider : providers)
         {
             bootstrap.inject(containerProvider);
@@ -264,10 +268,23 @@ public class DefaultConfiguration implem
         return context;
     }
 
-    protected Container createBootstrapContainer() {
+    protected Container createBootstrapContainer(List<ContainerProvider> providers) {
         ContainerBuilder builder = new ContainerBuilder();
+        boolean fmFactoryRegistered = false;
+        for (ContainerProvider provider : providers) {
+            if (provider instanceof FileManagerProvider) {
+                provider.register(builder, null);
+            }
+            if (provider instanceof FileManagerFactoryProvider) {
+                provider.register(builder, null);
+                fmFactoryRegistered = true;
+            }
+        }
         builder.factory(ObjectFactory.class, Scope.SINGLETON);
-        builder.factory(FileManagerFactory.class, DefaultFileManagerFactory.class, Scope.SINGLETON);
+        builder.factory(FileManager.class, "system", DefaultFileManager.class, Scope.SINGLETON);
+        if (!fmFactoryRegistered) {
+            builder.factory(FileManagerFactory.class, DefaultFileManagerFactory.class, Scope.SINGLETON);
+        }
         builder.factory(ReflectionProvider.class, OgnlReflectionProvider.class, Scope.SINGLETON);
         builder.factory(ValueStackFactory.class, OgnlValueStackFactory.class, Scope.SINGLETON);
         builder.factory(XWorkConverter.class, Scope.SINGLETON);

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/config/providers/XWorkConfigurationProvider.java Wed Jun 20 20:27:39 2012
@@ -91,6 +91,7 @@ public class XWorkConfigurationProvider 
                 .factory(ActionProxyFactory.class, DefaultActionProxyFactory.class, Scope.SINGLETON)
                 .factory(ObjectTypeDeterminer.class, DefaultObjectTypeDeterminer.class, Scope.SINGLETON)
                 .factory(XWorkConverter.class, Scope.SINGLETON)
+                .factory(FileManager.class, "system", DefaultFileManager.class, Scope.SINGLETON)
                 .factory(FileManagerFactory.class, DefaultFileManagerFactory.class, Scope.SINGLETON)
                 .factory(ValueStackFactory.class, OgnlValueStackFactory.class, Scope.SINGLETON)
                 .factory(ValidatorFactory.class, DefaultValidatorFactory.class, Scope.SINGLETON)

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/ClassFinder.java Wed Jun 20 20:27:39 2012
@@ -45,7 +45,6 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -80,72 +79,6 @@ public class ClassFinder {
     private ClassLoaderInterface classLoaderInterface;
     private FileManager fileManager;
 
-    /**
-     * Creates a ClassFinder that will search the urls in the specified ClassLoaderInterface
-     * excluding the urls in the ClassLoaderInterface's parent.
-     *
-     * To include the parent ClassLoaderInterface, use:
-     *
-     *    new ClassFinder(ClassLoaderInterface, false);
-     *
-     * To exclude the parent's parent, use:
-     *
-     *    new ClassFinder(ClassLoaderInterface, ClassLoaderInterface.getParent().getParent());
-     *
-     * @param classLoader source of classes to scan
-     * @throws Exception if something goes wrong
-     */
-    public ClassFinder(ClassLoaderInterface classLoader) throws Exception {
-        this(classLoader, true);
-    }
-
-    /**
-     * Creates a ClassFinder that will search the urls in the specified ClassLoaderInterface.
-     *
-     * @param classLoader source of classes to scan
-     * @param excludeParent Allegedly excludes classes from parent ClassLoaderInterface, whatever that might mean
-     * @throws Exception if something goes wrong.
-     */
-    public ClassFinder(ClassLoaderInterface classLoader, boolean excludeParent) throws Exception {
-        this(classLoader, getUrls(classLoader, excludeParent));
-    }
-
-    /**
-     * Creates a ClassFinder that will search the urls in the specified classloader excluding
-     * the urls in the 'exclude' ClassLoaderInterface.
-     *
-     * @param classLoader source of classes to scan
-     * @param exclude source of classes to exclude from scanning
-     * @throws Exception if something goes wrong
-     */
-    public ClassFinder(ClassLoaderInterface classLoader, ClassLoaderInterface exclude) throws Exception {
-        this(classLoader, getUrls(classLoader, exclude));
-    }
-
-    public ClassFinder(ClassLoaderInterface classLoader, URL url) {
-        this(classLoader, Arrays.asList(url));
-    }
-
-    public ClassFinder(ClassLoaderInterface classLoader, String... dirNames) {
-        this(classLoader, getURLs(classLoader, dirNames));
-    }
-
-    public ClassFinder(ClassLoaderInterface classLoaderInterface, Collection<URL> urls) {
-        this(classLoaderInterface, urls, false);
-    }
-
-    public ClassFinder(ClassLoaderInterface classLoaderInterface, Collection<URL> urls, boolean extractBaseInterfaces) {
-        this(classLoaderInterface, urls, extractBaseInterfaces, new HashSet(){
-            {
-                add("jar");
-            }
-        });
-    }
-
-    public ClassFinder(ClassLoaderInterface classLoaderInterface, Collection<URL> urls, boolean extractBaseInterfaces, Set<String> protocols) {
-	    this(classLoaderInterface,urls,extractBaseInterfaces,protocols,new DefaultClassnameFilterImpl());
-    }
-
     public ClassFinder(ClassLoaderInterface classLoaderInterface, Collection<URL> urls, boolean extractBaseInterfaces, Set<String> protocols, Test<String> classNameFilter) {
         this.classLoaderInterface = classLoaderInterface;
         this.extractBaseInterfaces = extractBaseInterfaces;
@@ -451,18 +384,6 @@ public class ClassFinder {
         return urls;
     }
 
-    private static Collection<URL> getUrls(ClassLoaderInterface classLoaderInterface, boolean excludeParent) throws IOException {
-        return getUrls(classLoaderInterface, excludeParent? classLoaderInterface.getParent() : null);
-    }
-
-    private static Collection<URL> getUrls(ClassLoaderInterface classLoader, ClassLoaderInterface excludeParent) throws IOException {
-        UrlSet urlSet = new UrlSet(classLoader);
-        if (excludeParent != null){
-            urlSet = urlSet.exclude(excludeParent);
-        }
-        return urlSet.getUrls();
-    }
-
     private List<String> file(URL location) {
         List<String> classNames = new ArrayList<String>();
         File dir = new File(URLDecoder.decode(location.getPath()));

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/finder/UrlSet.java Wed Jun 20 20:27:39 2012
@@ -15,9 +15,7 @@
  */
 package com.opensymphony.xwork2.util.finder;
 
-import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.FileManager;
-import com.opensymphony.xwork2.FileManagerFactory;
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import org.apache.commons.lang3.ObjectUtils;
@@ -28,7 +26,6 @@ import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -58,36 +55,35 @@ public class UrlSet {
     private Set<String> protocols;
     private FileManager fileManager;
 
-    private UrlSet() {
-        this.urls = new HashMap<String,URL>();
-        this.fileManager = ActionContext.getContext().getInstance(FileManagerFactory.class).getFileManager();
-    }
-
-    public UrlSet(ClassLoaderInterface classLoader) throws IOException {
-        this();
+    public UrlSet(FileManager fileManager, ClassLoaderInterface classLoader) throws IOException {
+        this(fileManager);
         load(getUrls(classLoader));
     }
 
-    public UrlSet(ClassLoaderInterface classLoader, Set<String> protocols) throws IOException {
-        this();
+    public UrlSet(FileManager fileManager, ClassLoaderInterface classLoader, Set<String> protocols) throws IOException {
+        this(fileManager);
         this.protocols = protocols;
+        this.fileManager = fileManager;
         load(getUrls(classLoader, protocols));
     }
 
-    public UrlSet(URL... urls){
-        this(Arrays.asList(urls));
-    }
     /**
      * Ignores all URLs that are not "jar" or "file"
      * @param urls
      */
-    public UrlSet(Collection<URL> urls){
-        this();
+    public UrlSet(FileManager fileManager, Collection<URL> urls){
+        this(fileManager);
         load(urls);
     }
 
-    private UrlSet(Map<String, URL> urls) {
+    private UrlSet(FileManager fileManager) {
+        this.urls = new HashMap<String,URL>();
+        this.fileManager = fileManager;
+    }
+
+    private UrlSet(FileManager fileManager, Map<String, URL> urls) {
         this.urls = urls;
+        this.fileManager = fileManager;
     }
 
     private void load(Collection<URL> urls){
@@ -103,7 +99,7 @@ public class UrlSet {
     public UrlSet include(UrlSet urlSet){
         Map<String, URL> urls = new HashMap<String, URL>(this.urls);
         urls.putAll(urlSet.urls);
-        return new UrlSet(urls);
+        return new UrlSet(fileManager, urls);
     }
 
     public UrlSet exclude(UrlSet urlSet) {
@@ -112,11 +108,11 @@ public class UrlSet {
         for (String url : parentUrls.keySet()) {
             urls.remove(url);
         }
-        return new UrlSet(urls);
+        return new UrlSet(fileManager, urls);
     }
 
     public UrlSet exclude(ClassLoaderInterface parent) throws IOException {
-        return exclude(new UrlSet(parent, this.protocols));
+        return exclude(new UrlSet(fileManager, parent, this.protocols));
     }
 
     public UrlSet exclude(File file) throws MalformedURLException {
@@ -181,7 +177,7 @@ public class UrlSet {
                 urls.put(url, entry.getValue());
             }
         }
-        return new UrlSet(urls);
+        return new UrlSet(fileManager, urls);
     }
 
     /**
@@ -203,7 +199,7 @@ public class UrlSet {
                 if ("jar".equals(finalUrl.getProtocol()) || "file".equals(finalUrl.getProtocol())) {
                     newUrls.put(finalUrl.toExternalForm(), finalUrl);
                 }
-                return new UrlSet(newUrls);
+                return new UrlSet(fileManager, newUrls);
             }
         }
 
@@ -219,7 +215,7 @@ public class UrlSet {
                 urls.put(url, entry.getValue());
             }
         }
-        return new UrlSet(urls);
+        return new UrlSet(fileManager, urls);
     }
 
     public List<URL> getUrls() {

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManager.java Wed Jun 20 20:27:39 2012
@@ -19,18 +19,14 @@ import com.opensymphony.xwork2.FileManag
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -42,18 +38,10 @@ public class DefaultFileManager implemen
 
     private static Logger LOG = LoggerFactory.getLogger(DefaultFileManager.class);
 
-    public static final String JBOSS5_VFS = "vfs";
-    public static final String JBOSS5_VFSZIP = "vfszip";
-    public static final String JBOSS5_VFSMEMORY = "vfsmemory";
-    public static final String JBOSS5_VFSFILE = "vfsfile";
-
-    public static final String JAR_FILE_NAME_SEPARATOR = "!/";
-    public static final String JAR_FILE_EXTENSION_END = ".jar/";
-
     private static final Pattern JAR_PATTERN = Pattern.compile("^(jar:|wsjar:|zip:|vfsfile:|code-source:)?(file:)?(.*?)(\\!/|\\.jar/)(.*)");
     private static final int JAR_FILE_PATH = 3;
 
-    private static Map<String, Revision> files = Collections.synchronizedMap(new HashMap<String, Revision>());
+    protected static Map<String, Revision> files = Collections.synchronizedMap(new HashMap<String, Revision>());
 
     protected boolean reloadingConfigs = true;
 
@@ -74,13 +62,11 @@ public class DefaultFileManager implemen
 
     public boolean fileNeedsReloading(String fileName) {
         Revision revision = files.get(fileName);
-
         if (revision == null) {
             // no revision yet and we keep the revision history, so
             // return whether the file needs to be loaded for the first time
             return reloadingConfigs;
         }
-
         return revision.needsReloading();
     }
 
@@ -109,13 +95,10 @@ public class DefaultFileManager implemen
         if (isReloadingConfigs()) {
             String fileName = fileUrl.toString();
             Revision revision;
-
             if (LOG.isDebugEnabled()) {
-                LOG.debug("Creating revision for URL: " +fileName);
+                LOG.debug("Creating revision for URL: " + fileName);
             }
-            if (isJBossUrl(fileUrl)) {
-                revision = JBossFileRevision.build(fileUrl, this);
-            } else if (isJarURL(fileUrl)) {
+            if (isJarURL(fileUrl)) {
                 revision = JarEntryRevision.build(fileUrl, this);
             } else {
                 revision = FileRevision.build(fileUrl);
@@ -130,6 +113,7 @@ public class DefaultFileManager implemen
 
     /**
      * Check if given URL is matching Jar pattern for different servers
+     *
      * @param fileUrl
      * @return
      */
@@ -138,19 +122,15 @@ public class DefaultFileManager implemen
         return jarMatcher.matches();
     }
 
-
     public URL normalizeToFileProtocol(URL url) {
         String fileName = url.toExternalForm();
         Matcher jarMatcher = JAR_PATTERN.matcher(fileName);
         try {
-            if (isJBossUrl(url)){
-                return getJBossPhysicalUrl(url);
-            } else  if (jarMatcher.matches()) {
+            if (jarMatcher.matches()) {
                 String path = jarMatcher.group(JAR_FILE_PATH);
                 return new URL("file", "", path);
             } else {
-                //it is not a jar or zip file
-                return null;
+                return null; //it is not a jar or zip file
             }
         } catch (MalformedURLException e) {
             //can this ever happen?
@@ -161,89 +141,16 @@ public class DefaultFileManager implemen
         }
     }
 
-    /**
-     * Check if given URL is pointing to JBoss 5 VFS resource
-     * @param fileUrl
-     * @return
-     */
-    protected boolean isJBossUrl(URL fileUrl) {
-        final String protocol = fileUrl.getProtocol();
-        return JBOSS5_VFSZIP.equals(protocol) || JBOSS5_VFSMEMORY.equals(protocol) || JBOSS5_VFS.equals(protocol)
-                || ("true".equals(System.getProperty("jboss.vfs.forceVfsJar")) && JBOSS5_VFSFILE.equals(protocol));
-    }
-
-    /**
-     * Try to determine physical file location.
-     *
-     * @param url JBoss VFS URL
-     * @return URL pointing to physical file or original URL
-     * @throws IOException If conversion fails
-     */
-    protected URL getJBossPhysicalUrl(URL url) throws IOException {
-        Object content = url.openConnection().getContent();
-        try {
-            String s = content.getClass().toString();
-            if (s.startsWith("class org.jboss.vfs.VirtualFile")) { // JBoss 7 and probably 6
-                File physicalFile = readJBossPhysicalFile(content);
-                return physicalFile.toURI().toURL();
-            } else if (s.startsWith("class org.jboss.virtual.VirtualFile")) { // JBoss 5
-                String fileName = url.toExternalForm();
-                return new URL("file", null, fileName.substring(fileName.indexOf(":") + 1));
-            }
-        } catch (Exception e) {
-            LOG.warn("Error calling getPhysicalFile() on JBoss VirtualFile.", e);
-        }
-        return url;
-    }
-
     public boolean support() {
         return false; // allow other implementation to be used first
     }
 
-    public Collection<? extends URL> getAllPhysicalUrls(URL url) throws IOException {
-        if (isJBossUrl(url)) {
-            return getAllJBossPhysicalUrls(url);
-        }
-        return Arrays.asList(url);
-    }
-
-    private List<URL> getAllJBossPhysicalUrls(URL url) throws IOException {
-        List<URL> urls = new ArrayList<URL>();
-        Object content = url.openConnection().getContent();
-        try {
-            if (content.getClass().toString().startsWith("class org.jboss.vfs.VirtualFile")) {
-                File physicalFile = readJBossPhysicalFile(content);
-                readFile(urls, physicalFile);
-                readFile(urls, physicalFile.getParentFile());
-            } else {
-                urls.add(url);
-            }
-        } catch (Exception e) {
-            LOG.warn("Error calling getPhysicalFile() on JBoss VirtualFile.", e);
-        }
-        return urls;
+    public boolean internal() {
+        return true;
     }
 
-    private File readJBossPhysicalFile(Object content) throws Exception {
-        Method method = content.getClass().getDeclaredMethod("getPhysicalFile");
-        return (File) method.invoke(content);
-    }
-
-    private void readFile(List<URL> urls, File physicalFile) throws MalformedURLException {
-        if (physicalFile.isDirectory()) {
-            for (File file : physicalFile.listFiles()) {
-                if (file.isFile()) {
-                    addIfAbsent(urls, file.toURI().toURL());
-                } else if (file.isDirectory()) {
-                    readFile(urls, file);
-                }
-            }
-        }
+    public Collection<? extends URL> getAllPhysicalUrls(URL url) throws IOException {
+        return Arrays.asList(url);
     }
 
-    private void addIfAbsent(List<URL> urls, URL fileUrl) {
-        if (!urls.contains(fileUrl)) {
-            urls.add(fileUrl);
-        }
-    }
 }

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactory.java Wed Jun 20 20:27:39 2012
@@ -7,6 +7,7 @@ import com.opensymphony.xwork2.inject.In
 import com.opensymphony.xwork2.util.logging.Logger;
 import com.opensymphony.xwork2.util.logging.LoggerFactory;
 
+import java.util.HashSet;
 import java.util.Set;
 
 /**
@@ -17,29 +18,54 @@ public class DefaultFileManagerFactory i
     private static final Logger LOG = LoggerFactory.getLogger(DefaultFileManagerFactory.class);
 
     private FileManager fileManager;
+    private Container container;
+
+    @Inject(value = "system")
+    public void setFileManager(FileManager fileManager) {
+        this.fileManager = fileManager;
+    }
 
     @Inject
-    public DefaultFileManagerFactory(Container container) {
+    public void setContainer(Container container) {
+        this.container = container;
+    }
+
+    public FileManager getFileManager() {
         Set<String> names = container.getInstanceNames(FileManager.class);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Found following implementations of FileManager interface: #0", names.toString());
+        }
+        Set<FileManager> internals = new HashSet<FileManager>();
+        Set<FileManager> users = new HashSet<FileManager>();
         for (String fmName : names) {
             FileManager fm = container.getInstance(FileManager.class, fmName);
+            if (fm.internal()) {
+                internals.add(fm);
+            } else {
+                users.add(fm);
+            }
+        }
+        for (FileManager fm : users) {
             if (fm.support()) {
-                if (fileManager != null) {
-                    LOG.error("More than one FileManager supports current file system, [#0] and [#1]! "
-                            + "Remove one of them from the config! Using implementation [#2]",
-                            fm.toString(), fileManager.toString(), fm.toString());
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Using FileManager implementation [#0]", fm.getClass().getSimpleName());
                 }
-                fileManager = fm;
+                return fm;
             }
         }
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("No user defined FileManager, looking up for internal implementations!");
+        }
         if (fileManager == null) {
-            LOG.debug("Using default implementation as a FileManager.");
-            fileManager = new DefaultFileManager();
-            container.inject(fileManager);
+            for (FileManager fm : internals) {
+                if (fm.support()) {
+                    return fm;
+                }
+            }
+        }
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Using default implementation of FileManager provided under name [system]: #0", fileManager.getClass().getSimpleName());
         }
-    }
-
-    public FileManager getFileManager() {
         return fileManager;
     }
 

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/FileRevision.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/FileRevision.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/FileRevision.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/FileRevision.java Wed Jun 20 20:27:39 2012
@@ -7,11 +7,32 @@ import java.net.URL;
 /**
  * Represents file resource revision, used for file://* resources
  */
-class FileRevision extends Revision {
+public class FileRevision extends Revision {
+
     private File file;
     private long lastModified;
 
-    public FileRevision(File file, long lastUpdated) {
+    public static Revision build(URL fileUrl) {
+        File file;
+        try {
+            if (fileUrl != null) {
+                file = new File(fileUrl.toURI());
+            } else {
+                return null;
+            }
+        } catch (URISyntaxException e) {
+            file = new File(fileUrl.getPath());
+        }  catch (Throwable t) {
+            return null;
+        }
+        if (file.exists() && file.canRead()) {
+            long lastModified = file.lastModified();
+            return new FileRevision(file, lastModified);
+        }
+        return null;
+    }
+
+    private FileRevision(File file, long lastUpdated) {
         if (file == null) {
             throw new IllegalArgumentException("File cannot be null");
         }
@@ -36,19 +57,4 @@ class FileRevision extends Revision {
         return this.lastModified < this.file.lastModified();
     }
 
-    public static Revision build(URL fileUrl) {
-        File file;
-        try {
-            file = new File(fileUrl.toURI());
-        } catch (URISyntaxException e) {
-            file = new File(fileUrl.getPath());
-        }  catch (Throwable t) {
-            return null;
-        }
-        if (file.exists() && file.canRead()) {
-            long lastModified = file.lastModified();
-            return new FileRevision(file, lastModified);
-        }
-        return null;
-    }
 }

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/JarEntryRevision.java Wed Jun 20 20:27:39 2012
@@ -17,6 +17,9 @@ class JarEntryRevision extends Revision 
 
     private static Logger LOG = LoggerFactory.getLogger(JarEntryRevision.class);
 
+    private static final String JAR_FILE_NAME_SEPARATOR = "!/";
+    private static final String JAR_FILE_EXTENSION_END = ".jar/";
+
     private String jarFileName;
     private String fileNameInJar;
     private long lastModified;
@@ -35,8 +38,7 @@ class JarEntryRevision extends Revision 
         try {
             JarFile jarFile = new JarFile(this.jarFileName);
             entry = jarFile.getEntry(this.fileNameInJar);
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             entry = null;
         }
 
@@ -49,9 +51,9 @@ class JarEntryRevision extends Revision 
         String jarFileName = "";
         try {
             String fileName = fileUrl.toString();
-            int separatorIndex = fileName.indexOf(DefaultFileManager.JAR_FILE_NAME_SEPARATOR);
+            int separatorIndex = fileName.indexOf(JAR_FILE_NAME_SEPARATOR);
             if (separatorIndex == -1) {
-                separatorIndex = fileName.lastIndexOf(DefaultFileManager.JAR_FILE_EXTENSION_END);
+                separatorIndex = fileName.lastIndexOf(JAR_FILE_EXTENSION_END);
             }
             if (separatorIndex == -1) {
                 if (LOG.isWarnEnabled()) {
@@ -61,7 +63,7 @@ class JarEntryRevision extends Revision 
             }
             // Split file name
             jarFileName = fileName.substring(0, separatorIndex);
-            int index = separatorIndex + DefaultFileManager.JAR_FILE_NAME_SEPARATOR.length();
+            int index = separatorIndex + JAR_FILE_NAME_SEPARATOR.length();
             String fileNameInJar = fileName.substring(index).replaceAll("%20", " ");
 
             URL url = fileManager.normalizeToFileProtocol(fileUrl);

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/Revision.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/Revision.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/Revision.java (original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/util/fs/Revision.java Wed Jun 20 20:27:39 2012
@@ -5,7 +5,7 @@ import java.net.URL;
 /**
  * Class represents common revision resource, should be used as default class when no other option exists
  */
-class Revision {
+public class Revision {
 
     public Revision() {
     }
@@ -17,4 +17,5 @@ class Revision {
     public static Revision build(URL fileUrl) {
         return new Revision();
     }
+
 }

Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java (original)
+++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorParamOverridingTest.java Wed Jun 20 20:27:39 2012
@@ -21,6 +21,7 @@ import com.opensymphony.xwork2.config.Ru
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
+import com.opensymphony.xwork2.util.fs.DefaultFileManager;
 import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
 
 import java.util.ArrayList;
@@ -35,7 +36,10 @@ public class XmlConfigurationProviderInt
     public void testInterceptorParamOveriding() throws Exception {
         DefaultConfiguration conf = new DefaultConfiguration();
         final XmlConfigurationProvider p = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-param-overriding.xml");
-        p.setFileManagerFactory(new DefaultFileManagerFactory(container));
+        DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
+        factory.setContainer(container);
+        factory.setFileManager(new DefaultFileManager());
+        p.setFileManagerFactory(factory);
         conf.reload(new ArrayList<ConfigurationProvider>() {
             {
                 add(new XWorkConfigurationProvider());

Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java (original)
+++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderInterceptorStackParamOverridingTest.java Wed Jun 20 20:27:39 2012
@@ -6,6 +6,7 @@ import com.opensymphony.xwork2.config.Ru
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 import com.opensymphony.xwork2.config.entities.InterceptorMapping;
 import com.opensymphony.xwork2.config.impl.DefaultConfiguration;
+import com.opensymphony.xwork2.util.fs.DefaultFileManager;
 import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
 
 import java.util.ArrayList;
@@ -22,7 +23,10 @@ public class XmlConfigurationProviderInt
     public void testInterceptorStackParamOveriding() throws Exception {
     	DefaultConfiguration conf = new DefaultConfiguration();
     	final XmlConfigurationProvider p = new XmlConfigurationProvider("com/opensymphony/xwork2/config/providers/xwork-test-interceptor-stack-param-overriding.xml");
-        p.setFileManagerFactory(new DefaultFileManagerFactory(container));
+        DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
+        factory.setContainer(container);
+        factory.setFileManager(new DefaultFileManager());
+        p.setFileManagerFactory(factory);
     	configurationManager.addContainerProvider(p);
         conf.reload(new ArrayList<ConfigurationProvider>(){
             {

Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactoryTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactoryTest.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactoryTest.java (original)
+++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/util/fs/DefaultFileManagerFactoryTest.java Wed Jun 20 20:27:39 2012
@@ -1,7 +1,6 @@
 package com.opensymphony.xwork2.util.fs;
 
 import com.opensymphony.xwork2.FileManager;
-import com.opensymphony.xwork2.FileManagerFactory;
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.inject.Container;
 import com.opensymphony.xwork2.inject.Scope;
@@ -21,7 +20,9 @@ public class DefaultFileManagerFactoryTe
     public void testCreateDefaultFileManager() throws Exception {
         // given
         fileManager = null;
-        FileManagerFactory factory = new DefaultFileManagerFactory(new DummyContainer());
+        DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
+        factory.setFileManager(new DefaultFileManager());
+        factory.setContainer(new DummyContainer());
 
         // when
         FileManager fm = factory.getFileManager();
@@ -33,7 +34,8 @@ public class DefaultFileManagerFactoryTe
     public void testCreateDummyFileManager() throws Exception {
         // given
         fileManager = new DummyFileManager();
-        FileManagerFactory factory = new DefaultFileManagerFactory(new DummyContainer());
+        DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
+        factory.setContainer(new DummyContainer());
 
         // when
         FileManager fm = factory.getFileManager();
@@ -44,7 +46,8 @@ public class DefaultFileManagerFactoryTe
 
     public void testFileManagerFactoryWithRealConfig() throws Exception {
         // given
-        FileManagerFactory factory = new DefaultFileManagerFactory(container);
+        DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
+        container.inject(factory);
 
         // when
         FileManager fm = factory.getFileManager();
@@ -89,6 +92,7 @@ class DummyContainer implements Containe
 
     public void removeScopeStrategy() {
     }
+
 }
 
 class DummyFileManager implements FileManager {
@@ -123,6 +127,10 @@ class DummyFileManager implements FileMa
         return true;
     }
 
+    public boolean internal() {
+        return true;
+    }
+
     public Collection<? extends URL> getAllPhysicalUrls(URL url) throws IOException {
         return null;
     }

Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java?rev=1352301&r1=1352300&r2=1352301&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java (original)
+++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DefaultActionValidatorManagerTest.java Wed Jun 20 20:27:39 2012
@@ -28,6 +28,7 @@ import com.opensymphony.xwork2.test.Data
 import com.opensymphony.xwork2.test.SimpleAction2;
 import com.opensymphony.xwork2.test.SimpleAction3;
 import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.fs.DefaultFileManager;
 import com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory;
 
 import java.util.ArrayList;
@@ -65,7 +66,10 @@ public class DefaultActionValidatorManag
         ActionContext.setContext(new ActionContext(new HashMap<String, Object>()));
         ActionContext.getContext().setValueStack(stubValueStack);
 
-        actionValidatorManager.setFileManagerFactory(new DefaultFileManagerFactory(container));
+        DefaultFileManagerFactory factory = new DefaultFileManagerFactory();
+        factory.setContainer(container);
+        factory.setFileManager(new DefaultFileManager());
+        actionValidatorManager.setFileManagerFactory(factory);
     }
 
     @Override