use of groovy.lang.GroovyClassLoader in project be5 by DevelopmentOnTheEdge.
the class GroovyRegister method initClassLoader.
public void initClassLoader() {
classLoader = new GroovyClassLoader();
addClassPaths();
}
use of groovy.lang.GroovyClassLoader in project ofbiz-framework by apache.
the class GroovyUtil method loadClass.
public static Class<?> loadClass(String path) throws ClassNotFoundException, IOException {
GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
Class<?> classLoader = groovyClassLoader.loadClass(path);
groovyClassLoader.close();
return classLoader;
}
use of groovy.lang.GroovyClassLoader in project spring-integration by spring-projects.
the class GroovyScriptExecutingMessageProcessor method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
if (this.beanFactory != null && this.beanFactory instanceof ConfigurableListableBeanFactory) {
((ConfigurableListableBeanFactory) this.beanFactory).ignoreDependencyType(MetaClass.class);
}
CompilerConfiguration compilerConfiguration = this.compilerConfiguration;
if (compilerConfiguration == null && this.compileStatic) {
compilerConfiguration = new CompilerConfiguration();
compilerConfiguration.addCompilationCustomizers(new ASTTransformationCustomizer(CompileStatic.class));
}
this.groovyClassLoader = new GroovyClassLoader(this.beanClassLoader, compilerConfiguration);
}
use of groovy.lang.GroovyClassLoader in project jbehave-core by jbehave.
the class BytecodeGroovyClassLoaderBehaviour method shouldCacheBytes.
@Test
public void shouldCacheBytes() throws IOException {
GroovyClassLoader classLoader = new BytecodeGroovyClassLoader();
assertThat((Class<?>) classLoader.parseClass("class Hello { }"), is(notNullValue()));
InputStream bytecode = classLoader.getResourceAsStream("Hello.class");
assertThat(bytecode, is(notNullValue()));
bytecode.close();
}
use of groovy.lang.GroovyClassLoader in project LogHub by fbacchella.
the class TestGroovy method testGroovy2.
@SuppressWarnings("unchecked")
@Test
public void testGroovy2() throws InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException, IOException {
String script = "event.a.b * 2";
try (GroovyClassLoader groovyClassLoader = new GroovyClassLoader()) {
Class<Script> theParsedClass = groovyClassLoader.parseClass(script);
Script groovyScript = theParsedClass.newInstance();
Binding groovyBinding = new Binding();
Event event = new EventInstance(ConnectionContext.EMPTY);
event.put("a", Collections.singletonMap("b", 1));
groovyBinding.setVariable("event", event);
groovyScript.setBinding(groovyBinding);
System.out.println(groovyScript.run().getClass());
}
}
Aggregations