Package groovy.lang

Examples of groovy.lang.GroovyClassLoader


  private String scriptText;
  protected ScriptSaver saver = new ScriptSaver();

  public SoapUIGroovyScriptEngine( ClassLoader parentClassLoader )
  {
    classLoader = new GroovyClassLoader( parentClassLoader );
    binding = new Binding();
    CompilerConfiguration config = new CompilerConfiguration();
    config.setDebug( true );
    config.setVerbose( true );
    shell = new GroovyShell( classLoader, binding, config );
View Full Code Here


        ClassLoader cl = contribution.getClassLoader();
        if (!(cl instanceof GroovyClassLoader)) {
            // replace the contribution class loader with a Groovy one
          // If the contribution does not have a ClassLoader, use this ClassLoader as parent
          if (cl == null) cl = this.getClass().getClassLoader();           
            cl = new GroovyClassLoader(cl);
            contribution.setClassLoader(cl);
        }
        try {

            ((GroovyClassLoader)cl).parseClass(((GroovyArtifact)model).getArtifactURL().openStream());
View Full Code Here

            firstChild.serialize(writer);
            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

     * process the route configuration defined in Groovy class
     */
    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

     * process the route configuration defined in Groovy class
     */
    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

* Returns a Groovy object
*/
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

        this.loader =
                (GroovyClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() {
                        CompilerConfiguration configuration = new CompilerConfiguration();
                        configuration.setClasspath(mgr.getClassPath());
                        return new GroovyClassLoader(finalParent, configuration);
                    }
                });
        execScripts = new HashMap();
        evalScripts = new HashMap();
        context = shell.getContext();
View Full Code Here

        if (javaHome.toLowerCase(Locale.US).endsWith("jre")) {
            javaHome = javaHome.substring(0, javaHome.length() - 4);
        }
        File toolsJar = new File((javaHome + "/lib/tools.jar"));
        if (toolsJar.exists()) {
            GroovyClassLoader loader = cu.getClassLoader();
            loader.addClasspath(toolsJar.getAbsolutePath());
            return loader.loadClass(main);
        }

        throw new ClassNotFoundException("unable to locate the java compiler com.sun.tools.javac.Main, please change your classloader settings");
    }
View Full Code Here

    }

    public GroovyScriptEngineImpl() {
        classMap = Collections.synchronizedMap(new HashMap<String, Class>());
        globalClosures = Collections.synchronizedMap(new HashMap<String, Closure>());
        loader = new GroovyClassLoader(getParentLoader(),
                new CompilerConfiguration());
    }
View Full Code Here

     */

    public void setClassLoader(GroovyClassLoader loader) {
        ClassLoader parent = Thread.currentThread().getContextClassLoader();
        if (parent == null) parent = ProcessingUnit.class.getClassLoader();
        this.classLoader = (loader == null ? new GroovyClassLoader(parent, configuration) : loader);
    }
View Full Code Here

TOP

Related Classes of groovy.lang.GroovyClassLoader

Copyright © 2018 www.massapicom. 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.