Search in sources :

Example 96 with GroovyClassLoader

use of groovy.lang.GroovyClassLoader in project ofbiz-framework by apache.

the class GroovyUtil method parseClass.

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;
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader)

Example 97 with GroovyClassLoader

use of groovy.lang.GroovyClassLoader in project ofbiz-framework by apache.

the class GroovyUtil method parseClass.

public static Class<?> parseClass(String text) throws IOException {
    GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
    Class<?> classLoader = groovyClassLoader.parseClass(text);
    groovyClassLoader.close();
    return classLoader;
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader)

Example 98 with GroovyClassLoader

use of groovy.lang.GroovyClassLoader in project midpoint by Evolveum.

the class GroovyScriptEvaluator method getGroovyLoader.

private GroovyClassLoader getGroovyLoader(ScriptExpressionEvaluationContext context) throws SecurityViolationException {
    GroovyClassLoader groovyClassLoader = getScriptCache().getInterpreter(context.getExpressionProfile());
    if (groovyClassLoader != null) {
        return groovyClassLoader;
    }
    ScriptExpressionProfile scriptExpressionProfile = context.getScriptExpressionProfile();
    groovyClassLoader = createGroovyLoader(scriptExpressionProfile, context);
    getScriptCache().putInterpreter(context.getExpressionProfile(), groovyClassLoader);
    return groovyClassLoader;
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) ScriptExpressionProfile(com.evolveum.midpoint.schema.expression.ScriptExpressionProfile)

Example 99 with GroovyClassLoader

use of groovy.lang.GroovyClassLoader in project zuul by Netflix.

the class GroovyCompiler method compile.

/**
 * Compiles groovy class from a file
 */
public Class<?> compile(File file) throws IOException {
    GroovyClassLoader loader = getGroovyClassLoader();
    Class<?> groovyClass = loader.parseClass(file);
    return groovyClass;
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader)

Example 100 with GroovyClassLoader

use of groovy.lang.GroovyClassLoader in project jbehave-core by jbehave.

the class GroovyAnnotationBuilder method buildConfiguration.

@SuppressWarnings("unchecked")
@Override
public Configuration buildConfiguration() throws AnnotationRequired {
    if (annotationFinder().isAnnotationPresent(UsingGroovy.class)) {
        Class<GroovyClassLoader> classLoaderClass = annotationFinder().getAnnotatedValue(UsingGroovy.class, Class.class, "classLoader");
        Class<GroovyResourceFinder> resourceFinderClass = annotationFinder().getAnnotatedValue(UsingGroovy.class, Class.class, "resourceFinder");
        try {
            GroovyClassLoader classLoader = super.instanceOf(classLoaderClass, classLoaderClass);
            GroovyResourceFinder resourceFinder = super.instanceOf(resourceFinderClass, resourceFinderClass);
            context = createGroovyContext(classLoader, resourceFinder);
        } catch (Exception e) {
            annotationMonitor().elementCreationFailed(GroovyContext.class, e);
        }
    } else {
        annotationMonitor().annotationNotFound(UsingGroovy.class, annotatedClass());
    }
    return super.buildConfiguration();
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader)

Aggregations

GroovyClassLoader (groovy.lang.GroovyClassLoader)126 File (java.io.File)26 GroovyObject (groovy.lang.GroovyObject)17 Test (org.junit.jupiter.api.Test)17 CompilerConfiguration (org.codehaus.groovy.control.CompilerConfiguration)13 IOException (java.io.IOException)11 Binding (groovy.lang.Binding)10 URL (java.net.URL)10 HashMap (java.util.HashMap)10 CompilationFailedException (org.codehaus.groovy.control.CompilationFailedException)10 Map (java.util.Map)9 DefaultGrailsApplication (grails.core.DefaultGrailsApplication)8 GrailsApplication (grails.core.GrailsApplication)8 BuildException (org.apache.tools.ant.BuildException)8 ArtefactHandler (grails.core.ArtefactHandler)7 GroovyShell (groovy.lang.GroovyShell)7 CompilationUnit (org.codehaus.groovy.control.CompilationUnit)7 SimpleMessage (org.codehaus.groovy.control.messages.SimpleMessage)7 Script (groovy.lang.Script)6 Decorator (com.opensymphony.module.sitemesh.Decorator)5