1 16 package org.apache.commons.vfs.provider; 17 18 import org.apache.commons.vfs.FileSystemException; 19 20 import java.util.ArrayList ; 21 22 27 public abstract class AbstractVfsContainer 28 extends AbstractVfsComponent 29 { 30 33 private final ArrayList components = new ArrayList (); 34 35 40 protected void addComponent(final Object component) 41 throws FileSystemException 42 { 43 if (!components.contains(component)) 44 { 45 if (component instanceof VfsComponent) 47 { 48 VfsComponent vfsComponent = (VfsComponent) component; 49 vfsComponent.setLogger(getLogger()); 50 vfsComponent.setContext(getContext()); 51 vfsComponent.init(); 52 } 53 54 components.add(component); 56 } 57 } 58 59 62 protected void removeComponent(final Object component) 63 { 64 components.remove(component); 65 } 66 67 70 public void close() 71 { 72 final int count = components.size(); 74 for (int i = 0; i < count; i++) 75 { 76 final Object component = components.get(i); 77 if (component instanceof VfsComponent) 78 { 79 final VfsComponent vfsComponent = (VfsComponent) component; 80 vfsComponent.close(); 81 } 82 } 83 components.clear(); 84 } 85 } 86 | Popular Tags |