View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.vfs.impl;
    18
    19  import org.apache.commons.vfs.FileObject;
    20  import org.apache.commons.vfs.FileSystemException;
    21  import org.apache.commons.vfs.FileSelector;
    22  import org.apache.commons.vfs.FileContent;
    23  import org.apache.commons.vfs.FileType;
    24  import org.apache.commons.vfs.NameScope;
    25
    26  import java.util.List;
    27
    28  /***
    29   * This decorator synchronize all access to the FileObject
    30   *
    31   * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
    32   * @version $Revision: 485638 $ $Date: 2006-12-11 13:20:55 +0100 (Mo, 11 Dez 2006) $
    33   */
    34  public class SynchronizedFileObject extends DecoratedFileObject
    35  {
    36  	public SynchronizedFileObject(FileObject fileObject)
    37  	{
    38  		super(fileObject);
    39  	}
    40
    41  	public void close() throws FileSystemException
    42      {
    43          synchronized(this)
    44          {
    45  		    super.close();
    46          }
    47      }
    48
    49  	public void copyFrom(FileObject srcFile, FileSelector selector) throws FileSystemException
    50  	{
    51          synchronized(this)
    52          {
    53      		super.copyFrom(srcFile, selector);
    54          }
    55      }
    56
    57  	public void createFile() throws FileSystemException
    58  	{
    59          synchronized(this)
    60          {
    61      		super.createFile();
    62          }
    63      }
    64
    65  	public void createFolder() throws FileSystemException
    66  	{
    67          synchronized(this)
    68          {
    69      		super.createFolder();
    70          }
    71      }
    72
    73  	public boolean delete() throws FileSystemException
    74  	{
    75          synchronized(this)
    76          {
    77      		return super.delete();
    78          }
    79      }
    80
    81  	public int delete(FileSelector selector) throws FileSystemException
    82  	{
    83          synchronized(this)
    84          {
    85      		return super.delete(selector);
    86          }
    87      }
    88
    89  	public boolean exists() throws FileSystemException
    90  	{
    91          synchronized(this)
    92          {
    93      		return super.exists();
    94          }
    95      }
    96
    97  	public void findFiles(FileSelector selector, boolean depthwise, List selected) throws FileSystemException
    98  	{
    99          synchronized(this)
    100         {
    101     		super.findFiles(selector, depthwise, selected);
    102         }
    103     }
    104
    105 	public FileObject[] findFiles(FileSelector selector) throws FileSystemException
    106 	{
    107         synchronized(this)
    108         {
    109     		return super.findFiles(selector);
    110         }
    111     }
    112
    113 	public FileObject getChild(String name) throws FileSystemException
    114 	{
    115         synchronized(this)
    116         {
    117     		return super.getChild(name);
    118         }
    119     }
    120
    121 	public FileObject[] getChildren() throws FileSystemException
    122 	{
    123         synchronized(this)
    124         {
    125     		return super.getChildren();
    126         }
    127     }
    128
    129 	public FileContent getContent() throws FileSystemException
    130 	{
    131         synchronized(this)
    132         {
    133     		return super.getContent();
    134         }
    135     }
    136
    137 	public FileType getType() throws FileSystemException
    138 	{
    139         synchronized(this)
    140         {
    141     		return super.getType();
    142         }
    143     }
    144
    145 	public boolean isHidden() throws FileSystemException
    146 	{
    147         synchronized(this)
    148         {
    149     		return super.isHidden();
    150         }
    151     }
    152
    153 	public boolean isReadable() throws FileSystemException
    154 	{
    155         synchronized(this)
    156         {
    157     		return super.isReadable();
    158         }
    159     }
    160
    161 	public boolean isWriteable() throws FileSystemException
    162 	{
    163         synchronized(this)
    164         {
    165     		return super.isWriteable();
    166         }
    167     }
    168
    169 	public void moveTo(FileObject destFile) throws FileSystemException
    170 	{
    171         synchronized(this)
    172         {
    173     		super.moveTo(destFile);
    174         }
    175     }
    176
    177 	public FileObject resolveFile(String name, NameScope scope) throws FileSystemException
    178 	{
    179         synchronized(this)
    180         {
    181     		return super.resolveFile(name, scope);
    182         }
    183     }
    184
    185 	public FileObject resolveFile(String path) throws FileSystemException
    186 	{
    187         synchronized(this)
    188         {
    189     		return super.resolveFile(path);
    190         }
    191     }
    192 }