本文整理汇总了Java中org.codehaus.groovy.runtime.InvokerHelper.removeClass方法的典型用法代码示例。如果您正苦于以下问题:Java InvokerHelper.removeClass方法的具体用法?Java InvokerHelper.removeClass怎么用?Java InvokerHelper.removeClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.runtime.InvokerHelper
的用法示例。
在下文中一共展示了InvokerHelper.removeClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearCache
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
/**
* Removes all classes from the class cache.
* <p>
* In addition to internal caches this method also clears any
* previously set MetaClass information for the given set of
* classes being removed.
*
* @see #getClassCacheEntry(String)
* @see #setClassCacheEntry(Class)
* @see #removeClassCacheEntry(String)
*/
public void clearCache() {
Map<String, Class> clearedClasses = classCache.clear();
sourceCache.clear();
for (Map.Entry<String, Class> entry : clearedClasses.entrySet()) {
// Another Thread may be using an instance of this class
// (for the first time) requiring a ClassInfo lock and
// classloading which would require a lock on classCache.
// The following locks on ClassInfo and to avoid deadlock
// should not be done with a classCache lock.
InvokerHelper.removeClass(entry.getValue());
}
}
示例2: evaluate
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
/**
* Evaluates some script against the current Binding and returns the result
*
* @param in the stream reading the script
* @param fileName is the logical file name of the script (which is used to create the class name of the script)
*/
public Object evaluate(Reader in, String fileName) throws CompilationFailedException {
Script script = null;
try {
script = parse(in, fileName);
return script.run();
} finally {
if (script != null) {
InvokerHelper.removeClass(script.getClass());
}
}
}
示例3: evaluate
import org.codehaus.groovy.runtime.InvokerHelper; //导入方法依赖的package包/类
private Object evaluate(InputStream in, String fileName, Writer out, MgnlGroovyConsole console) throws CompilationFailedException {
Script script = null;
try {
script = createScript(in, out, console);
script.setProperty("ctx", MgnlContext.getInstance());
return script.run();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (script != null) {
InvokerHelper.removeClass(script.getClass());
}
}
}