001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.commons.vfs.impl;
018:
019: import org.apache.commons.vfs.FileObject;
020: import org.apache.commons.vfs.FileSystemException;
021: import org.apache.commons.vfs.FileSelector;
022: import org.apache.commons.vfs.FileContent;
023: import org.apache.commons.vfs.FileType;
024: import org.apache.commons.vfs.NameScope;
025:
026: import java.util.List;
027:
028: /**
029: * This decorator synchronize all access to the FileObject
030: *
031: * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
032: * @version $Revision: 485638 $ $Date: 2006-12-11 04:20:55 -0800 (Mon, 11 Dec 2006) $
033: */
034: public class SynchronizedFileObject extends DecoratedFileObject {
035: public SynchronizedFileObject(FileObject fileObject) {
036: super (fileObject);
037: }
038:
039: public void close() throws FileSystemException {
040: synchronized (this ) {
041: super .close();
042: }
043: }
044:
045: public void copyFrom(FileObject srcFile, FileSelector selector)
046: throws FileSystemException {
047: synchronized (this ) {
048: super .copyFrom(srcFile, selector);
049: }
050: }
051:
052: public void createFile() throws FileSystemException {
053: synchronized (this ) {
054: super .createFile();
055: }
056: }
057:
058: public void createFolder() throws FileSystemException {
059: synchronized (this ) {
060: super .createFolder();
061: }
062: }
063:
064: public boolean delete() throws FileSystemException {
065: synchronized (this ) {
066: return super .delete();
067: }
068: }
069:
070: public int delete(FileSelector selector) throws FileSystemException {
071: synchronized (this ) {
072: return super .delete(selector);
073: }
074: }
075:
076: public boolean exists() throws FileSystemException {
077: synchronized (this ) {
078: return super .exists();
079: }
080: }
081:
082: public void findFiles(FileSelector selector, boolean depthwise,
083: List selected) throws FileSystemException {
084: synchronized (this ) {
085: super .findFiles(selector, depthwise, selected);
086: }
087: }
088:
089: public FileObject[] findFiles(FileSelector selector)
090: throws FileSystemException {
091: synchronized (this ) {
092: return super .findFiles(selector);
093: }
094: }
095:
096: public FileObject getChild(String name) throws FileSystemException {
097: synchronized (this ) {
098: return super .getChild(name);
099: }
100: }
101:
102: public FileObject[] getChildren() throws FileSystemException {
103: synchronized (this ) {
104: return super .getChildren();
105: }
106: }
107:
108: public FileContent getContent() throws FileSystemException {
109: synchronized (this ) {
110: return super .getContent();
111: }
112: }
113:
114: public FileType getType() throws FileSystemException {
115: synchronized (this ) {
116: return super .getType();
117: }
118: }
119:
120: public boolean isHidden() throws FileSystemException {
121: synchronized (this ) {
122: return super .isHidden();
123: }
124: }
125:
126: public boolean isReadable() throws FileSystemException {
127: synchronized (this ) {
128: return super .isReadable();
129: }
130: }
131:
132: public boolean isWriteable() throws FileSystemException {
133: synchronized (this ) {
134: return super .isWriteable();
135: }
136: }
137:
138: public void moveTo(FileObject destFile) throws FileSystemException {
139: synchronized (this ) {
140: super .moveTo(destFile);
141: }
142: }
143:
144: public FileObject resolveFile(String name, NameScope scope)
145: throws FileSystemException {
146: synchronized (this ) {
147: return super .resolveFile(name, scope);
148: }
149: }
150:
151: public FileObject resolveFile(String path)
152: throws FileSystemException {
153: synchronized (this) {
154: return super.resolveFile(path);
155: }
156: }
157: }
|