| 1 | |
package org.webslinger.commons.vfs.virtual; |
| 2 | |
|
| 3 | |
import java.util.Collection; |
| 4 | |
|
| 5 | |
import org.apache.commons.vfs.FileName; |
| 6 | |
import org.apache.commons.vfs.FileObject; |
| 7 | |
import org.apache.commons.vfs.FileSystemException; |
| 8 | |
|
| 9 | |
import org.webslinger.commons.vfs.handlers.HandlerFactory; |
| 10 | |
import org.webslinger.commons.vfs.handlers.cow.COWStorageHandler; |
| 11 | |
import org.webslinger.commons.vfs.handlers.cow.COWStateXmlStorageHandler; |
| 12 | |
|
| 13 | 53 | public class VirtualCOWStateXmlStorageHandlerFactory implements HandlerFactory<COWStorageHandler, VirtualFileSystem> { |
| 14 | |
protected final String stateName; |
| 15 | |
|
| 16 | |
public VirtualCOWStateXmlStorageHandlerFactory() { |
| 17 | 32 | this(".cowstate.xml"); |
| 18 | 32 | } |
| 19 | |
|
| 20 | 32 | public VirtualCOWStateXmlStorageHandlerFactory(String stateName) { |
| 21 | 32 | this.stateName = stateName; |
| 22 | 32 | } |
| 23 | |
|
| 24 | |
public COWStorageHandler getHandler(final VirtualFileSystem fs, Class<COWStorageHandler> handlerClass) throws FileSystemException { |
| 25 | 53 | return new COWStateXmlStorageHandler() { |
| 26 | |
public FileObject getFile(FileName dir) throws FileSystemException { |
| 27 | 82839 | return fs.findMounted(dir, stateName); |
| 28 | |
} |
| 29 | |
|
| 30 | |
public void excludeNames(Collection<String> names) { |
| 31 | 67113 | names.remove(stateName); |
| 32 | 67113 | } |
| 33 | |
}; |
| 34 | |
} |
| 35 | |
} |