Examples of GroovyClassLoader


Examples of groovy.lang.GroovyClassLoader

    public static Class<?> parseClass(String text) {
        return new GroovyClassLoader().parseClass(text);
    }

    public static Class<?> parseClass(String text, String location) {
        return new GroovyClassLoader().parseClass(text, location);
    }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

        }

        //
        InputStream in = new ByteArrayInputStream(bytes);
        GroovyCodeSource gcs = new GroovyCodeSource(in, templateName, "/groovy/shell");
        GroovyClassLoader loader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader(), config);
        Class<?> scriptClass;
        try {
            scriptClass = loader.parseClass(gcs, false);
        } catch (CompilationFailedException e) {
            throw new GroovyCompilationException(e, templateText, groovyText);
        } catch (ClassFormatError e) {
            throw new GroovyCompilationException(e, templateText, groovyText);
        }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

    * @throws IOException if stream can't be parsed or object can't be created
    *         cause to illegal content of stream
    */
   public Object instantiateScript(InputStream stream, String name) throws IOException
   {
      GroovyClassLoader loader;
      if (mapping.size() > 0)
      {
         JarJarClassLoader jarjarLoader = SecurityHelper.doPrivilegedAction(new PrivilegedAction<JarJarClassLoader>()
         {
            public JarJarClassLoader run()
            {
               return new JarJarClassLoader();
            }
         });

         jarjarLoader.addMapping(mapping);
         loader = jarjarLoader;
      }
      else
      {
         loader = SecurityHelper.doPrivilegedAction(new PrivilegedAction<GroovyClassLoader>()
         {
            public GroovyClassLoader run()
            {
               return new GroovyClassLoader();
            }
         });
      }
      return instantiateScript(stream, name, loader);
   }
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

   public Object instantiateScript(final InputStream stream, final String name, GroovyClassLoader loader)
      throws IOException
   {
      if (loader == null)
      {
         loader = new GroovyClassLoader();
      }
      Class<?> clazz = null;
      try
      {
         final GroovyClassLoader fLoader = loader;
         clazz = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Class<?>>()
         {
            public Class<?> run() throws Exception
            {
               if (name != null && name.length() > 0)
               {
                  return fLoader.parseClass(stream, name);
               }
               else
               {
                  return fLoader.parseClass(stream);
               }
            }
         });
      }
      catch (PrivilegedActionException pae)
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

    */
   public Object instantiateScript(final GroovyCodeSource codeSource, GroovyClassLoader loader)
   {
      if (loader == null)
      {
         loader = new GroovyClassLoader();
      }

      final GroovyClassLoader fLoader = loader;
      Class<?> clazz = SecurityHelper.doPrivilegedAction(new PrivilegedAction<Class<?>>()
      {
         public Class<?> run()
         {
            return fLoader.parseClass(codeSource);
         }
      });

      try
      {
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

    });
    script.run();

    String fileName = "src/main/java/Tester.groovy";
    GroovyClassLoader gcl = new GroovyClassLoader();
    Class clazz = gcl.parseClass(new File(fileName));
    Field[] fields = clazz.getFields();
    Field[] declaredFields = clazz.getDeclaredFields();
    Field declaredField = clazz.getDeclaredField("service");
    Object aScript = clazz.newInstance();
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

    @SuppressWarnings(value = "unchecked")
    private void loadCommand(Resource file) {
        try {
            ClassLoader parent = getClass().getClassLoader();
            GroovyClassLoader loader = new GroovyClassLoader(parent);
            Class<? extends Command> groovyClass =
                    (Class<? extends Command>) loader.parseClass(file.read(), file.getName());

            if(groovyClass.isAnnotationPresent(CommandDefinition.class)) {
                boolean correctClass = false;
                for(Class groovyInterface : groovyClass.getInterfaces()) {
                    if(groovyInterface.equals(Command.class)) {
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

    }

    public void init(PortletConfig config) throws PortletException
    {
        this.portletConfig = config;
        this.groovyClassLoader = new GroovyClassLoader();

        this.autoRefresh = "true".equals(config.getInitParameter(AUTO_REFRESH_INIT_PARAM));

        String param = config.getInitParameter(SCRIPT_SOURCE_URL_ENCODING_INIT_PARAM);
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

        this.scriptPreferencesValidatorInstance.validate(preferences);
    }

    public void initialize(PortletPreferences preferences) throws ValidatorException
    {
        this.groovyClassLoader = new GroovyClassLoader();

        this.autoRefresh = "true".equals(preferences.getValue(AUTO_REFRESH_PREF_KEY, null));

        String param = preferences.getValue(SCRIPT_SOURCE_URL_ENCODING_PREF_KEY, null);
View Full Code Here

Examples of groovy.lang.GroovyClassLoader

        Class<Script> scriptType = parseExpression(expression);
        return new GroovyExpression(scriptType, expression);
    }

    protected Class<Script> parseExpression(String expression) {
        return new GroovyClassLoader().parseClass(expression);
    }
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.