Package groovy.lang

Examples of groovy.lang.GroovyClassLoader$ClassCollector


    */
   public Object instantiateScript(InputStream stream, String name, GroovyClassLoader loader) throws IOException
   {
      if (loader == null)
      {
         loader = new GroovyClassLoader();
      }
      Class<?> clazz = null;
      try
      {
         if (name != null && name.length() > 0)
View Full Code Here


    */
   public Object instantiateScript(GroovyCodeSource codeSource, GroovyClassLoader loader)
   {
      if (loader == null)
      {
         loader = new GroovyClassLoader();
      }
      Class<?> clazz = null;
      clazz = loader.parseClass(codeSource);
      try
      {
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

    }

    private CachedRule loadGroovy(File file) {
        CachedRule entry = null;
        try {
            GroovyClassLoader gcl = new GroovyClassLoader();
            Class<?> clazz = gcl.parseClass(file);
            Rule rule = (Rule) clazz.newInstance();
            rule.setFactory(this);
            entry = new CachedRule(file.lastModified(), rule);
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

   @Override
   public ClassLoader getClassLoader()
   {
      if (classLoader == null && super.getClassLoader() != null)
      {
         this.classLoader = new GroovyClassLoader(super.getClassLoader());
      }
      return classLoader;
   }
View Full Code Here

   @Consumes({"script/groovy"})
   @Path("validate{name:.*}")
   public Response validateScript(@PathParam("name") String name, InputStream script)
   {

      GroovyClassLoader groovyClassLoader = groovyPublisher.getGroovyClassLoader();
      if (name == null || name.length() == 0)
      {
         name = groovyClassLoader.generateScriptName();
      }
      else if (name.startsWith("/"))
      {
         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

 
  protected final List<String> imports = new ArrayList<String>();
 
  protected final GroovyClassLoader compiler;
 
  public GroovyCLI() { this(new GroovyClassLoader(), new EntryPointConsole(), null); }
View Full Code Here

    this.addArgument("script...", String.class, "All arguments will be taken to form the script");
  }

  public Object execute(GroovyCLIContext ctx, CommandLineArgumentsStandard arguments) {
    if (original.getParent() != Thread.currentThread().getContextClassLoader())
      this.compiler = new GroovyClassLoader();
    else
      this.compiler = this.original;
   
    List<String> commandInfo = new ArrayList<String>();
    for (int i=0; i<arguments.getRawArgumentCount(); i++) {
View Full Code Here

      classText.append("public class UpdateCheckerFormulaImpl extends UpdateCheckerFormula{\n");
      classText.append("\tpublic int mainCompare(String currentVersion,String latestVersion){\n");
      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

TOP

Related Classes of groovy.lang.GroovyClassLoader$ClassCollector

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.