1 20 package org.apache.cactus.integration.maven; 21 22 import java.lang.reflect.InvocationTargetException ; 23 24 import org.apache.commons.jelly.JellyTagException; 25 import org.apache.commons.jelly.TagSupport; 26 import org.apache.commons.jelly.XMLOutput; 27 import org.apache.commons.jelly.MissingAttributeException; 28 import org.apache.commons.jelly.tags.ant.TaskSource; 29 import org.apache.commons.jelly.tags.ant.AntTagLibrary; 30 import org.apache.commons.beanutils.BeanUtils; 31 import org.apache.commons.logging.Log; 32 import org.apache.commons.logging.LogFactory; 33 import org.apache.tools.ant.types.FileSet; 34 import org.apache.tools.ant.types.Path; 35 import org.apache.tools.ant.types.Reference; 36 37 49 public class CactusScannerTag extends TagSupport implements TaskSource 50 { 51 54 private Log log = LogFactory.getLog(CactusScannerTag.class); 55 56 60 private CactusScanner cactusScanner; 61 62 68 private FileSet fileset; 69 70 78 private Path classpath; 79 80 84 private String classpathref; 85 86 90 private String var; 91 92 95 public CactusScannerTag() 96 { 97 this.cactusScanner = new CactusScanner(); 98 } 99 100 103 public void doTag(XMLOutput theXmlOutput) throws JellyTagException 104 { 105 this.cactusScanner.setProject(AntTagLibrary.getProject(context)); 106 this.cactusScanner.clear(); 107 108 invokeBody(theXmlOutput); 110 111 Path cp = this.classpath; 117 if (this.classpathref != null) 118 { 119 cp = (Path) AntTagLibrary.getProject( 120 context).getReference(this.classpathref); 121 } 122 123 this.cactusScanner.processFileSet(this.fileset, cp); 124 125 if (var == null) 127 { 128 throw new MissingAttributeException("var"); 129 } 130 context.setVariable(var, cactusScanner); 131 } 132 133 139 public Object getTaskObject() 140 { 141 return this; 142 } 143 144 147 public void setTaskProperty(String theName, Object theValue) 148 throws JellyTagException 149 { 150 try 151 { 152 BeanUtils.setProperty(this, theName, theValue); 153 } 154 catch (IllegalAccessException anException) 155 { 156 throw new JellyTagException(anException); 157 } 158 catch (InvocationTargetException anException) 159 { 160 throw new JellyTagException(anException); 161 } 162 163 } 164 165 171 public void addFileset(FileSet theSet) 172 { 173 log.debug("Adding fileset [" + theSet + "]"); 174 this.fileset = theSet; 175 } 176 177 180 public Path createClasspath() 181 { 182 log.debug("Creating classpath"); 183 if (this.classpath == null) 184 { 185 this.classpath = new Path(AntTagLibrary.getProject(context)); 186 } 187 return this.classpath.createPath(); 188 } 189 190 193 public Path getClasspath() 194 { 195 return this.classpath; 196 } 197 198 202 public void setClasspath(Path theClasspath) 203 { 204 log.debug("Setting classpath [" + theClasspath + "]"); 205 if (this.classpath == null) 206 { 207 this.classpath = theClasspath; 208 } 209 else 210 { 211 this.classpath.append(theClasspath); 212 } 213 } 214 215 221 public void setClasspathRef(Reference theReference) 222 { 223 createClasspath().setRefid(theReference); 224 } 225 226 229 public CactusScanner getCactusScanner() 230 { 231 return this.cactusScanner; 232 } 233 234 239 public void setVar(String theVar) 240 { 241 this.var = theVar; 242 } 243 244 249 public void setClasspathref(String theClasspathref) 250 { 251 this.classpathref = theClasspathref; 252 } 253 } 254 | Popular Tags |