/** * Factory method * * @param parent ClassLoader * @param project Project * @param path Path * @param parentFirst boolean * @return AntClassLoader */ public static AntClassLoader newAntClassLoader(final ClassLoader parent, final Project project, final Path path, final boolean parentFirst) { return new AntClassLoader(parent, project, path, parentFirst); }
public void execute() throws BuildException { if (taskClasspath==null || taskClasspath.size()==0) { throw new BuildException("no classpath given"); } Project project = getProject(); AntClassLoader loader = new AntClassLoader(makeRoot(),true); project.addReference(name,loader); }
private ResourceLoader setupResourceLoader() { if (classpath == null) { classpath = new Path(project); } /* * 'basedir' is added to the path to make sure that relative paths such * as "<ruleset>resources/custom_ruleset.xml</ruleset>" still work when * ant is invoked from a different directory using "-f" */ classpath.add(new Path(null, project.getBaseDir().toString())); project.log("Using the AntClassLoader: " + classpath, Project.MSG_VERBOSE); // must be true, otherwise you'll get ClassCastExceptions as classes // are loaded twice // and exist in multiple class loaders final boolean parentFirst = true; return new ResourceLoader(new AntClassLoader(Thread.currentThread().getContextClassLoader(), project, classpath, parentFirst)); }
return getIncludeantruntime() ? getClass().getClassLoader() : new AntClassLoader(new RootLoader(EMPTY_URL_ARRAY, null), getProject(), getClasspath());
final ClassLoader loader = new AntClassLoader(getProject(), classpath);
public Object run() { try { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); AntClassLoader newClassLoader = new AntClassLoader(getClass().getClassLoader(), true); // we're changing the thread classloader so that we can access resources // from the classpath used to load this task's class Thread.currentThread().setContextClassLoader(newClassLoader); return contextClassLoader; } catch (SecurityException ex) { throw new BuildException("Could not change the context clas loader", ex); } } });
private void doXJC() throws BuildException { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { // set the user-specified class loader so that XJC will use it. Thread.currentThread().setContextClassLoader(new AntClassLoader(getProject(),classpath)); _doXJC(); } finally { // restore the context class loader Thread.currentThread().setContextClassLoader(old); } }
private void setContextClassLoader() { if(classpath == null) { String cp = ((AntClassLoader) getClass().getClassLoader()).getClasspath(); classpath = new Path(getProject(),cp); } AntClassLoader classloader = new AntClassLoader(getProject(),classpath,true); Thread.currentThread().setContextClassLoader(classloader); }
/** * Return the classloader to use. */ protected ClassLoader getClassLoader() { if (_cl != null) return _cl; if (classpath != null) _cl = new AntClassLoader(project, classpath, useParent); else _cl = new AntClassLoader(project.getCoreLoader(), project, new Path(project), useParent); _cl.setIsolated(isolate); return _cl; }
public void execute() throws BuildException { try { Map commandLineOptions = this.fillOptionMap(); ClassLoader conextClassLoader = Thread.currentThread().getContextClassLoader(); AntClassLoader cl = new AntClassLoader(getClass().getClassLoader(), getProject(), classpath == null ? createClasspath() : classpath, false); commandLineOptions.put(Java2WSDLConstants.CLASSPATH_OPTION, new Java2WSDLCommandLineOption(Java2WSDLConstants.CLASSPATH_OPTION, classpath.list())); Thread.currentThread().setContextClassLoader(cl); new Java2WSDLCodegenEngine(commandLineOptions).generate(); Thread.currentThread().setContextClassLoader(conextClassLoader); } catch (Throwable e) { throw new BuildException(e); } }
public void execute() throws BuildException { if (taskClasspath==null || taskClasspath.size()==0) { throw new BuildException("no classpath given"); } Project project = getProject(); AntClassLoader loader = new AntClassLoader(makeRoot(),true); project.addReference(name,loader); }
public void execute() throws BuildException { if (taskClasspath==null || taskClasspath.size()==0) { throw new BuildException("no classpath given"); } Project project = getProject(); AntClassLoader loader = new AntClassLoader(makeRoot(),true); project.addReference(name,loader); }
public void execute() throws BuildException { if (taskClasspath==null || taskClasspath.size()==0) { throw new BuildException("no classpath given"); } Project project = getProject(); AntClassLoader loader = new AntClassLoader(makeRoot(),true); project.addReference(name,loader); }
public void execute() throws BuildException { if (taskClasspath==null || taskClasspath.size()==0) { throw new BuildException("no classpath given"); } Project project = getProject(); AntClassLoader loader = new AntClassLoader(makeRoot(),true); project.addReference(name,loader); }
@Override public ClassLoader run() { return getIncludeantruntime() ? getClass().getClassLoader() : new AntClassLoader(new RootLoader(EMPTY_URL_ARRAY, null), getProject(), getClasspath()); } });
public void execute() throws BuildException { if (taskClasspath==null || taskClasspath.size()==0) { throw new BuildException("no classpath given"); } Project project = getProject(); AntClassLoader loader = new AntClassLoader(makeRoot(),true); project.addReference(name,loader); }
/** * Return the classloader to use. */ protected ClassLoader getClassLoader() { if (_cl != null) return _cl; if (classpath != null) _cl = new AntClassLoader(getProject(), classpath, useParent); else _cl = new AntClassLoader(getProject().getCoreLoader(), getProject(), new Path(getProject()), useParent); _cl.setIsolated(isolate); return _cl; }
/** * Return the classloader to use. */ protected ClassLoader getClassLoader() { if (_cl != null) return _cl; if (classpath != null) _cl = new AntClassLoader(getProject(), classpath, useParent); else _cl = new AntClassLoader(getProject().getCoreLoader(), getProject(), new Path(getProject()), useParent); _cl.setIsolated(isolate); return _cl; }
/** * Return the classloader to use. */ protected ClassLoader getClassLoader() { if (_cl != null) return _cl; if (classpath != null) _cl = new AntClassLoader(getProject(), classpath, useParent); else _cl = new AntClassLoader(getProject().getCoreLoader(), getProject(), new Path(getProject()), useParent); _cl.setIsolated(isolate); return _cl; }
@Override protected void setUp() throws Exception { super.setUp(); URL jar1 = getClass().getClassLoader().getResource("remoting-test-client.jar"); URL jar2 = getClass().getClassLoader().getResource("remoting-test-client-tests.jar"); cl = new AntClassLoader(this.getClass().getClassLoader(),true); cl.addPathComponent(toFile(jar1)); cl.addPathComponent(toFile(jar2)); dir = File.createTempFile("remoting", "cache"); dir.delete(); dir.mkdirs(); channel.setJarCache(new FileSystemJarCache(dir, true)); channel.call(new JarCacherCallable()); sum1 = channel.jarLoader.calcChecksum(jar1); sum2 = channel.jarLoader.calcChecksum(jar2); }