本文整理了Java中org.apache.tools.ant.Project.createClassLoader()
方法的一些代码示例,展示了Project.createClassLoader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.createClassLoader()
方法的具体详情如下:
包路径:org.apache.tools.ant.Project
类名称:Project
方法名:createClassLoader
[英]Factory method to create a class loader for loading classes from a given path.
[中]方法创建一个类加载器,用于从给定路径加载类。
代码示例来源:origin: org.apache.ant/ant
/**
* Returns and initializes the classloader for this class.
* @return the classloader
*/
public ClassLoader getClassLoader() {
if (myClassLoader == null) {
myClassLoader = (classpath == null)
// the usual classloader
? getClass().getClassLoader()
// additional use the provided classpath
// Memory leak in line below
: getProject().createClassLoader(classpath);
}
return myClassLoader;
}
代码示例来源:origin: org.apache.ant/ant
/**
* Gets the Class object associated with the mapper implementation.
* @return <code>Class</code>.
* @throws ClassNotFoundException if the class cannot be found
*/
protected Class<? extends FileNameMapper> getImplementationClass() throws ClassNotFoundException {
String cName = this.classname;
if (type != null) {
cName = type.getImplementation();
}
ClassLoader loader = (classpath == null)
? getClass().getClassLoader()
// Memory leak in line below
: getProject().createClassLoader(classpath);
return Class.forName(cName, true, loader).asSubclass(FileNameMapper.class);
}
代码示例来源:origin: org.apache.ant/ant
/**
* If a custom classpath has been defined but no loader created
* yet, create the classloader and set it as the context
* classloader.
*/
private void setupLoader() {
if (classpath != null && loader == null) {
loader = getProject().createClassLoader(classpath);
loader.setThreadContextLoader();
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Returns a Classloader object which parses the passed in generic EjbJar classpath.
* The loader is used to dynamically load classes from javax.ejb.* and the classes
* being added to the jar.
* @return a classloader.
*/
protected ClassLoader getClassLoaderForBuild() {
if (classpathLoader != null) {
return classpathLoader;
}
Path combinedClasspath = getCombinedClasspath();
// only generate a new ClassLoader if we have a classpath
if (combinedClasspath == null) {
classpathLoader = getClass().getClassLoader();
} else {
// Memory leak in line below
classpathLoader
= getTask().getProject().createClassLoader(combinedClasspath);
}
return classpathLoader;
}
代码示例来源:origin: org.apache.ant/ant
/**
* Gets a fresh, different, previously unused classloader that uses the
* passed path as its classpath.
*
* <p>This method completely ignores the ant.reuse.loader magic
* property and should be used with caution.</p>
* @param p Ant Project where the handled components are living in.
* @param path the classpath for this loader
* @param reverseLoader if set to true this new loader will take
* precedence over its parent (which is contra the regular
* classloader behaviour)
* @return The fresh, different, previously unused class loader.
*/
public static ClassLoader getUniqueClassLoaderForPath(Project p, Path path,
boolean reverseLoader) {
AntClassLoader acl = p.createClassLoader(path);
if (reverseLoader) {
acl.setParentFirst(false);
acl.addJavaLibraries();
}
return acl;
}
代码示例来源:origin: org.apache.ant/ant
/**
* Based on the parameter passed in, this method creates the necessary
* factory desired.
*
* The current mapping for compiler names are as follows:
* <ul><li>jasper = jasper compiler (the default)
* <li><i>a fully qualified classname</i> = the name of a jsp compiler
* adapter
* </ul>
*
* @param compilerType either the name of the desired compiler, or the
* full classname of the compiler's adapter.
* @param task a task to log through.
* @return the compiler
* @throws BuildException if the compiler type could not be resolved into
* a compiler adapter.
*/
public static JspCompilerAdapter getCompiler(String compilerType, Task task)
throws BuildException {
return getCompiler(compilerType, task,
// Memory-Leak in line below
task.getProject().createClassLoader(null));
}
代码示例来源:origin: org.apache.ant/ant
/**
* @since Ant 1.6.2
*/
private boolean isTomcat5x() {
try (AntClassLoader l = getProject().createClassLoader(getClasspath())) {
l.loadClass("org.apache.jasper.tagplugins.jstl.If");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}
代码示例来源:origin: org.apache.ant/ant
readerLoader = getProject().createClassLoader(classpath);
readerClass = Class.forName(readerClassName, true,
readerLoader);
代码示例来源:origin: org.apache.ant/ant
try {
if (ignoreSystemClasses) {
loader = getProject().createClassLoader(classpath);
loader.setParentFirst(false);
loader.addJavaLibraries();
代码示例来源:origin: org.apache.ant/ant
= getProject().createClassLoader(classpath);
c = Class.forName(classname, true, al);
代码示例来源:origin: org.apache.ant/ant
if (classpath != null) {
cleanup = true;
cL = getProject().createClassLoader(classpath);
} else {
cL = this.getClass().getClassLoader();
代码示例来源:origin: org.apache.ant/ant
try {
if (ignoreSystemclasses) {
loader = getProject().createClassLoader(classpath);
loader.setParentFirst(false);
loader.addJavaLibraries();
代码示例来源:origin: org.apache.ant/ant
.createClassLoader(classpath));
代码示例来源:origin: org.apache.ant/ant
.createClassLoader(classpath));
代码示例来源:origin: org.apache.ant/ant
/**
* Utility method to lookup a ResourceLocation in the classpath.
*
* @return An InputSource for reading the resource, or <code>null</code>
* if the resource does not exist in the classpath or is not readable.
*/
private InputSource classpathLookup(ResourceLocation matchingEntry) {
InputSource source = null;
Path cp = classpath;
if (cp != null) {
cp = classpath.concatSystemClasspath("ignore");
} else {
cp = (new Path(getProject())).concatSystemClasspath("last");
}
AntClassLoader loader = getProject().createClassLoader(cp);
//
// for classpath lookup we ignore the base directory
//
InputStream is
= loader.getResourceAsStream(matchingEntry.getLocation());
if (is != null) {
source = new InputSource(is);
URL entryURL = loader.getResource(matchingEntry.getLocation());
String sysid = entryURL.toExternalForm();
source.setSystemId(sysid);
log("catalog entry matched a resource in the classpath: '"
+ sysid + "'", Project.MSG_DEBUG);
}
return source;
}
代码示例来源:origin: org.apache.ant/ant
} else {
loader
= getRmic().getProject().createClassLoader(getRmic().getClasspath());
c = Class.forName(WLRMIC_CLASSNAME, true, loader);
代码示例来源:origin: org.apache.ant/ant
/**
* Helper method invoked by isRebuildRequired to get a ClassLoader for a
* Jar File passed to it.
*
* @param classjar java.io.File representing jar file to get classes from.
* @return the classloader for the jarfile.
* @throws IOException if there is a problem.
*/
protected ClassLoader getClassLoaderFromJar(File classjar) throws IOException {
Path lookupPath = new Path(getTask().getProject());
lookupPath.setLocation(classjar);
Path classpath = getCombinedClasspath();
if (classpath != null) {
lookupPath.append(classpath);
}
return getTask().getProject().createClassLoader(lookupPath);
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Helper method invoked by isRebuildRequired to get a ClassLoader for a
* Jar File passed to it.
*
* @param classjar java.io.File representing jar file to get classes from.
* @return a classloader for the jar file.
* @throws IOException if there is an error.
*/
protected ClassLoader getClassLoaderFromJar(File classjar) throws IOException {
Path lookupPath = new Path(getTask().getProject());
lookupPath.setLocation(classjar);
Path classpath = getCombinedClasspath();
if (classpath != null) {
lookupPath.append(classpath);
}
return getTask().getProject().createClassLoader(lookupPath);
}
}
代码示例来源:origin: org.apache.ant/ant
Path p = getClasspath().concatSystemClasspath("ignore");
if (parentFirst) {
cl = getProject().createClassLoader(p);
} else {
cl = AntClassLoader.newAntClassLoader(getProject()
代码示例来源:origin: org.apache.ant/ant
+ classpath.toString(), Project.MSG_VERBOSE);
try (AntClassLoader cl = classpath.getProject().createClassLoader(classpath)) {
内容来源于网络,如有侵权,请联系作者删除!