1 18 19 package org.apache.tools.ant.taskdefs; 20 21 import org.apache.tools.ant.AntClassLoader; 22 import org.apache.tools.ant.BuildException; 23 import org.apache.tools.ant.Project; 24 import org.apache.tools.ant.types.Path; 25 import org.apache.tools.ant.types.Reference; 26 import org.apache.tools.ant.util.ClasspathUtils; 27 28 34 public abstract class DefBase extends AntlibDefinition { 35 private ClassLoader createdLoader; 36 private ClasspathUtils.Delegate cpDelegate; 37 38 43 protected boolean hasCpDelegate() { 44 return cpDelegate != null; 45 } 46 47 54 public void setReverseLoader(boolean reverseLoader) { 55 getDelegate().setReverseLoader(reverseLoader); 56 log("The reverseloader attribute is DEPRECATED. It will be removed", 57 Project.MSG_WARN); 58 } 59 60 63 public Path getClasspath() { 64 return getDelegate().getClasspath(); 65 } 66 67 70 public boolean isReverseLoader() { 71 return getDelegate().isReverseLoader(); 72 } 73 74 78 public String getLoaderId() { 79 return getDelegate().getClassLoadId(); 80 } 81 82 86 public String getClasspathId() { 87 return getDelegate().getClassLoadId(); 88 } 89 90 95 public void setClasspath(Path classpath) { 96 getDelegate().setClasspath(classpath); 97 } 98 99 104 public Path createClasspath() { 105 return getDelegate().createClasspath(); 106 } 107 108 113 public void setClasspathRef(Reference r) { 114 getDelegate().setClasspathref(r); 115 } 116 117 129 public void setLoaderRef(Reference r) { 130 getDelegate().setLoaderRef(r); 131 } 132 133 137 protected ClassLoader createLoader() { 138 if (getAntlibClassLoader() != null && cpDelegate == null) { 139 return getAntlibClassLoader(); 140 } 141 if (createdLoader == null) { 142 createdLoader = getDelegate().getClassLoader(); 143 ((AntClassLoader) createdLoader) 147 .addSystemPackageRoot("org.apache.tools.ant"); 148 } 149 return createdLoader; 150 } 151 152 157 public void init() throws BuildException { 158 super.init(); 159 } 160 161 private ClasspathUtils.Delegate getDelegate() { 162 if (cpDelegate == null) { 163 cpDelegate = ClasspathUtils.getDelegate(this); 164 } 165 return cpDelegate; 166 } 167 } 168 | Popular Tags |