Examples of parseClass()


Examples of groovy.lang.GroovyClassLoader.parseClass()

         name = name.substring(1);
      }

      try
      {
         groovyClassLoader.parseClass(script, name);
         return Response.status(Response.Status.OK).build();
      }
      catch (Exception e)
      {
         LOG.error(e.getMessage(), e);
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

      classText.append("\t\t").append(formulaDef).append('\n');
      classText.append("\t}\n");
      classText.append("}\n");
      GroovyClassLoader loader = new GroovyClassLoader(UpdateChecker.class.getClassLoader());
    try {
      Class groovyClass = loader.parseClass(classText.toString()); //TODO this his horribly slow (~500ms)  Can we parse all at once or can we do this lazily or initialize in another thread?
      return (UpdateCheckerFormula)groovyClass.newInstance();
    } catch (Exception e) {
      return new UpdateCheckerFormula();
    }
  }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

            writer.flush();
            String value = writer.toString();
            if (value != null) {
                InputStream in = new ByteArrayInputStream(value.getBytes());
                GroovyClassLoader loader = new GroovyClassLoader();
                Class groovyClass = loader.parseClass(groovyFileStream);
                GroovyObject groovyObject =
                    (GroovyObject) groovyClass.newInstance();
                Object[] arg = { in };
                Object obj = groovyObject.invokeMethod(methodName, arg);
                if (obj == null) {
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

     */
    private Response parseGroovy(String route) {
        try {
            // load the definition class into a RouteBuilder instance
            GroovyClassLoader classLoader = new GroovyClassLoader();
            Class<?> clazz = classLoader.parseClass(route);
            RouteBuilder builder = (RouteBuilder)clazz.newInstance();
            LOG.info("Loaded builder: " + builder);

            postRoutes(builder);

View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

     */
    private Response parseGroovy(String route) {
        try {
            // load the definition class into a RouteBuilder instance
            GroovyClassLoader classLoader = new GroovyClassLoader();
            Class<?> clazz = classLoader.parseClass(route);
            RouteBuilder builder = (RouteBuilder)clazz.newInstance();
            LOG.info("Loaded builder: " + builder);
            // add the route builder
            getCamelContext().addRoutes(builder);
            return Response.seeOther(new URI("/routes")).build();
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

public class GroovyParser {

  public static GroovyObject parse(String args) {
    GroovyClassLoader cl = new GroovyClassLoader();
    try {
      final Class<?> clazz = cl.parseClass(args);
      final GroovyObject newInstance = (GroovyObject) clazz.newInstance();
      return newInstance;
    }
    catch (Exception e) {
      throw new ExecutionException(e.getMessage(), e);
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

        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));
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

        name = "src/test/" + getClass().getPackage().getName().replace(".", "/") + "/" + name;

        try
        {
            scriptClass = gcl.parseClass(new File(name));
        }
        catch (CompilationFailedException e)
        {
            throw new RuntimeException("Script compilation failed: "
                + e.getMessage());
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

  public void testClassLoading() 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]);
View Full Code Here

Examples of groovy.lang.GroovyClassLoader.parseClass()

  public void testClassLoading() 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);
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.