You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ra...@apache.org on 2010/09/23 08:04:34 UTC

svn commit: r1000332 [14/27] - in /synapse/branches/commons-vfs-2-synapse-2.0: ./ core/ core/src/ core/src/main/ core/src/main/java/ core/src/main/java/org/ core/src/main/java/org/apache/ core/src/main/java/org/apache/commons/ core/src/main/java/org/ap...

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/http/ThreadLocalHttpConnectionManager.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/http/ThreadLocalHttpConnectionManager.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/http/ThreadLocalHttpConnectionManager.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/http/ThreadLocalHttpConnectionManager.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,283 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.http;
+
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A connection manager that provides access to a single HttpConnection.  This
+ * manager makes no attempt to provide exclusive access to the contained
+ * HttpConnection.
+ * <p/>
+ * imario@apache.org: Keep connection in ThreadLocal.
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @author <a href="mailto:becke@u.washington.edu">Michael Becke</a>
+ * @author Eric Johnson
+ * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
+ * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
+ * @author Laura Werner
+ * @since 2.0
+ */
+public class ThreadLocalHttpConnectionManager implements HttpConnectionManager
+{
+    /**
+     * The thread data.
+     */
+    protected ThreadLocal localHttpConnection = new ThreadLocal()
+    {
+        protected Object initialValue()
+        {
+            return new Entry();
+        }
+    };
+
+    /**
+     * Collection of parameters associated with this connection manager.
+     */
+    private HttpConnectionManagerParams params = new HttpConnectionManagerParams();
+
+
+    public ThreadLocalHttpConnectionManager()
+    {
+    }
+
+    /**
+     * Since the same connection is about to be reused, make sure the
+     * previous request was completely processed, and if not
+     * consume it now.
+     *
+     * @param conn The connection
+     */
+    static void finishLastResponse(HttpConnection conn)
+    {
+        InputStream lastResponse = conn.getLastResponseInputStream();
+        if (lastResponse != null)
+        {
+            conn.setLastResponseInputStream(null);
+            try
+            {
+                lastResponse.close();
+            }
+            catch (IOException ioe)
+            {
+                //FIXME: badness - close to force reconnect.
+                conn.close();
+            }
+        }
+    }
+
+    /**
+     * release the connection of the current thread.
+     */
+    public void releaseLocalConnection()
+    {
+        if (getLocalHttpConnection() != null)
+        {
+            releaseConnection(getLocalHttpConnection());
+        }
+    }
+
+    /**
+     * A connection entry.
+     */
+    private static class Entry
+    {
+        /**
+         * The http connection.
+         */
+        private HttpConnection conn = null;
+
+        /**
+         * The time the connection was made idle.
+         */
+        private long idleStartTime = Long.MAX_VALUE;
+
+        private Entry()
+        {
+        }
+    }
+
+    protected HttpConnection getLocalHttpConnection()
+    {
+        return ((Entry) localHttpConnection.get()).conn;
+    }
+
+    protected void setLocalHttpConnection(HttpConnection conn)
+    {
+        ((Entry) localHttpConnection.get()).conn = conn;
+    }
+
+    protected long getIdleStartTime()
+    {
+        return ((Entry) localHttpConnection.get()).idleStartTime;
+    }
+
+    protected void setIdleStartTime(long idleStartTime)
+    {
+        ((Entry) localHttpConnection.get()).idleStartTime = idleStartTime;
+    }
+
+    /**
+     * @param hostConfiguration The host configuration.
+     * @return the HttpConnection.
+     * @see HttpConnectionManager#getConnection(org.apache.commons.httpclient.HostConfiguration)
+     */
+    public HttpConnection getConnection(HostConfiguration hostConfiguration)
+    {
+        return getConnection(hostConfiguration, 0);
+    }
+
+    /**
+     * Gets the staleCheckingEnabled value to be set on HttpConnections that are created.
+     *
+     * @return <code>true</code> if stale checking will be enabled on HttpConections
+     * @see HttpConnection#isStaleCheckingEnabled()
+     */
+    public boolean isConnectionStaleCheckingEnabled()
+    {
+        return this.params.isStaleCheckingEnabled();
+    }
+
+    /**
+     * Sets the staleCheckingEnabled value to be set on HttpConnections that are created.
+     *
+     * @param connectionStaleCheckingEnabled <code>true</code> if stale checking will be enabled
+     *                                       on HttpConections
+     * @see HttpConnection#setStaleCheckingEnabled(boolean)
+     */
+    public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)
+    {
+        this.params.setStaleCheckingEnabled(connectionStaleCheckingEnabled);
+    }
+
+    /**
+     * @param hostConfiguration The host configuration.
+     * @param timeout The timeout value.
+     * @return The HttpConnection.
+     * @see HttpConnectionManager#getConnection(HostConfiguration, long)
+     * @since 3.0
+     */
+    public HttpConnection getConnectionWithTimeout(
+        HostConfiguration hostConfiguration, long timeout)
+    {
+
+        HttpConnection httpConnection = getLocalHttpConnection();
+        if (httpConnection == null)
+        {
+            httpConnection = new HttpConnection(hostConfiguration);
+            setLocalHttpConnection(httpConnection);
+            httpConnection.setHttpConnectionManager(this);
+            httpConnection.getParams().setStaleCheckingEnabled(params.isStaleCheckingEnabled());
+        }
+        else
+        {
+
+            // make sure the host and proxy are correct for this connection
+            // close it and set the values if they are not
+            if (!hostConfiguration.hostEquals(httpConnection)
+                || !hostConfiguration.proxyEquals(httpConnection))
+            {
+
+                if (httpConnection.isOpen())
+                {
+                    httpConnection.close();
+                }
+
+                httpConnection.setHost(hostConfiguration.getHost());
+                httpConnection.setPort(hostConfiguration.getPort());
+                httpConnection.setProtocol(hostConfiguration.getProtocol());
+                httpConnection.setLocalAddress(hostConfiguration.getLocalAddress());
+
+                httpConnection.setProxyHost(hostConfiguration.getProxyHost());
+                httpConnection.setProxyPort(hostConfiguration.getProxyPort());
+            }
+            else
+            {
+                finishLastResponse(httpConnection);
+            }
+        }
+
+        // remove the connection from the timeout handler
+        setIdleStartTime(Long.MAX_VALUE);
+
+        return httpConnection;
+    }
+
+    /**
+     * @param hostConfiguration The host configuration.
+     * @param timeout The timeout value.
+     * @return The HttpConnection.
+     * @see HttpConnectionManager#getConnection(HostConfiguration, long)
+     * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long)
+     */
+    public HttpConnection getConnection(
+        HostConfiguration hostConfiguration, long timeout)
+    {
+        return getConnectionWithTimeout(hostConfiguration, timeout);
+    }
+
+    /**
+     * @param conn The HttpConnection.
+     * @see HttpConnectionManager#releaseConnection(org.apache.commons.httpclient.HttpConnection)
+     */
+    public void releaseConnection(HttpConnection conn)
+    {
+        if (conn != getLocalHttpConnection())
+        {
+            throw new IllegalStateException("Unexpected release of an unknown connection.");
+        }
+
+        finishLastResponse(getLocalHttpConnection());
+
+        // track the time the connection was made idle
+        setIdleStartTime(System.currentTimeMillis());
+    }
+
+    /**
+     * @param idleTimeout The timeout value.
+     * @since 3.0
+     */
+    public void closeIdleConnections(long idleTimeout)
+    {
+        long maxIdleTime = System.currentTimeMillis() - idleTimeout;
+        if (getIdleStartTime() <= maxIdleTime)
+        {
+            getLocalHttpConnection().close();
+        }
+    }
+
+    public HttpConnectionManagerParams getParams()
+    {
+        return this.params;
+    }
+
+    public void setParams(HttpConnectionManagerParams params)
+    {
+        if (params == null)
+        {
+            throw new IllegalArgumentException("Parameters may not be null");
+        }
+        this.params = params;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/http/package.html
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/http/package.html?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/http/package.html (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/http/package.html Thu Sep 23 06:04:21 2010
@@ -0,0 +1,19 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<body>
+<p>The HTTP File Provider</p>
+</body>
\ No newline at end of file

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileNameParser.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileNameParser.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileNameParser.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileNameParser.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.https;
+
+import org.apache.commons.vfs.provider.FileNameParser;
+import org.apache.commons.vfs.provider.URLFileNameParser;
+
+/**
+ * Implementation for https. set default port to 443.
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public class HttpsFileNameParser extends URLFileNameParser
+{
+    private static final HttpsFileNameParser INSTANCE = new HttpsFileNameParser();
+
+    public HttpsFileNameParser()
+    {
+        super(443);
+    }
+
+    public static FileNameParser getInstance()
+    {
+        return INSTANCE;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileProvider.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileProvider.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileProvider.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/HttpsFileProvider.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.https;
+
+import org.apache.commons.vfs.provider.http.HttpFileProvider;
+
+/**
+ * An HTTPS provider that uses commons-httpclient.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 764356 $ $Date: 2009-04-13 09:36:01 +0530 (Mon, 13 Apr 2009) $
+ */
+public class HttpsFileProvider
+    extends HttpFileProvider
+{
+    public HttpsFileProvider()
+    {
+        super();
+        setFileNameParser(HttpsFileNameParser.getInstance());
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/package.html
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/package.html?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/package.html (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/https/package.html Thu Sep 23 06:04:21 2010
@@ -0,0 +1,19 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<body>
+<p>The HTTPS File Provider</p>
+</body>
\ No newline at end of file

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileObject.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.jar;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.provider.zip.ZipFileObject;
+
+import java.io.IOException;
+import java.security.cert.Certificate;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+/**
+ * A file in a Jar file system.
+ *
+ * @author <a href="mailto:brian@mmmanager.org">Brian Olsen</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public class JarFileObject extends ZipFileObject
+{
+    private final JarFileSystem fs;
+
+    private Attributes attributes;
+
+    protected JarFileObject(final FileName name,
+                            final ZipEntry entry,
+                            final JarFileSystem fs,
+                            final boolean zipExists) throws FileSystemException
+    {
+        super(name, entry, fs, zipExists);
+        this.fs = fs;
+
+        try
+        {
+            getAttributes(); // early get the attributes as the zip file might be closed
+        }
+        catch (IOException e)
+        {
+            throw new FileSystemException(e);
+        }
+    }
+
+    /**
+     * Returns the Jar manifest.
+     */
+    Manifest getManifest() throws IOException
+    {
+        if (fs.getZipFile() == null)
+        {
+            return null;
+        }
+
+        return ((JarFile) fs.getZipFile()).getManifest();
+    }
+
+    /**
+     * Returns the attributes of this file.
+     */
+    Attributes getAttributes() throws IOException
+    {
+        if (attributes == null)
+        {
+            if (entry == null)
+            {
+                attributes = new Attributes(1);
+            }
+            else
+            {
+                attributes = ((JarEntry) entry).getAttributes();
+                if (attributes == null)
+                {
+                    attributes = new Attributes(1);
+                }
+            }
+        }
+
+        return attributes;
+    }
+
+    /**
+     * Returns the value of an attribute.
+     */
+    protected Map doGetAttributes()
+        throws Exception
+    {
+        final Map attrs = new HashMap();
+
+        // Add the file system's attributes first
+        final JarFileSystem fs = (JarFileSystem) getFileSystem();
+        addAll(fs.getAttributes(), attrs);
+
+        // Add this file's attributes
+        addAll(getAttributes(), attrs);
+
+        return attrs;
+    }
+
+    /**
+     * Adds the source attributes to the destination map.
+     */
+    private void addAll(final Attributes src, final Map dest)
+    {
+        for (Iterator iterator = src.entrySet().iterator(); iterator.hasNext();)
+        {
+            final Map.Entry entry = (Map.Entry) iterator.next();
+            // final String name = entry.getKey().toString().toLowerCase();
+            final String name = entry.getKey().toString();
+            dest.put(name, entry.getValue());
+        }
+    }
+
+    /**
+     * Return the certificates of this JarEntry.
+     */
+    protected Certificate[] doGetCertificates()
+    {
+        if (entry == null)
+        {
+            return null;
+        }
+
+        return ((JarEntry) entry).getCertificates();
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.jar;
+
+import org.apache.commons.vfs.Capability;
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystem;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.provider.LayeredFileName;
+import org.apache.commons.vfs.provider.zip.ZipFileProvider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * A file system provider for Jar files.  Provides read-only file
+ * systems.  This provides access to Jar specific features like Signing and
+ * Manifest Attributes.
+ *
+ * @author <a href="mailto:brian@mmmanager.org">Brian Olsen</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public class JarFileProvider
+    extends ZipFileProvider
+{
+    static final Collection capabilities;
+
+    static
+    {
+        Collection combined = new ArrayList();
+        combined.addAll(ZipFileProvider.capabilities);
+        combined.addAll(Arrays.asList(new Capability[]
+            {
+                Capability.ATTRIBUTES,
+                Capability.FS_ATTRIBUTES,
+                Capability.SIGNING,
+                Capability.MANIFEST_ATTRIBUTES,
+                Capability.VIRTUAL
+            }));
+        capabilities = Collections.unmodifiableCollection(combined);
+    }
+
+    public JarFileProvider()
+    {
+        super();
+    }
+
+    /**
+     * Creates a layered file system.  This method is called if the file system
+     * is not cached.
+     *
+     * @param scheme The URI scheme.
+     * @param file   The file to create the file system on top of.
+     * @return The file system.
+     */
+    protected FileSystem doCreateFileSystem(final String scheme,
+                                            final FileObject file,
+                                            final FileSystemOptions fileSystemOptions)
+        throws FileSystemException
+    {
+        final FileName name =
+            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
+        return new JarFileSystem(name, file, fileSystemOptions);
+    }
+
+    public Collection getCapabilities()
+    {
+        return capabilities;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileSystem.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileSystem.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileSystem.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarFileSystem.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.jar;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.provider.zip.ZipFileObject;
+import org.apache.commons.vfs.provider.zip.ZipFileSystem;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.jar.Attributes;
+import java.util.jar.Attributes.Name;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+/**
+ * A read-only file system for Jar files.
+ *
+ * @author <a href="mailto:brian@mmmanager.org">Brian Olsen</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public class JarFileSystem
+    extends ZipFileSystem
+{
+    private Attributes attributes;
+
+    protected JarFileSystem(final FileName rootName,
+                            final FileObject file,
+                            final FileSystemOptions fileSystemOptions) throws FileSystemException
+    {
+        super(rootName, file, fileSystemOptions);
+    }
+
+    protected ZipFile createZipFile(File file) throws FileSystemException
+    {
+        try
+        {
+            return new JarFile(file);
+        }
+        catch (IOException ioe)
+        {
+            throw new FileSystemException("vfs.provider.jar/open-jar-file.error", file, ioe);
+        }
+    }
+
+    protected ZipFileObject createZipFileObject(FileName name,
+                                                ZipEntry entry) throws FileSystemException
+    {
+        return new JarFileObject(name, entry, this, true);
+    }
+
+    /**
+     * Returns the capabilities of this file system.
+     */
+    protected void addCapabilities(final Collection caps)
+    {
+        // super.addCapabilities(caps);
+        caps.addAll(JarFileProvider.capabilities);
+    }
+
+    Attributes getAttributes() throws IOException
+    {
+        if (attributes == null)
+        {
+            final Manifest man = ((JarFile) getZipFile()).getManifest();
+            if (man == null)
+            {
+                attributes = new Attributes(1);
+            }
+            else
+            {
+                attributes = man.getMainAttributes();
+                if (attributes == null)
+                {
+                    attributes = new Attributes(1);
+                }
+            }
+        }
+
+        return attributes;
+    }
+
+    Object getAttribute(Name attrName)
+        throws FileSystemException
+    {
+        try
+        {
+            final Attributes attr = getAttributes();
+            final String value = attr.getValue(attrName);
+            return value;
+        }
+        catch (IOException ioe)
+        {
+            throw new FileSystemException(attrName.toString(), ioe);
+        }
+    }
+
+    Name lookupName(String attrName)
+    {
+        if (Name.CLASS_PATH.toString().equals(attrName))
+        {
+            return Name.CLASS_PATH;
+        }
+        else if (Name.CONTENT_TYPE.toString().equals(attrName))
+        {
+            return Name.CONTENT_TYPE;
+        }
+        else if (Name.EXTENSION_INSTALLATION.toString().equals(attrName))
+        {
+            return Name.EXTENSION_INSTALLATION;
+        }
+        else if (Name.EXTENSION_LIST.toString().equals(attrName))
+        {
+            return Name.EXTENSION_LIST;
+        }
+        else if (Name.EXTENSION_NAME.toString().equals(attrName))
+        {
+            return Name.EXTENSION_NAME;
+        }
+        else if (Name.IMPLEMENTATION_TITLE.toString().equals(attrName))
+        {
+            return Name.IMPLEMENTATION_TITLE;
+        }
+        else if (Name.IMPLEMENTATION_URL.toString().equals(attrName))
+        {
+            return Name.IMPLEMENTATION_URL;
+        }
+        else if (Name.IMPLEMENTATION_VENDOR.toString().equals(attrName))
+        {
+            return Name.IMPLEMENTATION_VENDOR;
+        }
+        else if (Name.IMPLEMENTATION_VENDOR_ID.toString().equals(attrName))
+        {
+            return Name.IMPLEMENTATION_VENDOR_ID;
+        }
+        else if (Name.IMPLEMENTATION_VERSION.toString().equals(attrName))
+        {
+            return Name.IMPLEMENTATION_VENDOR;
+        }
+        else if (Name.MAIN_CLASS.toString().equals(attrName))
+        {
+            return Name.MAIN_CLASS;
+        }
+        else if (Name.MANIFEST_VERSION.toString().equals(attrName))
+        {
+            return Name.MANIFEST_VERSION;
+        }
+        else if (Name.SEALED.toString().equals(attrName))
+        {
+            return Name.SEALED;
+        }
+        else if (Name.SIGNATURE_VERSION.toString().equals(attrName))
+        {
+            return Name.SIGNATURE_VERSION;
+        }
+        else if (Name.SPECIFICATION_TITLE.toString().equals(attrName))
+        {
+            return Name.SPECIFICATION_TITLE;
+        }
+        else if (Name.SPECIFICATION_VENDOR.toString().equals(attrName))
+        {
+            return Name.SPECIFICATION_VENDOR;
+        }
+        else if (Name.SPECIFICATION_VERSION.toString().equals(attrName))
+        {
+            return Name.SPECIFICATION_VERSION;
+        }
+        else
+        {
+            return new Name(attrName);
+        }
+    }
+
+    /**
+     * Retrives the attribute with the specified name. The default
+     * implementation simply throws an exception.
+     * @param attrName The attiribute's name.
+     * @return The value of the attribute.
+     * @throws FileSystemException if an error occurs.
+     */
+    public Object getAttribute(String attrName) throws FileSystemException
+    {
+        final Name name = lookupName(attrName);
+        return getAttribute(name);
+    }
+
+
+    protected ZipFile getZipFile() throws FileSystemException
+    {
+        return super.getZipFile();
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarURLConnectionImpl.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarURLConnectionImpl.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarURLConnectionImpl.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/JarURLConnectionImpl.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.jar;
+
+import org.apache.commons.vfs.FileContent;
+import org.apache.commons.vfs.FileSystemException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.cert.Certificate;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+/**
+ * A default URL connection that will work for most file systems.
+ *
+ * @author <a href="mailto:brian@mmmanager.org">Brian Olsen</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public class JarURLConnectionImpl
+    extends JarURLConnection
+{
+    // This is because JarURLConnection SUCKS
+    private static final String HACK_URL = "jar:http://somehost/somejar.jar!/";
+
+    private FileContent content;
+    private URL parentURL;
+    private JarFileObject file;
+    private String entryName;
+
+    public JarURLConnectionImpl(JarFileObject file, FileContent content)
+        throws MalformedURLException, FileSystemException
+    {
+        //This is because JarURLConnection SUCKS!!
+        super(new URL(HACK_URL));
+
+        this.url = file.getURL();
+        this.content = content;
+        this.parentURL = file.getURL();
+        this.entryName = file.getName().getPath();
+        this.file = file;
+    }
+
+
+    public URL getJarFileURL()
+    {
+        return parentURL;
+    }
+
+
+    public String getEntryName()
+    {
+        return entryName;
+    }
+
+
+    public JarFile getJarFile() throws IOException
+    {
+        throw new FileSystemException("vfs.provider.jar/jar-file-no-access.error");
+    }
+
+
+    public Manifest getManifest() throws IOException
+    {
+        return file.getManifest();
+    }
+
+
+    public JarEntry getJarEntry() throws IOException
+    {
+        throw new FileSystemException("vfs.provider.jar/jar-entry-no-access.error");
+    }
+
+
+    public Attributes getAttributes() throws IOException
+    {
+        return file.getAttributes();
+    }
+
+
+    public Certificate[] getCertificates()
+    {
+        return file.doGetCertificates();
+    }
+
+
+    public void connect()
+    {
+        connected = true;
+    }
+
+    public InputStream getInputStream()
+        throws IOException
+    {
+        return content.getInputStream();
+    }
+
+    public OutputStream getOutputStream()
+        throws IOException
+    {
+        return content.getOutputStream();
+    }
+
+    public int getContentLength()
+    {
+        try
+        {
+            return (int) content.getSize();
+        }
+        catch (FileSystemException fse)
+        {
+            // Ignore the error.
+        }
+
+        return -1;
+    }
+
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/package.html
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/package.html?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/package.html (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/jar/package.html Thu Sep 23 06:04:21 2010
@@ -0,0 +1,19 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+   
+         http://www.apache.org/licenses/LICENSE-2.0
+   
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<body>
+<p>The Jar File Provider.</p>
+</body>
\ No newline at end of file

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.Capability;
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystem;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
+import org.apache.commons.vfs.provider.LocalFileProvider;
+import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.util.Os;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * A file system provider, which uses direct file access.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public class DefaultLocalFileProvider
+    extends AbstractOriginatingFileProvider
+    implements LocalFileProvider
+{
+    /** The provider's capabilities. */
+    public static final Collection capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[]
+    {
+        Capability.CREATE,
+        Capability.DELETE,
+        Capability.RENAME,
+        Capability.GET_TYPE,
+        Capability.GET_LAST_MODIFIED,
+        Capability.SET_LAST_MODIFIED_FILE,
+        Capability.SET_LAST_MODIFIED_FOLDER,
+        Capability.LIST_CHILDREN,
+        Capability.READ_CONTENT,
+        Capability.URI,
+        Capability.WRITE_CONTENT,
+        Capability.APPEND_CONTENT,
+        Capability.RANDOM_ACCESS_READ,
+        Capability.RANDOM_ACCESS_WRITE
+    }));
+
+    public DefaultLocalFileProvider()
+    {
+        super();
+
+        if (Os.isFamily(Os.OS_FAMILY_WINDOWS))
+        {
+            setFileNameParser(new WindowsFileNameParser());
+        }
+        else
+        {
+            setFileNameParser(new GenericFileNameParser());
+        }
+    }
+
+    /**
+     * Determines if a name is an absolute file name.
+     * @param name The file name.
+     * @return true if the name is absolute, false otherwise.
+     */
+    public boolean isAbsoluteLocalName(final String name)
+    {
+        return ((LocalFileNameParser) getFileNameParser()).isAbsoluteName(name);
+    }
+
+    /**
+     * Finds a local file, from its local name.
+     * @param name The name of the file to locate.
+     * @return the located FileObject.
+     * @throws FileSystemException if an error occurs.
+     */
+    public FileObject findLocalFile(final String name)
+        throws FileSystemException
+    {
+        StringBuffer uri = new StringBuffer(name.length() + 5);
+        uri.append("file:");
+        uri.append(name);
+        FileName filename = parseUri(null, uri.toString());
+        return findFile(filename, null);
+    }
+
+    /**
+     * Finds a local file.
+     * @param file The File to locate.
+     * @return the located FileObject.
+     * @throws FileSystemException if an error occurs.
+     */
+    public FileObject findLocalFile(final File file)
+        throws FileSystemException
+    {
+        return findLocalFile(UriParser.encode(file.getAbsolutePath()));
+        // return findLocalFile(file.getAbsolutePath());
+    }
+
+    /**
+     * Creates the filesystem.
+     */
+    protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
+        throws FileSystemException
+    {
+        // Create the file system
+        final LocalFileName rootName = (LocalFileName) name;
+        return new LocalFileSystem(rootName, rootName.getRootFile(), fileSystemOptions);
+    }
+
+    public Collection getCapabilities()
+    {
+        return capabilities;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+
+/**
+ * A general-purpose file name parser.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public class GenericFileNameParser
+    extends LocalFileNameParser
+{
+    private static final GenericFileNameParser INSTANCE = new GenericFileNameParser();
+
+    /**
+     * retrieve a instance to this parser.
+     *
+     * @return the parser
+     */
+    public static GenericFileNameParser getInstance()
+    {
+        return INSTANCE;
+    }
+
+    /**
+     * Pops the root prefix off a URI, which has had the scheme removed.
+     */
+    protected String extractRootPrefix(final String uri,
+                                       final StringBuffer name)
+        throws FileSystemException
+    {
+        // TODO - this class isn't generic at all.  Need to fix this
+
+        // Looking for <sep>
+        if (name.length() == 0 || name.charAt(0) != '/')
+        {
+            throw new FileSystemException("vfs.provider.local/not-absolute-file-name.error", uri);
+        }
+
+        // do not strip the separator, BUT also return it ...
+        return "/";
+    }
+
+    /*
+     * ... this is why whe need this:
+     * here the rootFilename can only be "/" (see above) put this "/" is also in the pathname
+     * so its of no value for the LocalFileName instance
+     */
+    protected FileName createFileName(String scheme, final String rootFile, final String path, final FileType type)
+    {
+        return new LocalFileName(scheme, "", path, type);
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFile.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFile.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFile.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFile.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.RandomAccessContent;
+import org.apache.commons.vfs.provider.AbstractFileObject;
+import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.util.RandomAccessMode;
+import org.apache.commons.vfs.util.FileObjectUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * A file object implementation which uses direct file access.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @author Gary D. Gregory
+ * @version $Revision: 764356 $ $Date: 2009-04-13 09:36:01 +0530 (Mon, 13 Apr 2009) $
+ */
+public class LocalFile
+    extends AbstractFileObject
+    implements FileObject
+{
+    private final String rootFile;
+
+    private File file;
+
+    /**
+     * Creates a non-root file.
+     */
+    protected LocalFile(final LocalFileSystem fileSystem,
+                        final String rootFile,
+                        final FileName name) throws FileSystemException
+    {
+        super(name, fileSystem);
+        this.rootFile = rootFile;
+    }
+
+    /**
+     * Returns the local file that this file object represents.
+     */
+    protected File getLocalFile()
+    {
+        return file;
+    }
+
+    /**
+     * Attaches this file object to its file resource.
+     */
+    protected void doAttach()
+        throws Exception
+    {
+        if (file == null)
+        {
+            // Remove the "file:///"
+            // LocalFileName localFileName = (LocalFileName) getName();
+            String fileName = rootFile + getName().getPathDecoded();
+            // fileName = UriParser.decode(fileName);
+            file = new File(fileName);
+        }
+    }
+
+    /**
+     * Returns the file's type.
+     */
+    protected FileType doGetType()
+        throws Exception
+    {
+        // JDK BUG: 6192331
+        // if (!file.exists())
+        if (!file.exists() && file.length() < 1)
+        {
+            return FileType.IMAGINARY;
+        }
+
+        if (file.isDirectory())
+        {
+            return FileType.FOLDER;
+        }
+
+        // In doubt, treat an existing file as file
+        // if (file.isFile())
+        // {
+            return FileType.FILE;
+        // }
+
+        // throw new FileSystemException("vfs.provider.local/get-type.error", file);
+    }
+
+    /**
+     * Returns the children of the file.
+     */
+    protected String[] doListChildren()
+        throws Exception
+    {
+        return UriParser.encode(file.list());
+    }
+
+    /**
+     * Deletes this file, and all children.
+     */
+    protected void doDelete()
+        throws Exception
+    {
+        if (!file.delete())
+        {
+            throw new FileSystemException("vfs.provider.local/delete-file.error", file);
+        }
+    }
+
+    /**
+     * rename this file
+     */
+    protected void doRename(final FileObject newfile) throws Exception
+    {
+        LocalFile newLocalFile = (LocalFile) FileObjectUtils.getAbstractFileObject(newfile);
+
+        if (!file.renameTo(newLocalFile.getLocalFile()))
+        {
+            throw new FileSystemException("vfs.provider.local/rename-file.error",
+                new String[]{file.toString(), newfile.toString()});
+        }
+    }
+
+    /**
+     * Creates this folder.
+     */
+    protected void doCreateFolder()
+        throws Exception
+    {
+        if (!file.mkdirs())
+        {
+            throw new FileSystemException("vfs.provider.local/create-folder.error", file);
+        }
+    }
+
+    /**
+     * Determines if this file can be written to.
+     */
+    protected boolean doIsWriteable() throws FileSystemException
+    {
+        return file.canWrite();
+    }
+
+    /**
+     * Determines if this file is hidden.
+     */
+    protected boolean doIsHidden()
+    {
+        return file.isHidden();
+    }
+
+    /**
+     * Determines if this file can be read.
+     */
+    protected boolean doIsReadable() throws FileSystemException
+    {
+        return file.canRead();
+    }
+
+    /**
+     * Gets the last modified time of this file.
+     */
+    protected long doGetLastModifiedTime() throws FileSystemException
+    {
+        return file.lastModified();
+    }
+
+    /**
+     * Sets the last modified time of this file.
+     */
+    protected boolean doSetLastModTime(final long modtime)
+        throws FileSystemException
+    {
+        return file.setLastModified(modtime);
+    }
+
+    /**
+     * Creates an input stream to read the content from.
+     */
+    protected InputStream doGetInputStream()
+        throws Exception
+    {
+        return new FileInputStream(file);
+    }
+
+    /**
+     * Creates an output stream to write the file content to.
+     */
+    protected OutputStream doGetOutputStream(boolean bAppend)
+        throws Exception
+    {
+        return new FileOutputStream(file.getPath(), bAppend);
+    }
+
+    /**
+     * Returns the size of the file content (in bytes).
+     */
+    protected long doGetContentSize()
+        throws Exception
+    {
+        return file.length();
+    }
+
+    protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
+    {
+        return new LocalFileRandomAccessContent(file, mode);
+    }
+
+    protected boolean doIsSameFile(FileObject destFile) throws FileSystemException
+    {
+        if (!FileObjectUtils.isInstanceOf(destFile, LocalFile.class))
+        {
+            return false;
+        }
+
+        LocalFile destLocalFile = (LocalFile) FileObjectUtils.getAbstractFileObject(destFile);
+        if (!exists() || !destLocalFile.exists())
+        {
+            return false;
+        }
+
+        try
+        {
+            return file.getCanonicalPath().equals(destLocalFile.file.getCanonicalPath());
+        }
+        catch (IOException e)
+        {
+            throw new FileSystemException(e);
+        }
+
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileName.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileName.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileName.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileName.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.provider.AbstractFileName;
+
+/**
+ * A local file URI.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public class LocalFileName extends AbstractFileName
+{
+    private final String rootFile;
+
+    protected LocalFileName(final String scheme,
+                            final String rootFile,
+                            final String path,
+                            final FileType type)
+    {
+        super(scheme, path, type);
+        this.rootFile = rootFile;
+    }
+
+    /**
+     * Returns the root file for this file.
+     * @return The root file name.
+     */
+    public String getRootFile()
+    {
+        return rootFile;
+    }
+
+    /**
+     * Factory method for creating name instances.
+     * @param path The file path.
+     * @param type The file type.
+     * @return The FileName.
+     */
+    public FileName createName(final String path, FileType type)
+    {
+        return new LocalFileName(getScheme(), rootFile, path, type);
+    }
+
+    /**
+     * Builds the root URI for this file name.
+     */
+    protected void appendRootUri(final StringBuffer buffer, boolean addPassword)
+    {
+        buffer.append(getScheme());
+        buffer.append("://");
+        buffer.append(rootFile);
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.provider.AbstractFileNameParser;
+import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.VfsComponentContext;
+
+/**
+ * A name parser.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public abstract class LocalFileNameParser extends AbstractFileNameParser
+{
+    /**
+     * Determines if a name is an absolute file name.
+     * @param name The file name.
+     * @return true if the name is absolute, false otherwise.
+     */
+    public boolean isAbsoluteName(final String name)
+    {
+        // TODO - this is yucky
+        StringBuffer b = new StringBuffer(name);
+        try
+        {
+            UriParser.fixSeparators(b);
+            extractRootPrefix(name, b);
+            return true;
+        }
+        catch (FileSystemException e)
+        {
+            return false;
+        }
+    }
+
+    /**
+     * Pops the root prefix off a URI, which has had the scheme removed.
+     */
+    protected abstract String extractRootPrefix(final String uri,
+                                                final StringBuffer name)
+        throws FileSystemException;
+
+
+    public FileName parseUri(final VfsComponentContext context, FileName base, final String filename)
+        throws FileSystemException
+    {
+        final StringBuffer name = new StringBuffer();
+
+        // Extract the scheme
+        String scheme = UriParser.extractScheme(filename, name);
+        if (scheme == null)
+        {
+            scheme = "file";
+        }
+
+        // Remove encoding, and adjust the separators
+        UriParser.canonicalizePath(name, 0, name.length(), this);
+
+        UriParser.fixSeparators(name);
+
+        // Extract the root prefix
+        final String rootFile = extractRootPrefix(filename, name);
+
+        // Normalise the path
+        FileType fileType = UriParser.normalisePath(name);
+
+        final String path = name.toString();
+
+        return createFileName(
+            scheme,
+            rootFile,
+            path,
+            fileType);
+    }
+
+    protected abstract FileName createFileName(String scheme, final String rootFile, final String path,
+                                               final FileType type);
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileRandomAccessContent.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileRandomAccessContent.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileRandomAccessContent.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileRandomAccessContent.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.provider.AbstractRandomAccessContent;
+import org.apache.commons.vfs.util.RandomAccessMode;
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+
+/**
+ * RandomAccess for local files
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+class LocalFileRandomAccessContent extends AbstractRandomAccessContent
+{
+    // private final LocalFile localFile;
+    private final RandomAccessFile raf;
+    private final InputStream rafis;
+
+    LocalFileRandomAccessContent(final File localFile, final RandomAccessMode mode) throws FileSystemException
+    {
+        super(mode);
+
+        try
+        {
+            raf = new RandomAccessFile(localFile, mode.getModeString());
+            rafis = new InputStream()
+            {
+                public int read() throws IOException
+                {
+                    try
+                    {
+                        return raf.readByte();
+                    }
+                    catch (EOFException e)
+                    {
+                        return -1;
+                    }
+                }
+
+                public long skip(long n) throws IOException
+                {
+                    raf.seek(raf.getFilePointer() + n);
+                    return n;
+                }
+
+                public void close() throws IOException
+                {
+                    raf.close();
+                }
+
+                public int read(byte[] b) throws IOException
+                {
+                    return raf.read(b);
+                }
+
+                public int read(byte[] b, int off, int len) throws IOException
+                {
+                    return raf.read(b, off, len);
+                }
+
+                public int available() throws IOException
+                {
+                    long available = raf.length() - raf.getFilePointer();
+                    if (available > Integer.MAX_VALUE)
+                    {
+                        return Integer.MAX_VALUE;
+                    }
+
+                    return (int) available;
+                }
+            };
+        }
+        catch (FileNotFoundException e)
+        {
+            throw new FileSystemException("vfs.provider/random-access-open-failed.error", localFile);
+        }
+    }
+
+    public long getFilePointer() throws IOException
+    {
+        return raf.getFilePointer();
+    }
+
+    public void seek(long pos) throws IOException
+    {
+        raf.seek(pos);
+    }
+
+    public long length() throws IOException
+    {
+        return raf.length();
+    }
+
+    public void close() throws IOException
+    {
+        raf.close();
+    }
+
+    public byte readByte() throws IOException
+    {
+        return raf.readByte();
+    }
+
+    public char readChar() throws IOException
+    {
+        return raf.readChar();
+    }
+
+    public double readDouble() throws IOException
+    {
+        return raf.readDouble();
+    }
+
+    public float readFloat() throws IOException
+    {
+        return raf.readFloat();
+    }
+
+    public int readInt() throws IOException
+    {
+        return raf.readInt();
+    }
+
+    public int readUnsignedByte() throws IOException
+    {
+        return raf.readUnsignedByte();
+    }
+
+    public int readUnsignedShort() throws IOException
+    {
+        return raf.readUnsignedShort();
+    }
+
+    public long readLong() throws IOException
+    {
+        return raf.readLong();
+    }
+
+    public short readShort() throws IOException
+    {
+        return raf.readShort();
+    }
+
+    public boolean readBoolean() throws IOException
+    {
+        return raf.readBoolean();
+    }
+
+    public int skipBytes(int n) throws IOException
+    {
+        return raf.skipBytes(n);
+    }
+
+    public void readFully(byte[] b) throws IOException
+    {
+        raf.readFully(b);
+    }
+
+    public void readFully(byte[] b, int off, int len) throws IOException
+    {
+        raf.readFully(b, off, len);
+    }
+
+    public String readUTF() throws IOException
+    {
+        return raf.readUTF();
+    }
+
+    public void writeDouble(double v) throws IOException
+    {
+        raf.writeDouble(v);
+    }
+
+    public void writeFloat(float v) throws IOException
+    {
+        raf.writeFloat(v);
+    }
+
+    public void write(int b) throws IOException
+    {
+        raf.write(b);
+    }
+
+    public void writeByte(int v) throws IOException
+    {
+        raf.writeByte(v);
+    }
+
+    public void writeChar(int v) throws IOException
+    {
+        raf.writeChar(v);
+    }
+
+    public void writeInt(int v) throws IOException
+    {
+        raf.writeInt(v);
+    }
+
+    public void writeShort(int v) throws IOException
+    {
+        raf.writeShort(v);
+    }
+
+    public void writeLong(long v) throws IOException
+    {
+        raf.writeLong(v);
+    }
+
+    public void writeBoolean(boolean v) throws IOException
+    {
+        raf.writeBoolean(v);
+    }
+
+    public void write(byte[] b) throws IOException
+    {
+        raf.write(b);
+    }
+
+    public void write(byte[] b, int off, int len) throws IOException
+    {
+        raf.write(b, off, len);
+    }
+
+    public void writeBytes(String s) throws IOException
+    {
+        raf.writeBytes(s);
+    }
+
+    public void writeChars(String s) throws IOException
+    {
+        raf.writeChars(s);
+    }
+
+    public void writeUTF(String str) throws IOException
+    {
+        raf.writeUTF(str);
+    }
+
+    public InputStream getInputStream() throws IOException
+    {
+        return rafis;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/LocalFileSystem.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSelector;
+import org.apache.commons.vfs.FileSystem;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.provider.AbstractFileSystem;
+
+import java.io.File;
+import java.io.FilePermission;
+import java.util.Collection;
+
+/**
+ * A local file system.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 480428 $ $Date: 2006-11-29 11:45:24 +0530 (Wed, 29 Nov 2006) $
+ */
+public class LocalFileSystem
+    extends AbstractFileSystem
+    implements FileSystem
+{
+    private final String rootFile;
+
+    public LocalFileSystem(final FileName rootName,
+                           final String rootFile,
+                           final FileSystemOptions opts)
+    {
+        super(rootName, null, opts);
+        this.rootFile = rootFile;
+    }
+
+    /**
+     * Creates a file object.
+     */
+    protected FileObject createFile(final FileName name) throws FileSystemException
+    {
+        // Create the file
+        return new LocalFile(this, rootFile, name);
+    }
+
+    /**
+     * Returns the capabilities of this file system.
+     */
+    protected void addCapabilities(final Collection caps)
+    {
+        caps.addAll(DefaultLocalFileProvider.capabilities);
+    }
+
+    /**
+     * Creates a temporary local copy of a file and its descendents.
+     */
+    protected File doReplicateFile(final FileObject fileObject,
+                                   final FileSelector selector)
+        throws Exception
+    {
+        final LocalFile localFile = (LocalFile) fileObject;
+        final File file = localFile.getLocalFile();
+        final SecurityManager sm = System.getSecurityManager();
+        if (sm != null)
+        {
+            final FilePermission requiredPerm = new FilePermission(file.getAbsolutePath(), "read");
+            sm.checkPermission(requiredPerm);
+        }
+        return file;
+    }
+
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileName.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileName.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileName.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
+
+/**
+ * A local file URI.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 895278 $ $Date: 2010-01-03 01:32:29 +0530 (Sun, 03 Jan 2010) $
+ */
+public class WindowsFileName extends LocalFileName
+{
+    protected WindowsFileName(final String scheme,
+                              final String rootFile,
+                              final String path,
+                              final FileType type)
+    {
+        super(scheme, rootFile, path, type);
+    }
+
+    /**
+     * Factory method for creating name instances.
+     * @param path The file path.
+     * @param type The file type.
+     * @return The FileName.
+     */
+    public FileName createName(final String path, FileType type)
+    {
+        return new WindowsFileName(getScheme(), getRootFile(), path, type);
+    }
+
+    /**
+     * Builds the root URI for this file name.
+     */
+    protected void appendRootUri(final StringBuffer buffer, boolean addPassword)
+    {
+        buffer.append(getScheme());
+        buffer.append("://");
+        if (getRootFile() != null && !getRootFile().startsWith("/"))
+        {
+            // next is drive-letter (else unc name)
+            buffer.append("/");
+        }
+        buffer.append(getRootFile());
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.vfs.provider.local;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+
+/**
+ * A parser for Windows file names.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 764356 $ $Date: 2009-04-13 09:36:01 +0530 (Mon, 13 Apr 2009) $
+ */
+public class WindowsFileNameParser
+    extends LocalFileNameParser
+{
+    /**
+     * Pops the root prefix off a URI, which has had the scheme removed.
+     */
+    protected String extractRootPrefix(final String uri,
+                                       final StringBuffer name)
+        throws FileSystemException
+    {
+        return extractWindowsRootPrefix(uri, name);
+    }
+
+    protected FileName createFileName(String scheme, final String rootFile, final String path, final FileType type)
+    {
+        return new WindowsFileName(scheme, rootFile, path, type);
+    }
+
+    /**
+     * Extracts a Windows root prefix from a name.
+     */
+    private String extractWindowsRootPrefix(final String uri,
+                                            final StringBuffer name)
+        throws FileSystemException
+    {
+        // Looking for:
+        // ('/'){0, 3} <letter> ':' '/'
+        // ['/'] '//' <name> '/' <name> ( '/' | <end> )
+
+        // Skip over first 4 (unc) leading '/' chars
+        int startPos = 0;
+        int maxlen = Math.min(4, name.length());
+        for (; startPos < maxlen && name.charAt(startPos) == '/'; startPos++)
+        {
+        }
+        if (startPos == maxlen && name.length() > startPos && name.charAt(startPos + 1) == '/')
+        {
+            // Too many '/'
+            throw new FileSystemException("vfs.provider.local/not-absolute-file-name.error", uri);
+        }
+        name.delete(0, startPos);
+
+        // Look for drive name
+        String driveName = extractDrivePrefix(name);
+        if (driveName != null)
+        {
+            return driveName;
+        }
+
+        // Look for UNC name
+        if (startPos < 2)
+        {
+            throw new FileSystemException("vfs.provider.local/not-absolute-file-name.error", uri);
+        }
+
+        return "//" + extractUNCPrefix(uri, name);
+    }
+
+    /**
+     * Extracts a drive prefix from a path.  Leading '/' chars have been removed.
+     */
+    private String extractDrivePrefix(final StringBuffer name)
+    {
+        // Looking for <letter> ':' '/'
+        if (name.length() < 3)
+        {
+            // Too short
+            return null;
+        }
+        char ch = name.charAt(0);
+        if (ch == '/' || ch == ':')
+        {
+            // Missing drive letter
+            return null;
+        }
+        if (name.charAt(1) != ':')
+        {
+            // Missing ':'
+            return null;
+        }
+        if (name.charAt(2) != '/')
+        {
+            // Missing separator
+            return null;
+        }
+
+        String prefix = name.substring(0, 2);
+        name.delete(0, 2);
+
+        return prefix.intern();
+    }
+
+    /**
+     * Extracts a UNC name from a path.  Leading '/' chars have been removed.
+     */
+    private String extractUNCPrefix(final String uri,
+                                    final StringBuffer name)
+        throws FileSystemException
+    {
+        // Looking for <name> '/' <name> ( '/' | <end> )
+
+        // Look for first separator
+        int maxpos = name.length();
+        int pos = 0;
+        for (; pos < maxpos && name.charAt(pos) != '/'; pos++)
+        {
+        }
+        pos++;
+        if (pos >= maxpos)
+        {
+            throw new FileSystemException("vfs.provider.local/missing-share-name.error", uri);
+        }
+
+        // Now have <name> '/'
+        int startShareName = pos;
+        for (; pos < maxpos && name.charAt(pos) != '/'; pos++)
+        {
+        }
+        if (pos == startShareName)
+        {
+            throw new FileSystemException("vfs.provider.local/missing-share-name.error", uri);
+        }
+
+        // Now have <name> '/' <name> ( '/' | <end> )
+        String prefix = name.substring(0, pos);
+        name.delete(0, pos);
+        return prefix;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/package.html
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/package.html?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/package.html (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/local/package.html Thu Sep 23 06:04:21 2010
@@ -0,0 +1,19 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+   
+         http://www.apache.org/licenses/LICENSE-2.0
+   
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<body>
+<p>The Local File Provider.</p>
+</body>
\ No newline at end of file

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/package.html
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/package.html?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/package.html (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/package.html Thu Sep 23 06:04:21 2010
@@ -0,0 +1,19 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+   
+         http://www.apache.org/licenses/LICENSE-2.0
+   
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<body>
+<p>The File Provider API, and utility classes.</p>
+</body>
\ No newline at end of file