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; }
/** * 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()); }