本文整理了Java中groovy.lang.GroovyClassLoader.<init>()
方法的一些代码示例,展示了GroovyClassLoader.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GroovyClassLoader.<init>()
方法的具体详情如下:
包路径:groovy.lang.GroovyClassLoader
类名称:GroovyClassLoader
方法名:<init>
[英]creates a GroovyClassLoader using the current Thread's context Class loader as parent.
[中]使用当前线程的上下文类加载器作为父级创建GroovyClassLoader。
代码示例来源:origin: spring-projects/spring-framework
/**
* Build a {@link GroovyClassLoader} for the given {@code ClassLoader}.
* @param classLoader the ClassLoader to build a GroovyClassLoader for
* @since 4.3.3
*/
protected GroovyClassLoader buildGroovyClassLoader(@Nullable ClassLoader classLoader) {
return (this.compilerConfiguration != null ?
new GroovyClassLoader(classLoader, this.compilerConfiguration) : new GroovyClassLoader(classLoader));
}
代码示例来源:origin: Netflix/zuul
/**
* @return a new GroovyClassLoader
*/
GroovyClassLoader getGroovyClassLoader() {
return new GroovyClassLoader();
}
代码示例来源:origin: org.springframework/spring-context
/**
* Build a {@link GroovyClassLoader} for the given {@code ClassLoader}.
* @param classLoader the ClassLoader to build a GroovyClassLoader for
* @since 4.3.3
*/
protected GroovyClassLoader buildGroovyClassLoader(@Nullable ClassLoader classLoader) {
return (this.compilerConfiguration != null ?
new GroovyClassLoader(classLoader, this.compilerConfiguration) : new GroovyClassLoader(classLoader));
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public GroovyClassLoader run() {
return new GroovyClassLoader();
}
}));
代码示例来源:origin: groovy/groovy-core
public GroovyClassLoader run() {
return new GroovyClassLoader(parentLoader);
}
});
代码示例来源:origin: groovy/groovy-core
public Object run() {
return new GroovyClassLoader(parentLoader);
}
}));
代码示例来源:origin: Netflix/zuul
/**
* @return a new GroovyClassLoader
*/
GroovyClassLoader getGroovyClassLoader() {
return new GroovyClassLoader();
}
代码示例来源:origin: Netflix/zuul
/**
* compiles the Groovy source code
*
* @param sFilterCode
* @return
* @throws org.codehaus.groovy.control.CompilationFailedException
*
*/
public Class compileGroovy(String sFilterCode) throws org.codehaus.groovy.control.CompilationFailedException {
GroovyClassLoader loader = new GroovyClassLoader();
return loader.parseClass(sFilterCode);
}
代码示例来源:origin: org.codehaus.groovy/groovy
public GroovyClassLoader run() {
ClassLoader parent = Thread.currentThread().getContextClassLoader();
if (parent == null) parent = ProcessingUnit.class.getClassLoader();
return loader == null ? new GroovyClassLoader(parent, configuration) : loader;
}
});
代码示例来源:origin: groovy/groovy-core
public Object run() {
return new GroovyClassLoader(parentLoader);
}
});
代码示例来源:origin: groovy/groovy-core
public Object run() {
return new GroovyClassLoader(SecurityTestSupport.class.getClassLoader());
}
});
代码示例来源:origin: Netflix/zuul
/**
* compiles the Groovy source code
*
* @param sFilterCode
* @return
* @throws org.codehaus.groovy.control.CompilationFailedException
*
*/
public Class compileGroovy(String sFilterCode) throws org.codehaus.groovy.control.CompilationFailedException {
GroovyClassLoader loader = new GroovyClassLoader();
return loader.parseClass(sFilterCode);
}
代码示例来源:origin: ch.qos.logback/logback-classic
GroovyClassLoader gLoader = new GroovyClassLoader(classLoader);
try {
Class scriptClass = gLoader.parseClass(scriptText);
代码示例来源:origin: groovy/groovy-core
public Object run() {
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.setClasspath(mgr.getClassPath());
return new GroovyClassLoader(finalParent, configuration);
}
});
代码示例来源:origin: apache/groovy
public long execute() throws Exception {
ClassLoader cl = new URLClassLoader(classpath, ClassLoader.getSystemClassLoader().getParent());
GroovyClassLoader gcl = new GroovyClassLoader(cl);
CompilationUnit cu = new CompilationUnit(new CompilerConfiguration(), null, gcl, new GroovyClassLoader(this.getClass().getClassLoader()));
for (File source : sources) {
cu.addSource(source);
}
long sd = System.nanoTime();
cu.compile(CompilePhase.CLASS_GENERATION.getPhaseNumber());
long dur = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - sd);
return dur;
}
}
代码示例来源:origin: groovy/groovy-core
public void testInitOrder () throws NoSuchFieldException, IllegalAccessException, ClassNotFoundException {
System.out.println("GET FIELD");
final Field f = new GroovyClassLoader().loadClass("org.codehaus.groovy.runtime.X", false, false, false).getField("field");
System.out.println(failed);
assertTrue(!failed);
f.getInt(null);
System.out.println(failed);
assertTrue(failed);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@SuppressWarnings("resource")
public void classLoading() throws Exception {
StaticApplicationContext context = new StaticApplicationContext();
GroovyClassLoader gcl = new GroovyClassLoader();
Class<?> class1 = gcl.parseClass("class TestBean { def myMethod() { \"foo\" } }");
Class<?> class2 = gcl.parseClass("class TestBean { def myMethod() { \"bar\" } }");
context.registerBeanDefinition("testBean", new RootBeanDefinition(class1));
Object testBean1 = context.getBean("testBean");
Method method1 = class1.getDeclaredMethod("myMethod", new Class<?>[0]);
Object result1 = ReflectionUtils.invokeMethod(method1, testBean1);
assertEquals("foo", result1);
context.removeBeanDefinition("testBean");
context.registerBeanDefinition("testBean", new RootBeanDefinition(class2));
Object testBean2 = context.getBean("testBean");
Method method2 = class2.getDeclaredMethod("myMethod", new Class<?>[0]);
Object result2 = ReflectionUtils.invokeMethod(method2, testBean2);
assertEquals("bar", result2);
}
代码示例来源:origin: groovy/groovy-core
public void testJdkDynamicProxyDifferentLoaders() throws Exception {
// Instantiate all beans.
JdkDynamicProxyServiceBean sb1 = (JdkDynamicProxyServiceBean) JdkDynamicProxyInvocationHandler.getProxiedObject(new GroovyClassLoader().loadClass("org.codehaus.groovy.runtime.JdkDynamicProxyServiceBeanImpl1").newInstance());
JdkDynamicProxyServiceBean sb2 = (JdkDynamicProxyServiceBean) JdkDynamicProxyInvocationHandler.getProxiedObject(new GroovyClassLoader().loadClass("org.codehaus.groovy.runtime.JdkDynamicProxyServiceBeanImpl2").newInstance());
// Manually wire beans together.
sb1.setJdkDynamicProxyServiceBean(sb2);
assertEquals("SERVICE", sb1.doService());
}
代码示例来源:origin: groovy/groovy-core
public void testJdkDynamicProxySameLoader() throws Exception {
// Instantiate all beans.
final GroovyClassLoader loader = new GroovyClassLoader();
JdkDynamicProxyServiceBean sb1 = (JdkDynamicProxyServiceBean) JdkDynamicProxyInvocationHandler.getProxiedObject(loader.loadClass("org.codehaus.groovy.runtime.JdkDynamicProxyServiceBeanImpl1").newInstance());
JdkDynamicProxyServiceBean sb2 = (JdkDynamicProxyServiceBean) JdkDynamicProxyInvocationHandler.getProxiedObject(loader.loadClass("org.codehaus.groovy.runtime.JdkDynamicProxyServiceBeanImpl2").newInstance());
// Manually wire beans together.
sb1.setJdkDynamicProxyServiceBean(sb2);
assertEquals("SERVICE", sb1.doService());
}
代码示例来源:origin: groovy/groovy-core
public void testCreateScriptWithScriptClass() {
GroovyClassLoader classLoader = new GroovyClassLoader();
String controlProperty = "text";
String controlValue = "I am a script";
String code = controlProperty + " = '" + controlValue + "'";
GroovyCodeSource codeSource = new GroovyCodeSource(code, "testscript", "/groovy/shell");
Class scriptClass = classLoader.parseClass(codeSource, false);
Script script = InvokerHelper.createScript(scriptClass, new Binding(bindingVariables));
assertEquals(bindingVariables, script.getBinding().getVariables());
script.run();
assertEquals(controlValue, script.getProperty(controlProperty));
}
}
内容来源于网络,如有侵权,请联系作者删除!