Class JcrGroovyCompiler

  • All Implemented Interfaces:
    org.picocontainer.Startable

    public class JcrGroovyCompiler
    extends Object
    implements org.picocontainer.Startable
    JcrGroovyCompiler can load source code of groovy script from JCR and parse it via GroovyClassLoader.
    Version:
    $Id$
    Author:
    Andrey Parfonov
    • Constructor Detail

      • JcrGroovyCompiler

        public JcrGroovyCompiler()
    • Method Detail

      • compile

        public Class<?>[] compile​(UnifiedNodeReference... sourceReferences)
                           throws IOException
        Compile Groovy source that located in sourceReferences. Compiled sources can be dependent to each other and dependent to Groovy sources that are accessible for this compiler.
        Parameters:
        sourceReferences - references to Groovy sources to be compiled
        Returns:
        result of compilation
        Throws:
        IOException - if any i/o errors occurs
      • compile

        public Class<?>[] compile​(org.exoplatform.services.rest.ext.groovy.SourceFolder[] src,
                                  UnifiedNodeReference... sourceReferences)
                           throws IOException
        Compile Groovy source that located in sourceReferences. Compiled sources can be dependent to each other and dependent to Groovy sources that are accessible for this compiler and with additional Groovy sources src. NOTE To be able load Groovy source files from specified folders the following rules must be observed:
        • Groovy source files must be located in folder with respect to package structure
        • Name of Groovy source files must be the same as name of class located in file
        • Groovy source file must have extension '.groovy'

        Example: If source stream that we want compile contains the following code:
                   package c.b.a
                   
                   import a.b.c.A
                   
                   class B extends A {
                   // Do something.
                   }
         
        Assume we store dependencies in JCR then URL of folder with Groovy sources may be like this: jcr://repository/workspace#/groovy-library. Then absolute path to JCR node that contains Groovy source must be as following: /groovy-library/a/b/c/A.groovy
        Parameters:
        src - additional Groovy source location that should be added in class-path when compile sourceReferences
        sourceReferences - references to Groovy sources to be compiled
        Returns:
        result of compilation
        Throws:
        IOException - if any i/o errors occurs
      • compile

        public Class<?>[] compile​(org.exoplatform.services.rest.ext.groovy.SourceFolder[] src,
                                  org.exoplatform.services.rest.ext.groovy.SourceFile[] files)
                           throws IOException
        Compile Groovy source that located in files. Compiled sources can be dependent to each other and dependent to Groovy sources that are accessible for this compiler and with additional Groovy sources src. NOTE To be able load Groovy source files from specified folders the following rules must be observed:
        • Groovy source files must be located in folder with respect to package structure
        • Name of Groovy source files must be the same as name of class located in file
        • Groovy source file must have extension '.groovy'
        Parameters:
        src - additional Groovy source location that should be added in class-path when compile files
        files - Groovy sources to be compiled
        Returns:
        result of compilation
        Throws:
        IOException - if any i/o errors occurs
      • compile

        public Class<?>[] compile​(org.exoplatform.services.rest.ext.groovy.SourceFile[] files)
                           throws IOException
        Compile Groovy source that located in files. Compiled sources can be dependent to each other and dependent to Groovy sources that are accessible for this compiler.
        Parameters:
        files - Groovy sources to be compiled
        Returns:
        result of compilation
        Throws:
        IOException - if any i/o errors occurs
      • getDependencies

        public URL[] getDependencies​(org.exoplatform.services.rest.ext.groovy.SourceFolder[] sources,
                                     org.exoplatform.services.rest.ext.groovy.SourceFile[] files)
                              throws IOException
        Get URLs of classes (stored in JCR only) required to compile sources files. Result array includes URLs of files plus URLs of other required sources if they can be found in class-path.
        Parameters:
        sources - additional Groovy source location that should be added in class-path when analyze files
        files - set of sources for analyzing
        Returns:
        URLs
        Throws:
        IOException - if any i/o errors occurs
      • start

        public void start()
        Specified by:
        start in interface org.picocontainer.Startable
        See Also:
        Startable.start()
      • stop

        public void stop()
        Specified by:
        stop in interface org.picocontainer.Startable
        See Also:
        Startable.stop()