Examples of parseClass()


Examples of com.dotcms.repackage.groovy.lang.GroovyClassLoader.parseClass()

       * Call the named method of the given object.
       */
      public Object call(Object sourceCode, String method, Object[] args) throws BSFException {
        GroovyClassLoader gcl = new GroovyClassLoader();
        try {
        return ((GroovyObject)gcl.parseClass(sourceCode.toString()).newInstance()).invokeMethod(method, args);
        } catch (Exception e) {
              throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "exception from Groovy: " + e, e);
          }
      }

View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

        public Class<? extends T> generate() {
            src.format("}");

            GroovyClassLoader classLoader = new GroovyClassLoader(type.getClassLoader());
            return classLoader.parseClass(src.toString());
        }
    }
}
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

        };
        String scriptText = source.getResource().getText();
        String scriptName = source.getClassName();
        GroovyCodeSource codeSource = new GroovyCodeSource(scriptText == null ? "" : scriptText, scriptName, "/groovy/script");
        try {
            groovyClassLoader.parseClass(codeSource, false);
        } catch (MultipleCompilationErrorsException e) {
            SyntaxException syntaxError = e.getErrorCollector().getSyntaxError(0);
            Integer lineNumber = syntaxError == null ? null : syntaxError.getLine();
            throw new ScriptCompilationException(String.format("Could not compile %s.", source.getDisplayName()), e, source,
                    lineNumber);
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

    {
        try
        {
            final GroovyClassLoader grooveyClassLoader = new GroovyClassLoader(this.getClassLoader());
            final Class groovyClass =
                grooveyClassLoader.parseClass(
                    this.getContents(new File(this.scriptPath)),
                    scriptPath);
            final GroovyObject groovyObject = (GroovyObject)groovyClass.newInstance();

            this.copyProperties(
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

    Object[] mainMethodArgs = WRAPPER_MANAGER.getMainMethodArgs();
    try
    {
      ClassLoader parent = WrapperGroovyMain.class.getClassLoader();
      GroovyClassLoader loader = new GroovyClassLoader(parent);
      Class groovyClass = loader.parseClass(scriptFile);
      GroovyObject script = (GroovyObject) groovyClass.newInstance();
      script.invokeMethod("main", mainMethodArgs);
    }
    catch (Throwable e)
    {
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

                    "    return v\n" +
                    "  }\n" +
                    "}";

            GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader());
            groovyClass = loader.parseClass(groovyString);
            try {
                match = groovyClass.getDeclaredMethod("match");
                metaField = groovyClass.getField("meta");
            } catch (NoSuchFieldException e) {
                // can never occur as we control the groovy string
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

public class BytecodeGroovyClassLoaderBehaviour {

    @Test
    public void shouldCacheBytes() throws IOException {
        GroovyClassLoader classLoader = new BytecodeGroovyClassLoader();
        assertNotNull((Class<?>) classLoader.parseClass("class Hello { }"));
        InputStream bytecode = classLoader.getResourceAsStream("Hello.class");
        assertNotNull(bytecode);
        bytecode.close();
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

  public CompiledScript compile(String scriptName, String scriptCode) throws ScriptCompilerException
  {
    try
    {
      GroovyClassLoader gcl = new GroovyClassLoader();
      Class scriptClass = gcl.parseClass(scriptCode);
      if (scriptClass == null)
      {
        throw new ScriptCompilerException("No compiled script code in script \"" + scriptName + "\"");
      }
      return new CompiledGroovyScript(scriptName, gcl.parseClass(scriptCode));
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

      Class scriptClass = gcl.parseClass(scriptCode);
      if (scriptClass == null)
      {
        throw new ScriptCompilerException("No compiled script code in script \"" + scriptName + "\"");
      }
      return new CompiledGroovyScript(scriptName, gcl.parseClass(scriptCode));
    }
    catch (CompilationFailedException x)
    {
      throw new ScriptCompilerException("Unable to compile script", x);
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

    try
    {
//      GroovyShell gs = new GroovyShell();
//      gs.parse(scriptCode);
      GroovyClassLoader gcl = new GroovyClassLoader();
      Class scriptClass = gcl.parseClass(scriptCode);
      if (scriptClass == null)
      {
        throw new ScriptCompilerException("No compiled script code");
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.