1 22 package org.jboss.deployers.plugins.structure.vfs; 23 24 import java.io.IOException ; 25 26 import org.jboss.deployers.spi.structure.vfs.ContextInfo; 27 import org.jboss.deployers.spi.structure.vfs.StructureMetaData; 28 import org.jboss.deployers.spi.structure.vfs.StructuredDeployers; 29 import org.jboss.logging.Logger; 30 import org.jboss.virtual.VirtualFile; 31 import org.jboss.virtual.VirtualFileFilter; 32 import org.jboss.virtual.VisitorAttributes; 33 import org.jboss.virtual.plugins.vfs.helpers.AbstractVirtualFileVisitor; 34 35 41 public class AbstractCandidateStructureVisitor extends AbstractVirtualFileVisitor 42 { 43 44 private static final Logger log = Logger.getLogger(AbstractCandidateStructureVisitor.class); 45 46 47 private final VirtualFile parent; 48 49 50 private final StructureMetaData metaData; 51 private final StructuredDeployers deployers; 52 53 54 private boolean ignoreDirectories; 55 56 57 private VirtualFileFilter filter; 58 59 65 public AbstractCandidateStructureVisitor(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers) 66 { 67 this(parent, metaData, deployers, null); 68 } 69 70 77 public AbstractCandidateStructureVisitor(VirtualFile parent, StructureMetaData metaData, StructuredDeployers deployers, VisitorAttributes attributes) 78 { 79 super(attributes); 80 if (parent == null) 81 throw new IllegalArgumentException ("Null parent"); 82 this.parent = parent; 83 this.metaData = metaData; 84 this.deployers = deployers; 85 } 86 87 92 public VirtualFile getParent() 93 { 94 return parent; 95 } 96 97 102 public boolean isIgnoreDirectories() 103 { 104 return ignoreDirectories; 105 } 106 107 112 public VirtualFileFilter getFilter() 113 { 114 return filter; 115 } 116 117 122 public void setFilter(VirtualFileFilter filter) 123 { 124 this.filter = filter; 125 } 126 127 132 public void setIgnoreDirectories(boolean ignoreDirectories) 133 { 134 this.ignoreDirectories = ignoreDirectories; 135 } 136 137 public void visit(VirtualFile file) 138 { 139 ContextInfo context = metaData.getContext(file.getPathName()); 140 if (context == null) 141 { 142 try 144 { 145 if (ignoreDirectories && file.isLeaf() == false) 146 return; 147 } 148 catch (IOException e) 149 { 150 log.debug("Ignoring " + file + " reason=" + e); 151 return; 152 } 153 154 if (filter != null && filter.accepts(file) == false) 156 return; 157 158 try 159 { 160 deployers.determineStructure(file, metaData); 162 } 163 catch (Exception e) 164 { 165 log.debug("Ignoring " + file + " reason=" + e); 166 return; 167 } 168 } 169 } 170 } 171 | Popular Tags |