本文整理了Java中groovy.lang.GroovyClassLoader.close()
方法的一些代码示例,展示了GroovyClassLoader.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GroovyClassLoader.close()
方法的具体详情如下:
包路径:groovy.lang.GroovyClassLoader
类名称:GroovyClassLoader
方法名:close
[英]Closes this GroovyClassLoader and clears any caches it maintains.
No use should be made of this instance after this method is invoked. Any classes that are already loaded are still accessible.
[中]关闭此GroovyClassLoader并清除它维护的所有缓存。
调用此方法后,不应使用此实例。任何已经加载的类仍然可以访问。
代码示例来源:origin: apache/ofbiz-framework
public static Class<?> loadClass(String path) throws ClassNotFoundException, IOException {
GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
Class<?> classLoader = groovyClassLoader.loadClass(path);
groovyClassLoader.close();
return classLoader;
}
代码示例来源:origin: apache/ofbiz-framework
public static Class<?> parseClass(String text) throws IOException {
GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
Class<?> classLoader = groovyClassLoader.parseClass(text);
groovyClassLoader.close();
return classLoader;
}
代码示例来源:origin: dkpro/dkpro-tc
Object[] a = {};
groovyObject.invokeMethod("run", a);
loader.close();
代码示例来源:origin: org.dkpro.tc/dkpro-tc-core
/**
* Method which executes Groovy script provided in the pathToScript.
*
* @param pathToScript
* path to Groovy script.
*
* @throws InstantiationException
* if class cannot be instantiated
*
* @throws IllegalAccessException
* if an illegal access occurred
*
* @throws IOException
* general IO Exceptions
*/
public static void start(String pathToScript)
throws InstantiationException, IllegalAccessException, IOException
{
ClassLoader parent = ExperimentStarter.class.getClassLoader();
GroovyClassLoader loader = new GroovyClassLoader(parent);
StringWriter writer = new StringWriter();
IOUtils.copy(parent.getResourceAsStream(pathToScript), writer, "UTF-8");
Class<?> groovyClass = loader.parseClass(writer.toString());
GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance();
Object[] a = {};
groovyObject.invokeMethod("run", a);
loader.close();
}
}
代码示例来源:origin: stackoverflow.com
import groovy.lang.GroovyClassLoader ;
import groovy.lang.GroovyObject ;
public class Test {
public static void main( String[] args ) throws Exception {
GroovyClassLoader loader = new GroovyClassLoader() ;
GroovyObject o = (GroovyObject)loader.loadClass( "File1" ).newInstance() ;
o.invokeMethod( "run", new Object[] {} ) ;
loader.close() ;
}
}
代码示例来源:origin: apache/ofbiz-framework
public static Class<?> parseClass(InputStream in, String location) throws IOException {
GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
Class<?> classLoader = groovyClassLoader.parseClass(UtilIO.readString(in), location);
groovyClassLoader.close();
return classLoader;
}
public static Class<?> parseClass(InputStream in, String location, GroovyClassLoader groovyClassLoader) throws IOException {
代码示例来源:origin: kiselev-dv/gazetteer
gcl.close();
代码示例来源:origin: io.teknek/nit-compiler
@Override
public Object createInstance(NitDesc nitDesc) throws NitException {
GroovyClassLoader gc = new GroovyClassLoader();
try {
Class<?> cl = gc.parseClass(nitDesc.getScript());
return NitFactory.findMatchingConstructor(nitDesc, cl);
} finally {
try {
gc.close();
} catch (IOException e) { }
}
}
代码示例来源:origin: kiselev-dv/gazetteer
gcl.close();
内容来源于网络,如有侵权,请联系作者删除!