private synchronized ClassLoader generateClassLoader() { if (scriptLoader != null) { return scriptLoader; } if (cpDelegate == null) { scriptLoader = getClass().getClassLoader(); return scriptLoader; } scriptLoader = cpDelegate.getClassLoader(); return scriptLoader; }
/** * create a classloader for this definition * @return the classloader from the cpDelegate */ protected ClassLoader createLoader() { if (getAntlibClassLoader() != null && cpDelegate == null) { return getAntlibClassLoader(); } if (createdLoader == null) { createdLoader = getDelegate().getClassLoader(); // need to load Task via system classloader or the new // task we want to define will never be a Task but always // be wrapped into a TaskAdapter. ((AntClassLoader) createdLoader) .addSystemPackageRoot("org.apache.tools.ant"); } return createdLoader; }
/** * Use the reference to locate the loader. If the loader is not * found, the specified classpath will be used and registered * with the specified name. * * This allows multiple taskdef/typedef to use the same class loader, * so they can be used together, eliminating the need to * put them in the CLASSPATH. * * @param r the reference to locate the loader. * @since Ant 1.5 */ public void setLoaderRef(Reference r) { getDelegate().setLoaderRef(r); }
/** * Set a reference to a classpath to use when loading the files. * To actually share the same loader, set loaderref as well * @param r the reference to the classpath */ public void setClasspathRef(Reference r) { getDelegate().setClasspathref(r); }
/** * Helper method obtaining a fresh instance of the class specified * in the @classname and using the specified classpath. * * @return the fresh instantiated object. */ public Object newInstance() { return ClasspathUtils.newInstance(this.className, getClassLoader()); }
/** * Classpath to be used when searching for classes and resources. * * @return an empty Path instance to be configured by Ant. */ public Path createClasspath() { return getClassPathDelegate().createClasspath(); }
/** * Create the classpath to be used when searching for component being * defined. * @return the classpath of the this definition */ public Path createClasspath() { return getDelegate().createClasspath(); }
/** * Returns the class path id of the class path delegate. * @return the class path id */ public String getClasspathId() { return getDelegate().getClassLoadId(); }
/** * Returns the loader id of the class path Delegate. * @return the loader id */ public String getLoaderId() { return getDelegate().getClassLoadId(); }
/** * Set the classpath by reference. * * @param r a Reference to a Path instance to be used as the classpath * value. */ public void setClasspathRef(Reference r) { getClassPathDelegate().setClasspathref(r); }
/** * Set the classpath to be used when searching for classes and resources. * * @param classpath an Ant Path object containing the search path. */ public void setClasspath(Path classpath) { getClassPathDelegate().setClasspath(classpath); }
/** * @return the classpath for this definition */ public Path getClasspath() { return getDelegate().getClasspath(); }
/** * Set the classpath to be used when searching for component being defined. * * @param classpath an Ant Path object containing the classpath. */ public void setClasspath(Path classpath) { getDelegate().setClasspath(classpath); }
/** * @return the reverse loader attribute of the classpath delegate. */ public boolean isReverseLoader() { return getDelegate().isReverseLoader(); }
/** * Delegate method handling the @classpathref attribute. * * <p>This attribute can add a referenced path-like structure to the * classpath.</p> * * @param r the reference to the classpath. */ public void setClasspathref(Reference r) { this.classpathId = r.getRefId(); createClasspath().setRefid(r); }
/** * Obtains a delegate that helps out with classic classpath configuration. * * @param component your projectComponent that needs the assistance * @return the helper, delegate. * @see ClasspathUtils.Delegate */ public static Delegate getDelegate(ProjectComponent component) { return new Delegate(component); }
/** * Finds or creates the classloader for this object. * @return The class loader. */ public ClassLoader getClassLoader() { return getClassLoaderForPath(getContextProject(), classpath, getClassLoadId(), reverseLoader, loaderId != null || isMagicPropertySet(getContextProject())); }