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 [9/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/apa...

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractLayeredFileProvider.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,108 @@
+/*
+ * 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;
+
+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;
+
+/**
+ * A {@link FileProvider} that is layered on top of another, such as the
+ * contents of a zip or tar file.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804273 $ $Date: 2009-08-14 21:26:52 +0530 (Fri, 14 Aug 2009) $
+ */
+public abstract class AbstractLayeredFileProvider
+    extends AbstractFileProvider
+    implements FileProvider
+{
+    public AbstractLayeredFileProvider()
+    {
+        super();
+        setFileNameParser(LayeredFileNameParser.getInstance());
+    }
+
+    /**
+     * Locates a file object, by absolute URI.
+     * @param baseFile The base FileObject.
+     * @param uri The name of the file to locate.
+     * @param properties The FileSystemOptions.
+     * @return The FileObject if it is located, null otherwise.
+     * @throws FileSystemException if an error occurs.
+     */
+    public FileObject findFile(final FileObject baseFile,
+                               final String uri,
+                               final FileSystemOptions properties) throws FileSystemException
+    {
+        // Split the URI up into its parts
+        final LayeredFileName name = (LayeredFileName) parseUri(baseFile != null ? baseFile.getName() : null, uri);
+
+        // Make the URI canonical
+
+        // Resolve the outer file name
+        final FileName fileName = name.getOuterName();
+        final FileObject file = getContext().resolveFile(baseFile, fileName.getURI(), properties);
+
+        // Create the file system
+        final FileObject rootFile = createFileSystem(name.getScheme(), file, properties);
+
+        // Resolve the file
+        return rootFile.resolveFile(name.getPath());
+    }
+
+    /**
+     * Creates a layered file system.
+     * @param scheme The protocol to use.
+     * @param file a FileObject.
+     * @param fileSystemOptions Options to access the FileSystem.
+     * @return A FileObject associated with the new FileSystem.
+     * @throws FileSystemException if an error occurs.
+     */
+    public synchronized FileObject createFileSystem(final String scheme,
+                                                    final FileObject file,
+                                                    final FileSystemOptions fileSystemOptions)
+        throws FileSystemException
+    {
+        // Check if cached
+        final FileName rootName = file.getName();
+        FileSystem fs = findFileSystem(rootName, null);
+        if (fs == null)
+        {
+            // Create the file system
+            fs = doCreateFileSystem(scheme, file, fileSystemOptions);
+            addFileSystem(rootName, fs);
+        }
+        return fs.getRoot();
+    }
+
+    /**
+     * Creates a layered file system.  This method is called if the file system
+     * is not cached.  The file system may implement {@link VfsComponent}.
+     *
+     * @param scheme The URI scheme.
+     * @param file   The file to create the file system on top of.
+     * @return The file system.
+     */
+    protected abstract FileSystem doCreateFileSystem(final String scheme,
+                                                     final FileObject file,
+                                                     final FileSystemOptions fileSystemOptions)
+        throws FileSystemException;
+
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,122 @@
+/*
+ * 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;
+
+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;
+
+/**
+ * A {@link FileProvider} that handles physical files, such as the files in a
+ * local fs, or on an FTP server.  An originating file system cannot be
+ * layered on top of another file system.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804273 $ $Date: 2009-08-14 21:26:52 +0530 (Fri, 14 Aug 2009) $
+ */
+public abstract class AbstractOriginatingFileProvider
+    extends AbstractFileProvider
+{
+    public AbstractOriginatingFileProvider()
+    {
+        super();
+    }
+
+    /**
+     * Locates a file object, by absolute URI.
+     *
+     * @param baseFile The base file object.
+     * @param uri The URI of the file to locate
+     * @param fileSystemOptions The FileSystem options.
+     * @return The located FileObject
+     * @throws FileSystemException if an error occurs.
+     */
+    public FileObject findFile(final FileObject baseFile,
+                               final String uri,
+                               final FileSystemOptions fileSystemOptions) throws FileSystemException
+    {
+        // Parse the URI
+        final FileName name;
+        try
+        {
+            name = parseUri(baseFile != null ? baseFile.getName() : null, uri);
+        }
+        catch (FileSystemException exc)
+        {
+            throw new FileSystemException("vfs.provider/invalid-absolute-uri.error", uri, exc);
+        }
+
+        // Locate the file
+        return findFile(name, fileSystemOptions);
+    }
+
+    /**
+     * Locates a file from its parsed URI.
+     * @param name The file name.
+     * @param fileSystemOptions FileSystem options.
+     * @return A FileObject associated with the file.
+     * @throws FileSystemException if an error occurs.
+     */
+    protected FileObject findFile(final FileName name, final FileSystemOptions fileSystemOptions)
+        throws FileSystemException
+    {
+        // Check in the cache for the file system
+        final FileName rootName = getContext().getFileSystemManager().resolveName(name, FileName.ROOT_PATH);
+
+        FileSystem fs = getFileSystem(rootName, fileSystemOptions);
+
+        // Locate the file
+        // return fs.resolveFile(name.getPath());
+        return fs.resolveFile(name);
+    }
+
+    /**
+     * Returns the FileSystem associated with the specified root.
+     * @param rootName The root path.
+     * @param fileSystemOptions The FileSystem options.
+     * @return The FileSystem.
+     * @throws FileSystemException if an error occurs.
+     */
+    protected synchronized FileSystem getFileSystem(FileName rootName, final FileSystemOptions fileSystemOptions)
+        throws FileSystemException
+    {
+        FileSystem fs = findFileSystem(rootName, fileSystemOptions);
+        if (fs == null)
+        {
+            // Need to create the file system, and cache it
+            fs = doCreateFileSystem(rootName, fileSystemOptions);
+            addFileSystem(rootName, fs);
+        }
+        return fs;
+    }
+
+
+
+    /**
+     * Creates a {@link FileSystem}.  If the returned FileSystem implements
+     * {@link VfsComponent}, it will be initialised.
+     *
+     * @param rootName The name of the root file of the file system to create.
+     * @param fileSystemOptions The FileSystem options.
+     * @return The FileSystem.
+     * @throws FileSystemException if an error occurs.
+     */
+    protected abstract FileSystem doCreateFileSystem(final FileName rootName, final FileSystemOptions fileSystemOptions)
+        throws FileSystemException;
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessContent.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessContent.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessContent.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessContent.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,120 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.RandomAccessContent;
+import org.apache.commons.vfs.util.RandomAccessMode;
+
+import java.io.IOException;
+
+/**
+ * Implements the DataOutput part of the RandomAccessContent interface and throws
+ * UnsupportedOperationException if one of those methods are called.
+ * (for read-only random access implementations)
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 804273 $ $Date: 2009-08-14 21:26:52 +0530 (Fri, 14 Aug 2009) $
+ */
+public abstract class AbstractRandomAccessContent implements RandomAccessContent
+{
+    private final RandomAccessMode mode;
+
+    protected AbstractRandomAccessContent(final RandomAccessMode mode)
+    {
+        this.mode = mode;
+    }
+
+    public void writeDouble(double v) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeFloat(float v) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void write(int b) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeByte(int v) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeChar(int v) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeInt(int v) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeShort(int v) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeLong(long v) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeBoolean(boolean v) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void write(byte[] b) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void write(byte[] b, int off, int len) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeBytes(String s) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeChars(String s) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void writeUTF(String str) throws IOException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * @deprecated see {@link java.io.DataInputStream#readLine()}
+     * @return The line as a String.
+     * @throws IOException if an error occurs.
+     */
+    public String readLine() throws IOException
+    {
+        throw new UnsupportedOperationException("deprecated");
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessStreamContent.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessStreamContent.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessStreamContent.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractRandomAccessStreamContent.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,126 @@
+/*
+ * 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;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.vfs.util.RandomAccessMode;
+
+/**
+ * Implements the part usable for all stream base random access implementations.
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public abstract class AbstractRandomAccessStreamContent extends AbstractRandomAccessContent
+{
+    protected AbstractRandomAccessStreamContent(final RandomAccessMode mode)
+    {
+        super(mode);
+    }
+
+    protected abstract DataInputStream getDataInputStream() throws IOException;
+
+    public byte readByte() throws IOException
+    {
+        byte data = getDataInputStream().readByte();
+        return data;
+    }
+
+    public char readChar() throws IOException
+    {
+        char data = getDataInputStream().readChar();
+        return data;
+    }
+
+    public double readDouble() throws IOException
+    {
+        double data = getDataInputStream().readDouble();
+        return data;
+    }
+
+    public float readFloat() throws IOException
+    {
+        float data = getDataInputStream().readFloat();
+        return data;
+    }
+
+    public int readInt() throws IOException
+    {
+        int data = getDataInputStream().readInt();
+        return data;
+    }
+
+    public int readUnsignedByte() throws IOException
+    {
+        int data = getDataInputStream().readUnsignedByte();
+        return data;
+    }
+
+    public int readUnsignedShort() throws IOException
+    {
+        int data = getDataInputStream().readUnsignedShort();
+        return data;
+    }
+
+    public long readLong() throws IOException
+    {
+        long data = getDataInputStream().readLong();
+        return data;
+    }
+
+    public short readShort() throws IOException
+    {
+        short data = getDataInputStream().readShort();
+        return data;
+    }
+
+    public boolean readBoolean() throws IOException
+    {
+        boolean data = getDataInputStream().readBoolean();
+        return data;
+    }
+
+    public int skipBytes(int n) throws IOException
+    {
+        int data = getDataInputStream().skipBytes(n);
+        return data;
+    }
+
+    public void readFully(byte[] b) throws IOException
+    {
+        getDataInputStream().readFully(b);
+    }
+
+    public void readFully(byte[] b, int off, int len) throws IOException
+    {
+        getDataInputStream().readFully(b, off, len);
+    }
+
+    public String readUTF() throws IOException
+    {
+        String data = getDataInputStream().readUTF();
+        return data;
+    }
+
+    public InputStream getInputStream() throws IOException
+    {
+        return getDataInputStream();
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsComponent.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,82 @@
+/*
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.vfs.FileSystemException;
+
+/**
+ * A partial {@link VfsComponent} implementation.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804273 $ $Date: 2009-08-14 21:26:52 +0530 (Fri, 14 Aug 2009) $
+ */
+public abstract class AbstractVfsComponent
+    implements VfsComponent
+{
+    private VfsComponentContext context;
+    private Log log;
+
+    /**
+     * Sets the Logger to use for the component.
+     * @param log The Log to use.
+     */
+    public final void setLogger(final Log log)
+    {
+        this.log = log;
+    }
+
+    /**
+     * Sets the context for this file system provider.
+     * @param context The VfsComponentContext.
+     */
+    public final void setContext(final VfsComponentContext context)
+    {
+        this.context = context;
+    }
+
+    /**
+     * Initialises the component.  This implementation does nothing.
+     * @throws FileSystemException if an error occurs.
+     */
+    public void init() throws FileSystemException
+    {
+    }
+
+    /**
+     * Closes the provider.  This implementation does nothing.
+     */
+    public void close()
+    {
+    }
+
+    /**
+     * Returns the logger for this file system to use.
+     */
+    protected final Log getLogger()
+    {
+        return log;
+    }
+
+    /**
+     * Returns the context for this provider.
+     */
+    protected final VfsComponentContext getContext()
+    {
+        return context;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/AbstractVfsContainer.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,87 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileSystemException;
+
+import java.util.ArrayList;
+
+/**
+ * A {@link VfsComponent} that contains a set of sub-components.
+ *
+ * @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 abstract class AbstractVfsContainer
+    extends AbstractVfsComponent
+{
+    /**
+     * The components contained by this component.
+     */
+    private final ArrayList components = new ArrayList();
+
+    /**
+     * Adds a sub-component to this component.  If the sub-component implements
+     * {@link VfsComponent}, it is initialised.  All sub-components are closed
+     * when this component is closed.
+     */
+    protected void addComponent(final Object component)
+        throws FileSystemException
+    {
+        if (!components.contains(component))
+        {
+            // Initialise
+            if (component instanceof VfsComponent)
+            {
+                VfsComponent vfsComponent = (VfsComponent) component;
+                vfsComponent.setLogger(getLogger());
+                vfsComponent.setContext(getContext());
+                vfsComponent.init();
+            }
+
+            // Keep track of component, to close it later
+            components.add(component);
+        }
+    }
+
+    /**
+     * Removes a sub-component from this component.
+     */
+    protected void removeComponent(final Object component)
+    {
+        components.remove(component);
+    }
+
+    /**
+     * Closes the sub-components of this component.
+     */
+    public void close()
+    {
+        // Close all components
+        final int count = components.size();
+        for (int i = 0; i < count; i++)
+        {
+            final Object component = components.get(i);
+            if (component instanceof VfsComponent)
+            {
+                final VfsComponent vfsComponent = (VfsComponent) component;
+                vfsComponent.close();
+            }
+        }
+        components.clear();
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/CompositeFileProvider.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/CompositeFileProvider.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/CompositeFileProvider.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/CompositeFileProvider.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,70 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+
+/**
+ * Description.
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public abstract class CompositeFileProvider extends AbstractFileProvider
+{
+    private static final int INITIAL_BUFSZ = 80;
+
+    public CompositeFileProvider()
+    {
+        super();
+    }
+
+    /**
+     * The schemes to use for resolve
+     */
+    protected abstract String[] getSchemes();
+
+    /**
+     * Locates a file object, by absolute URI.
+     * @param baseFile The base FileObject.
+     * @param uri The file to find.
+     * @param fileSystemOptions The options for the FileSystem.
+     * @return A FileObject for the located file.
+     * @throws FileSystemException if an error occurs.
+     */
+    public FileObject findFile(final FileObject baseFile,
+                               final String uri,
+                               final FileSystemOptions fileSystemOptions)
+        throws FileSystemException
+    {
+        StringBuffer buf = new StringBuffer(INITIAL_BUFSZ);
+
+        UriParser.extractScheme(uri, buf);
+
+        String[] schemes = getSchemes();
+        for (int iterSchemes = 0; iterSchemes < schemes.length; iterSchemes++)
+        {
+            buf.insert(0, ":");
+            buf.insert(0, schemes[iterSchemes]);
+        }
+
+        FileObject fo = getContext().getFileSystemManager().resolveFile(buf.toString(), fileSystemOptions);
+        return fo;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileContent.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,727 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileContent;
+import org.apache.commons.vfs.FileContentInfo;
+import org.apache.commons.vfs.FileContentInfoFactory;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.RandomAccessContent;
+import org.apache.commons.vfs.util.MonitorInputStream;
+import org.apache.commons.vfs.util.MonitorOutputStream;
+import org.apache.commons.vfs.util.MonitorRandomAccessContent;
+import org.apache.commons.vfs.util.RandomAccessMode;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.cert.Certificate;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The content of a file.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804273 $ $Date: 2009-08-14 21:26:52 +0530 (Fri, 14 Aug 2009) $
+ */
+public final class DefaultFileContent implements FileContent
+{
+    /*
+    static final int STATE_NONE = 0;
+    static final int STATE_READING = 1;
+    static final int STATE_WRITING = 2;
+    static final int STATE_RANDOM_ACCESS = 3;
+    */
+
+    static final int STATE_CLOSED = 0;
+    static final int STATE_OPENED = 1;
+
+    private final AbstractFileObject file;
+    private Map attrs;
+    private Map roAttrs;
+    private FileContentInfo fileContentInfo;
+    private final FileContentInfoFactory fileContentInfoFactory;
+
+    private final ThreadLocal threadData = new ThreadLocal();
+    private boolean resetAttributes;
+
+    /**
+     * open streams counter for this file
+     */
+    private int openStreams;
+
+    public DefaultFileContent(final AbstractFileObject file, final FileContentInfoFactory fileContentInfoFactory)
+    {
+        this.file = file;
+        this.fileContentInfoFactory = fileContentInfoFactory;
+    }
+
+    private FileContentThreadData getThreadData()
+    {
+        FileContentThreadData data = (FileContentThreadData) this.threadData.get();
+        if (data == null)
+        {
+            data = new FileContentThreadData();
+            this.threadData.set(data);
+        }
+        return data;
+    }
+
+    void streamOpened()
+    {
+        synchronized (this)
+        {
+            openStreams++;
+        }
+        ((AbstractFileSystem) file.getFileSystem()).streamOpened();
+    }
+
+    void streamClosed()
+    {
+        synchronized (this)
+        {
+            if (openStreams > 0)
+            {
+                openStreams--;
+                if (openStreams < 1)
+                {
+                    file.notifyAllStreamsClosed();
+                }
+            }
+        }
+        ((AbstractFileSystem) file.getFileSystem()).streamClosed();
+    }
+
+    /**
+     * Returns the file that this is the content of.
+     * @return the FileObject.
+     */
+    public FileObject getFile()
+    {
+        return file;
+    }
+
+    /**
+     * Returns the size of the content (in bytes).
+     * @return The size of the content (in bytes).
+     * @throws FileSystemException if an error occurs.
+     */
+    public long getSize() throws FileSystemException
+    {
+        // Do some checking
+        if (!file.getType().hasContent())
+        {
+            throw new FileSystemException("vfs.provider/get-size-not-file.error", file);
+        }
+        /*
+        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
+        {
+            throw new FileSystemException("vfs.provider/get-size-write.error", file);
+        }
+        */
+
+        try
+        {
+            // Get the size
+            return file.doGetContentSize();
+        }
+        catch (final Exception exc)
+        {
+            throw new FileSystemException("vfs.provider/get-size.error", new Object[]{file}, exc);
+        }
+    }
+
+    /**
+     * Returns the last-modified timestamp.
+     * @return The last modified timestamp.
+     * @throws FileSystemException if an error occurs.
+     */
+    public long getLastModifiedTime() throws FileSystemException
+    {
+        /*
+        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
+        {
+            throw new FileSystemException("vfs.provider/get-last-modified-writing.error", file);
+        }
+        */
+        if (!file.getType().hasAttributes())
+        {
+            throw new FileSystemException("vfs.provider/get-last-modified-no-exist.error", file);
+        }
+        try
+        {
+            return file.doGetLastModifiedTime();
+        }
+        catch (final Exception e)
+        {
+            throw new FileSystemException("vfs.provider/get-last-modified.error", file, e);
+        }
+    }
+
+    /**
+     * Sets the last-modified timestamp.
+     * @param modTime The last modified timestamp.
+     * @throws FileSystemException if an error occurs.
+     */
+    public void setLastModifiedTime(final long modTime) throws FileSystemException
+    {
+        /*
+        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
+        {
+            throw new FileSystemException("vfs.provider/set-last-modified-writing.error", file);
+        }
+        */
+        if (!file.getType().hasAttributes())
+        {
+            throw new FileSystemException("vfs.provider/set-last-modified-no-exist.error", file);
+        }
+        try
+        {
+            if (!file.doSetLastModTime(modTime))
+            {
+                throw new FileSystemException("vfs.provider/set-last-modified.error", file);
+            }
+        }
+        catch (final Exception e)
+        {
+            throw new FileSystemException("vfs.provider/set-last-modified.error", file, e);
+        }
+    }
+
+    /**
+     * Checks if an attribute exists.
+     * @param attrName The name of the attribute to check.
+     * @return true if the attribute is associated with the file.
+     * @throws FileSystemException if an error occurs.
+     */
+    public boolean hasAttribute(final String attrName) throws FileSystemException
+    {
+        if (!file.getType().hasAttributes())
+        {
+            throw new FileSystemException("vfs.provider/exists-attributes-no-exist.error", file);
+        }
+        getAttributes();
+        return attrs.containsKey(attrName);
+    }
+
+    /**
+     * Returns a read-only map of this file's attributes.
+     * @return a Map of the file's attributes.
+     * @throws FileSystemException if an error occurs.
+     */
+    public Map getAttributes() throws FileSystemException
+    {
+        if (!file.getType().hasAttributes())
+        {
+            throw new FileSystemException("vfs.provider/get-attributes-no-exist.error", file);
+        }
+        if (resetAttributes || roAttrs == null)
+        {
+            try
+            {
+                synchronized (this)
+                {
+                    attrs = file.doGetAttributes();
+                    roAttrs = Collections.unmodifiableMap(attrs);
+                    resetAttributes = false;
+                }
+            }
+            catch (final Exception e)
+            {
+                throw new FileSystemException("vfs.provider/get-attributes.error", file, e);
+            }
+        }
+        return roAttrs;
+    }
+
+    /**
+     * Used internally to flag situations where the file attributes should be
+     * reretrieved.
+     */
+    public void resetAttributes()
+    {
+        resetAttributes = true;
+    }
+
+    /**
+     * Lists the attributes of this file.
+     * @return An array of attribute names.
+     * @throws FileSystemException if an error occurs.
+     */
+    public String[] getAttributeNames() throws FileSystemException
+    {
+        getAttributes();
+        final Set names = attrs.keySet();
+        return (String[]) names.toArray(new String[names.size()]);
+    }
+
+    /**
+     * Gets the value of an attribute.
+     * @param attrName The attribute name.
+     * @return The value of the attribute or null.
+     * @throws FileSystemException if an error occurs.
+     */
+    public Object getAttribute(final String attrName)
+        throws FileSystemException
+    {
+        getAttributes();
+        return attrs.get(attrName);
+    }
+
+    /**
+     * Sets the value of an attribute.
+     * @param attrName The name of the attribute to add.
+     * @param value The value of the attribute.
+     * @throws FileSystemException if an error occurs.
+     */
+    public void setAttribute(final String attrName, final Object value)
+        throws FileSystemException
+    {
+        if (!file.getType().hasAttributes())
+        {
+            throw new FileSystemException("vfs.provider/set-attribute-no-exist.error", new Object[]{attrName, file});
+        }
+        try
+        {
+            file.doSetAttribute(attrName, value);
+        }
+        catch (final Exception e)
+        {
+            throw new FileSystemException("vfs.provider/set-attribute.error", new Object[]{attrName, file}, e);
+        }
+
+        if (attrs != null)
+        {
+            attrs.put(attrName, value);
+        }
+    }
+
+    /**
+     * Removes an attribute.
+     * @param attrName The name of the attribute to remove.
+     * @throws FileSystemException if an error occurs.
+     */
+    public void removeAttribute(final String attrName) throws FileSystemException
+    {
+        if (!file.getType().hasAttributes())
+        {
+            throw new FileSystemException("vfs.provider/remove-attribute-no-exist.error", file);
+        }
+
+        try
+        {
+            file.doRemoveAttribute(attrName);
+        }
+        catch (final Exception e)
+        {
+            throw new FileSystemException("vfs.provider/remove-attribute.error", new Object[]{attrName, file}, e);
+        }
+
+        if (attrs != null)
+        {
+            attrs.remove(attrName);
+        }
+    }
+
+    /**
+     * Returns the certificates used to sign this file.
+     * @return An array of Certificates.
+     * @throws FileSystemException if an error occurs.
+     */
+    public Certificate[] getCertificates() throws FileSystemException
+    {
+        if (!file.exists())
+        {
+            throw new FileSystemException("vfs.provider/get-certificates-no-exist.error", file);
+        }
+        /*
+        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
+        {
+            throw new FileSystemException("vfs.provider/get-certificates-writing.error", file);
+        }
+        */
+
+        try
+        {
+            final Certificate[] certs = file.doGetCertificates();
+            if (certs != null)
+            {
+                return certs;
+            }
+            else
+            {
+                return new Certificate[0];
+            }
+        }
+        catch (final Exception e)
+        {
+            throw new FileSystemException("vfs.provider/get-certificates.error", file, e);
+        }
+    }
+
+    /**
+     * Returns an input stream for reading the content.
+     * @return The InputStream
+     * @throws FileSystemException if an error occurs.
+     */
+    public InputStream getInputStream() throws FileSystemException
+    {
+        /*
+        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
+        {
+            throw new FileSystemException("vfs.provider/read-in-use.error", file);
+        }
+        */
+
+        // Get the raw input stream
+        final InputStream instr = file.getInputStream();
+
+        final InputStream wrappedInstr = new FileContentInputStream(file, instr);
+
+        this.getThreadData().addInstr(wrappedInstr);
+        streamOpened();
+
+        // setState(STATE_OPENED);
+        return wrappedInstr;
+    }
+
+    /**
+     * Returns an input/output stream to use to read and write the content of the file in an
+     * random manner.
+     * @param mode The RandomAccessMode.
+     * @return A RandomAccessContent object to access the file.
+     * @throws FileSystemException if an error occurs.
+     */
+    public RandomAccessContent getRandomAccessContent(final RandomAccessMode mode) throws FileSystemException
+    {
+        /*
+        if (getThreadData().getState() != STATE_NONE)
+        {
+            throw new FileSystemException("vfs.provider/read-in-use.error", file);
+        }
+        */
+
+        // Get the content
+        final RandomAccessContent rastr = file.getRandomAccessContent(mode);
+
+        FileRandomAccessContent rac = new FileRandomAccessContent(file, rastr);
+        this.getThreadData().addRastr(rac);
+        streamOpened();
+
+        // setState(STATE_OPENED);
+        return rac;
+    }
+
+    /**
+     * Returns an output stream for writing the content.
+     * @return The OutputStream for the file.
+     * @throws FileSystemException if an error occurs.
+     */
+    public OutputStream getOutputStream() throws FileSystemException
+    {
+        return getOutputStream(false);
+    }
+
+    /**
+     * Returns an output stream for writing the content in append mode.
+     * @param bAppend true if the data written should be appended.
+     * @return The OutputStream for the file.
+     * @throws FileSystemException if an error occurs.
+     */
+    public OutputStream getOutputStream(boolean bAppend) throws FileSystemException
+    {
+        /*
+        if (getThreadData().getState() != STATE_NONE)
+        */
+        if (this.getThreadData().getOutstr() != null)
+        {
+            throw new FileSystemException("vfs.provider/write-in-use.error", file);
+        }
+
+        // Get the raw output stream
+        final OutputStream outstr = file.getOutputStream(bAppend);
+
+        // Create wrapper
+        this.getThreadData().setOutstr(new FileContentOutputStream(file, outstr));
+        streamOpened();
+
+        // setState(STATE_OPENED);
+        return this.getThreadData().getOutstr();
+    }
+
+    /**
+     * Closes all resources used by the content, including all streams, readers
+     * and writers.
+     * @throws FileSystemException if an error occurs.
+     */
+    public void close() throws FileSystemException
+    {
+        try
+        {
+            // Close the input stream
+            while (getThreadData().getInstrsSize() > 0)
+            {
+                final FileContentInputStream instr = (FileContentInputStream) getThreadData().removeInstr(0);
+                instr.close();
+            }
+
+            // Close the randomAccess stream
+            while (getThreadData().getRastrsSize() > 0)
+            {
+                final RandomAccessContent ra = (RandomAccessContent) getThreadData().removeRastr(0);
+                try
+                {
+                    ra.close();
+                }
+                catch (IOException e)
+                {
+                    throw new FileSystemException(e);
+                }
+            }
+
+            // Close the output stream
+            if (this.getThreadData().getOutstr() != null)
+            {
+                this.getThreadData().closeOutstr();
+            }
+        }
+        finally
+        {
+            threadData.set(null);
+        }
+    }
+
+    /**
+     * Handles the end of input stream.
+     */
+    private void endInput(final FileContentInputStream instr)
+    {
+        getThreadData().removeInstr(instr);
+        streamClosed();
+        /*
+        if (!getThreadData().hasStreams())
+        {
+            setState(STATE_CLOSED);
+        }
+        */
+    }
+
+    /**
+     * Handles the end of random access.
+     */
+    private void endRandomAccess(RandomAccessContent rac)
+    {
+        getThreadData().removeRastr(rac);
+        streamClosed();
+        // setState(STATE_CLOSED);
+    }
+
+    /**
+     * Handles the end of output stream.
+     */
+    private void endOutput() throws Exception
+    {
+        streamClosed();
+
+        this.getThreadData().setOutstr(null);
+        // setState(STATE_CLOSED);
+
+        file.endOutput();
+    }
+
+    /*
+    private void setState(int state)
+    {
+        getThreadData().setState(state);
+    }
+    */
+
+    /**
+     * check if a input and/or output stream is open.<br />
+     * This checks only the scope of the current thread.
+     *
+     * @return true if this is the case
+     */
+    public boolean isOpen()
+    {
+        // return getThreadData().getState() == STATE_OPENED;
+        return getThreadData().hasStreams();
+    }
+
+    /**
+     * check if a input and/or output stream is open.<br />
+     * This checks all threads.
+     *
+     * @return true if this is the case
+     */
+    public boolean isOpenGlobal()
+    {
+        synchronized (this)
+        {
+            return openStreams > 0;
+        }
+    }
+
+    /**
+     * An input stream for reading content.  Provides buffering, and
+     * end-of-stream monitoring.
+     */
+    private final class FileContentInputStream
+        extends MonitorInputStream
+    {
+        // avoid gc
+        private final FileObject file;
+
+        FileContentInputStream(final FileObject file, final InputStream instr)
+        {
+            super(instr);
+            this.file = file;
+        }
+
+        /**
+         * Closes this input stream.
+         */
+        public void close() throws FileSystemException
+        {
+            try
+            {
+                super.close();
+            }
+            catch (final IOException e)
+            {
+                throw new FileSystemException("vfs.provider/close-instr.error", file, e);
+            }
+        }
+
+        /**
+         * Called after the stream has been closed.
+         */
+        protected void onClose() throws IOException
+        {
+            try
+            {
+                super.onClose();
+            }
+            finally
+            {
+                endInput(this);
+            }
+        }
+    }
+
+    /**
+     * An input/output stream for reading/writing content on random positions
+     */
+    private final class FileRandomAccessContent extends MonitorRandomAccessContent
+    {
+        // avoid gc
+        private final FileObject file;
+        private final RandomAccessContent content;
+
+        FileRandomAccessContent(final FileObject file, final RandomAccessContent content)
+        {
+            super(content);
+            this.file = file;
+            this.content = content;
+        }
+
+        /**
+         * Called after the stream has been closed.
+         */
+        protected void onClose() throws IOException
+        {
+            try
+            {
+                super.onClose();
+            }
+            finally
+            {
+                endRandomAccess(this);
+            }
+        }
+    }
+
+    /**
+     * An output stream for writing content.
+     */
+    final class FileContentOutputStream extends MonitorOutputStream
+    {
+        // avoid gc
+        private final FileObject file;
+
+        FileContentOutputStream(final FileObject file, final OutputStream outstr)
+        {
+            super(outstr);
+            this.file = file;
+        }
+
+        /**
+         * Closes this output stream.
+         */
+        public void close() throws FileSystemException
+        {
+            try
+            {
+                super.close();
+            }
+            catch (final IOException e)
+            {
+                throw new FileSystemException("vfs.provider/close-outstr.error", file, e);
+            }
+        }
+
+        /**
+         * Called after this stream is closed.
+         */
+        protected void onClose() throws IOException
+        {
+            try
+            {
+                super.onClose();
+            }
+            finally
+            {
+                try
+                {
+                    endOutput();
+                }
+                catch (Exception e)
+                {
+                    throw new FileSystemException("vfs.provider/close-outstr.error", file, e);
+                }
+            }
+        }
+    }
+
+    /**
+     * get the content info. e.g. content-type, content-encoding
+     * @return The FileContentInfo.
+     * @throws FileSystemException if an error occurs.
+     */
+    public FileContentInfo getContentInfo() throws FileSystemException
+    {
+        if (fileContentInfo == null)
+        {
+            fileContentInfo = fileContentInfoFactory.create(this);
+        }
+
+        return fileContentInfo;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileSelectorInfo.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileSelectorInfo.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileSelectorInfo.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultFileSelectorInfo.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSelectInfo;
+
+/**
+ * A default {@link FileSelectInfo} implementation.
+ *
+ * @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) $
+ */
+final class DefaultFileSelectorInfo
+    implements FileSelectInfo
+{
+    private FileObject baseFolder;
+    private FileObject file;
+    private int depth;
+
+    public FileObject getBaseFolder()
+    {
+        return baseFolder;
+    }
+
+    public void setBaseFolder(final FileObject baseFolder)
+    {
+        this.baseFolder = baseFolder;
+    }
+
+    public FileObject getFile()
+    {
+        return file;
+    }
+
+    public void setFile(final FileObject file)
+    {
+        this.file = file;
+    }
+
+    public int getDepth()
+    {
+        return depth;
+    }
+
+    public void setDepth(final int depth)
+    {
+        this.depth = depth;
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLConnection.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLConnection.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLConnection.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLConnection.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;
+
+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.URL;
+import java.net.URLConnection;
+
+/**
+ * A default URL connection that will work for most file systems.
+ *
+ * @author <a href="mailto:brian@mmmanager.org">Brian Olsen</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public final class DefaultURLConnection
+    extends URLConnection
+{
+    private final FileContent content;
+
+    public DefaultURLConnection(final URL url,
+                                final FileContent content)
+    {
+        super(url);
+        this.content = content;
+    }
+
+    public void connect()
+    {
+        connected = true;
+    }
+
+    public InputStream getInputStream()
+        throws IOException
+    {
+        return content.getInputStream();
+    }
+
+    public OutputStream getOutputStream()
+        throws IOException
+    {
+        return content.getOutputStream();
+    }
+
+
+    public long getLastModified()
+    {
+        try
+        {
+            return content.getLastModifiedTime();
+        }
+        catch (FileSystemException fse)
+        {
+            // Ignore the exception
+        }
+
+        return -1;
+    }
+
+    public int getContentLength()
+    {
+        try
+        {
+            return (int) content.getSize();
+        }
+        catch (FileSystemException fse)
+        {
+            // Ignore the exception
+        }
+
+        return -1;
+    }
+
+    public String getContentType()
+    {
+        try
+        {
+            return content.getContentInfo().getContentType();
+        }
+        catch (FileSystemException e)
+        {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    public String getContentEncoding()
+    {
+        try
+        {
+            return content.getContentInfo().getContentEncoding();
+        }
+        catch (FileSystemException e)
+        {
+            throw new RuntimeException(e.getMessage());
+        }
+    }
+
+    /*
+    public String getHeaderField(String name)
+    {
+        try
+        {
+            if (content.getFile().getFileSystem().hasCapability(Capability.ATTRIBUTES))
+            {
+                String value = (String) content.getAttribute(name);
+                if (value != null)
+                {
+                    return value;
+                }
+            }
+
+            return null;
+        }
+        catch (FileSystemException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+    */
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLStreamHandler.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLStreamHandler.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLStreamHandler.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DefaultURLStreamHandler.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,103 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileType;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * A default URL stream handler that will work for most file systems.
+ *
+ * @author <a href="mailto:brian@mmmanager.org">Brian Olsen</a>
+ * @version $Revision: 764356 $ $Date: 2009-04-13 09:36:01 +0530 (Mon, 13 Apr 2009) $
+ */
+public class DefaultURLStreamHandler
+    extends URLStreamHandler
+{
+    private final VfsComponentContext context;
+    private final FileSystemOptions fileSystemOptions;
+
+    public DefaultURLStreamHandler(final VfsComponentContext context)
+    {
+        this(context, null);
+    }
+
+    public DefaultURLStreamHandler(final VfsComponentContext context, final FileSystemOptions fileSystemOptions)
+    {
+        this.context = context;
+        this.fileSystemOptions = fileSystemOptions;
+    }
+
+    protected URLConnection openConnection(final URL url)
+        throws IOException
+    {
+        final FileObject entry = context.resolveFile(url.toExternalForm(), fileSystemOptions);
+        return new DefaultURLConnection(url, entry.getContent());
+    }
+
+    protected void parseURL(final URL u,
+                            final String spec,
+                            final int start,
+                            final int limit)
+    {
+        try
+        {
+            FileObject old = context.resolveFile(u.toExternalForm(), fileSystemOptions);
+
+            FileObject newURL;
+            if (start > 0 && spec.charAt(start - 1) == ':')
+            {
+                newURL = context.resolveFile(old, spec, fileSystemOptions);
+            }
+            else
+            {
+                if (old.getType() == FileType.FILE && old.getParent() != null)
+                {
+                    // for files we have to resolve relative
+                    newURL = old.getParent().resolveFile(spec);
+                }
+                else
+                {
+                    newURL = old.resolveFile(spec);
+                }
+            }
+
+            final String url = newURL.getName().getURI();
+            final StringBuffer filePart = new StringBuffer();
+            final String protocolPart = UriParser.extractScheme(url, filePart);
+
+            setURL(u, protocolPart, "", -1, null, null, filePart.toString(), null, null);
+        }
+        catch (FileSystemException fse)
+        {
+            // This is rethrown to MalformedURLException in URL anyway
+            throw new RuntimeException(fse.getMessage());
+        }
+    }
+
+    protected String toExternalForm(final URL u)
+    {
+        return u.getProtocol() + ":" + u.getFile();
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/DelegateFileObject.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,436 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.util.WeakRefFileListener;
+import org.apache.commons.vfs.util.RandomAccessMode;
+import org.apache.commons.vfs.FileListener;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.FileNotFolderException;
+import org.apache.commons.vfs.FileChangeEvent;
+import org.apache.commons.vfs.FileContentInfo;
+import org.apache.commons.vfs.RandomAccessContent;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.cert.Certificate;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A file backed by another file.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @author Gary D. Gregory
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ * @todo Extract subclass that overlays the children
+ */
+public class DelegateFileObject
+    extends AbstractFileObject
+    implements FileListener
+{
+    private FileObject file;
+    private final Set children = new HashSet();
+    private boolean ignoreEvent;
+
+    public DelegateFileObject(final FileName name,
+                              final AbstractFileSystem fileSystem,
+                              final FileObject file) throws FileSystemException
+    {
+        super(name, fileSystem);
+        this.file = file;
+        if (file != null)
+        {
+            WeakRefFileListener.installListener(file, this);
+        }
+    }
+
+    /**
+     * Get access to the delegated file.
+     * @return The FileObject.
+     */
+    public FileObject getDelegateFile()
+    {
+        return file;
+    }
+
+    /**
+     * Adds a child to this file.
+     * @param baseName The base FileName.
+     * @param type The FileType.
+     * @throws Exception if an error occurs.
+     */
+    public void attachChild(final FileName baseName, final FileType type) throws Exception
+    {
+        final FileType oldType = doGetType();
+        if (children.add(baseName.getBaseName()))
+        {
+            childrenChanged(baseName, type);
+        }
+        maybeTypeChanged(oldType);
+    }
+
+    /**
+     * Attaches or detaches the target file.
+     * @param file The FileObject.
+     * @throws Exception if an error occurs.
+     */
+    public void setFile(final FileObject file) throws Exception
+    {
+        final FileType oldType = doGetType();
+
+        if (file != null)
+        {
+            WeakRefFileListener.installListener(file, this);
+        }
+        this.file = file;
+        maybeTypeChanged(oldType);
+    }
+
+    /**
+     * Checks whether the file's type has changed, and fires the appropriate
+     * events.
+     * @param oldType The old FileType.
+     * @throws Exception if an error occurs.
+     */
+    private void maybeTypeChanged(final FileType oldType) throws Exception
+    {
+        final FileType newType = doGetType();
+        if (oldType == FileType.IMAGINARY && newType != FileType.IMAGINARY)
+        {
+            handleCreate(newType);
+        }
+        else if (oldType != FileType.IMAGINARY && newType == FileType.IMAGINARY)
+        {
+            handleDelete();
+        }
+    }
+
+    /**
+     * Determines the type of the file, returns null if the file does not
+     * exist.
+     */
+    protected FileType doGetType() throws FileSystemException
+    {
+        if (file != null)
+        {
+            return file.getType();
+        }
+        else if (children.size() > 0)
+        {
+            return FileType.FOLDER;
+        }
+        else
+        {
+            return FileType.IMAGINARY;
+        }
+    }
+
+    /**
+     * Determines if this file can be read.
+     */
+    protected boolean doIsReadable() throws FileSystemException
+    {
+        if (file != null)
+        {
+            return file.isReadable();
+        }
+        else
+        {
+            return true;
+        }
+    }
+
+    /**
+     * Determines if this file can be written to.
+     */
+    protected boolean doIsWriteable() throws FileSystemException
+    {
+        if (file != null)
+        {
+            return file.isWriteable();
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+     * Determines if this file is hidden.
+     */
+    protected boolean doIsHidden() throws FileSystemException
+    {
+        if (file != null)
+        {
+            return file.isHidden();
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+     * Lists the children of the file.
+     */
+    protected String[] doListChildren() throws Exception
+    {
+        if (file != null)
+        {
+            final FileObject[] children;
+
+            try
+            {
+                children = file.getChildren();
+            }
+            // VFS-210
+            catch (FileNotFolderException e)
+            {
+                throw new FileNotFolderException(getName(), e);
+            }
+
+            final String[] childNames = new String[children.length];
+            for (int i = 0; i < children.length; i++)
+            {
+                childNames[i] = children[i].getName().getBaseName();
+            }
+            return childNames;
+        }
+        else
+        {
+            return (String[]) children.toArray(new String[children.size()]);
+        }
+    }
+
+    /**
+     * Creates this file as a folder.
+     */
+    protected void doCreateFolder() throws Exception
+    {
+        ignoreEvent = true;
+        try
+        {
+            file.createFolder();
+        }
+        finally
+        {
+            ignoreEvent = false;
+        }
+    }
+
+    /**
+     * Deletes the file.
+     */
+    protected void doDelete() throws Exception
+    {
+        ignoreEvent = true;
+        try
+        {
+            file.delete();
+        }
+        finally
+        {
+            ignoreEvent = false;
+        }
+    }
+
+    /**
+     * Returns the size of the file content (in bytes).  Is only called if
+     * {@link #doGetType} returns {@link FileType#FILE}.
+     */
+    protected long doGetContentSize() throws Exception
+    {
+        return file.getContent().getSize();
+    }
+
+    /**
+     * Returns the attributes of this file.
+     */
+    protected Map doGetAttributes()
+        throws Exception
+    {
+        return file.getContent().getAttributes();
+    }
+
+    /**
+     * Sets an attribute of this file.
+     */
+    protected void doSetAttribute(final String atttrName,
+                                  final Object value)
+        throws Exception
+    {
+        file.getContent().setAttribute(atttrName, value);
+    }
+
+    /**
+     * Returns the certificates of this file.
+     */
+    protected Certificate[] doGetCertificates() throws Exception
+    {
+        return file.getContent().getCertificates();
+    }
+
+    /**
+     * Returns the last-modified time of this file.
+     */
+    protected long doGetLastModifiedTime() throws Exception
+    {
+        return file.getContent().getLastModifiedTime();
+    }
+
+    /**
+     * Sets the last-modified time of this file.
+     */
+    protected boolean doSetLastModTime(final long modtime)
+        throws Exception
+    {
+        file.getContent().setLastModifiedTime(modtime);
+        return true;
+    }
+
+    /**
+     * Creates an input stream to read the file content from.
+     */
+    protected InputStream doGetInputStream() throws Exception
+    {
+        return file.getContent().getInputStream();
+    }
+
+    /**
+     * Creates an output stream to write the file content to.
+     */
+    protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
+    {
+        return file.getContent().getOutputStream(bAppend);
+    }
+
+    /**
+     * Called when a file is created.
+     * @param event The FileChangeEvent.
+     * @throws Exception if an error occurs.
+     */
+    public void fileCreated(final FileChangeEvent event) throws Exception
+    {
+        if (event.getFile() != file)
+        {
+            return;
+        }
+        if (!ignoreEvent)
+        {
+            handleCreate(file.getType());
+        }
+    }
+
+    /**
+     * Called when a file is deleted.
+     * @param event The FileChangeEvent.
+     * @throws Exception if an error occurs.
+     */
+    public void fileDeleted(final FileChangeEvent event) throws Exception
+    {
+        if (event.getFile() != file)
+        {
+            return;
+        }
+        if (!ignoreEvent)
+        {
+            handleDelete();
+        }
+    }
+
+    /**
+     * Called when a file is changed.
+     * <p/>
+     * This will only happen if you monitor the file using {@link org.apache.commons.vfs.FileMonitor}.
+     * @param event The FileChangeEvent.
+     * @throws Exception if an error occurs.
+     */
+    public void fileChanged(FileChangeEvent event) throws Exception
+    {
+        if (event.getFile() != file)
+        {
+            return;
+        }
+        if (!ignoreEvent)
+        {
+            handleChanged();
+        }
+    }
+
+    /**
+     * Close the delegated file.
+     * @throws FileSystemException if an error occurs.
+     */
+    public void close() throws FileSystemException
+    {
+        super.close();
+
+        if (file != null)
+        {
+            file.close();
+        }
+    }
+
+    /**
+     * Refresh file information.
+     * @throws FileSystemException if an error occurs.
+     */
+    public void refresh() throws FileSystemException
+    {
+        super.refresh();
+        if (file != null)
+        {
+            file.refresh();
+        }
+    }
+
+    protected FileContentInfo doGetContentInfo() throws Exception
+    {
+        return file.getContent().getContentInfo();
+    }
+
+    /**
+     * Renames the file.
+     */
+    protected void doRename(FileObject newFile)
+        throws Exception
+    {
+        file.moveTo(((DelegateFileObject) newFile).file);
+    }
+
+    /**
+     * Removes an attribute of this file.
+     */
+    protected void doRemoveAttribute(final String atttrName)
+        throws Exception
+    {
+        file.getContent().removeAttribute(atttrName);
+    }
+
+    /**
+     * Creates access to the file for random i/o.
+     */
+    protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
+    {
+        return file.getContent().getRandomAccessContent(mode);
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileContentThreadData.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,113 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.RandomAccessContent;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+
+/**
+ * Holds the data which needs to be local to the current thread
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+class FileContentThreadData
+{
+    // private int state = DefaultFileContent.STATE_CLOSED;
+
+    private final ArrayList instrs = new ArrayList();
+    private final ArrayList rastrs = new ArrayList();
+    private DefaultFileContent.FileContentOutputStream outstr;
+
+    FileContentThreadData()
+    {
+    }
+
+    /*
+    int getState()
+    {
+        return state;
+    }
+
+    void setState(int state)
+    {
+        this.state = state;
+    }
+    */
+
+    void addInstr(InputStream is)
+    {
+        this.instrs.add(is);
+    }
+
+    void setOutstr(DefaultFileContent.FileContentOutputStream os)
+    {
+        this.outstr = os;
+    }
+
+    DefaultFileContent.FileContentOutputStream getOutstr()
+    {
+        return this.outstr;
+    }
+
+    void addRastr(RandomAccessContent ras)
+    {
+        this.rastrs.add(ras);
+    }
+
+    int getInstrsSize()
+    {
+        return this.instrs.size();
+    }
+
+    public Object removeInstr(int pos)
+    {
+        return this.instrs.remove(pos);
+    }
+
+    public void removeInstr(InputStream instr)
+    {
+        this.instrs.remove(instr);
+    }
+
+    public Object removeRastr(int pos)
+    {
+        return this.rastrs.remove(pos);
+    }
+
+    public void removeRastr(RandomAccessContent ras)
+    {
+        this.rastrs.remove(ras);
+    }
+
+    public boolean hasStreams()
+    {
+        return instrs.size() > 0 || outstr != null || rastrs.size() > 0;
+    }
+
+    public void closeOutstr() throws FileSystemException
+    {
+        outstr.close();
+        outstr = null;
+    }
+
+    int getRastrsSize()
+    {
+        return rastrs.size();
+    }
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileNameParser.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileNameParser.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileNameParser.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileNameParser.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileSystemException;
+
+/**
+ * Provides methods to parse a filename into a {@link org.apache.commons.vfs.FileName}.
+ * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
+ */
+public interface FileNameParser
+{
+    /**
+     * Check if a character needs encoding (%nn).
+     * @param ch the character
+     * @return true if character should be encoded
+     */
+    boolean encodeCharacter(char ch);
+
+    /**
+     * parses a String into a filename.
+     * @param context The component context.
+     * @param base The base FileName.
+     * @param filename The target file name.
+     * @return A FileName that represents the taret file.
+     * @throws FileSystemException if an error occurs parsing the URI.
+     */
+    FileName parseUri(final VfsComponentContext context, final FileName base, final String filename)
+            throws FileSystemException;
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileProvider.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;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemConfigBuilder;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemOptions;
+
+import java.util.Collection;
+
+
+/**
+ * A file provider.  Each file provider is responsible for handling files for
+ * a particular URI scheme.
+ * <p/>
+ * <p>A file provider may also implement {@link VfsComponent}.
+ *
+ * @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+public interface FileProvider
+{
+    /**
+     * Locates a file object, by absolute URI.
+     *
+     * @param baseFile          The base file to use for resolving the individual parts of
+     *                          a compound URI.
+     * @param uri               The absolute URI of the file to find.
+     * @param fileSystemOptions The FileSystemOptions
+     * @return The FileObject.
+     * @throws FileSystemException if an error occurs locating the file.
+     */
+    FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
+        throws FileSystemException;
+
+    /**
+     * Creates a layered file system.
+     *
+     * @param scheme            The URI scheme for the layered file system.
+     * @param file              The file to build the file system on.
+     * @param fileSystemOptions The FileSystemOptions.
+     * @return A FileObject in the file system.
+     * @throws FileSystemException if an error occurs.
+     */
+    FileObject createFileSystem(String scheme, FileObject file, FileSystemOptions fileSystemOptions)
+        throws FileSystemException;
+
+    /**
+     * Gets the configbuilder useable to collect the needed fileSystemOptions.
+     * @return a FileSystemConfigBuilder for the particular file system.
+     */
+    FileSystemConfigBuilder getConfigBuilder();
+
+    /**
+     * Get the filesystem capabilities.<br>
+     * These are the same as on the filesystem, but available before the first filesystem was
+     * instanciated.
+     * @return a Collection of the file systems Capabilities.
+     */
+    Collection getCapabilities();
+
+    /**
+     * Parse the URI into a FileName.
+     * @param root The base FileName.
+     * @param uri The file to be accessed.
+     * @return A FileName representing the target file.
+     * @throws FileSystemException if an error occurs.
+     */
+    FileName parseUri(FileName root, String uri) throws FileSystemException;
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileReplicator.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileReplicator.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileReplicator.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileReplicator.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSelector;
+import org.apache.commons.vfs.FileSystemException;
+
+import java.io.File;
+
+/**
+ * Responsible for making local replicas of files.
+ * <p/>
+ * <p>A file replicator may also implement {@link VfsComponent}.
+ *
+ * @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 interface FileReplicator
+{
+    /**
+     * Creates a local copy of the file, and all its descendents.
+     *
+     * @param srcFile  The file to copy.
+     * @param selector Selects the files to copy.
+     * @return The local copy of the source file.
+     * @throws FileSystemException If the source files does not exist, or on error copying.
+     */
+    File replicateFile(FileObject srcFile, FileSelector selector)
+        throws FileSystemException;
+}

Added: synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java
URL: http://svn.apache.org/viewvc/synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java?rev=1000332&view=auto
==============================================================================
--- synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java (added)
+++ synapse/branches/commons-vfs-2-synapse-2.0/core/src/main/java/org/apache/commons/vfs/provider/FileSystemKey.java Thu Sep 23 06:04:21 2010
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.apache.commons.vfs.FileSystemOptions;
+
+/**
+ * Used to identify a filesystem
+ *
+ * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
+ * @version $Revision: 804548 $ $Date: 2009-08-16 07:42:32 +0530 (Sun, 16 Aug 2009) $
+ */
+class FileSystemKey implements Comparable
+{
+    private static final FileSystemOptions EMPTY_OPTIONS = new FileSystemOptions();
+
+    private final Comparable key;
+    private final FileSystemOptions fileSystemOptions;
+
+    FileSystemKey(final Comparable key, final FileSystemOptions fileSystemOptions)
+    {
+        this.key = key;
+        if (fileSystemOptions != null)
+        {
+            this.fileSystemOptions = fileSystemOptions;
+        }
+        else
+        {
+            this.fileSystemOptions = EMPTY_OPTIONS;
+        }
+    }
+
+    public int compareTo(Object o)
+    {
+        FileSystemKey fk = (FileSystemKey) o;
+
+        int ret = key.compareTo(fk.key);
+        if (ret != 0)
+        {
+            // other filesystem
+            return ret;
+        }
+
+        return fileSystemOptions.compareTo(fk.fileSystemOptions);
+    }
+}