Class JcrGroovyCompiler
- java.lang.Object
-
- org.exoplatform.services.jcr.ext.script.groovy.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
-
-
Field Summary
Fields Modifier and Type Field Description protected List<GroovyScriptAddRepoPlugin>addRepoPluginsprotected JcrGroovyClassLoaderProviderclassLoaderProvider
-
Constructor Summary
Constructors Constructor Description JcrGroovyCompiler()JcrGroovyCompiler(JcrGroovyClassLoaderProvider classLoaderProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>[]compile(UnifiedNodeReference... sourceReferences)Compile Groovy source that located insourceReferences.Class<?>[]compile(org.exoplatform.services.rest.ext.groovy.SourceFile[] files)Compile Groovy source that located infiles.Class<?>[]compile(org.exoplatform.services.rest.ext.groovy.SourceFolder[] src, UnifiedNodeReference... sourceReferences)Compile Groovy source that located insourceReferences.Class<?>[]compile(org.exoplatform.services.rest.ext.groovy.SourceFolder[] src, org.exoplatform.services.rest.ext.groovy.SourceFile[] files)Compile Groovy source that located infiles.URL[]getDependencies(org.exoplatform.services.rest.ext.groovy.SourceFolder[] sources, org.exoplatform.services.rest.ext.groovy.SourceFile[] files)Get URLs of classes (stored in JCR only) required to compile sourcesfiles.voidstart()voidstop()
-
-
-
Field Detail
-
classLoaderProvider
protected final JcrGroovyClassLoaderProvider classLoaderProvider
-
addRepoPlugins
protected List<GroovyScriptAddRepoPlugin> addRepoPlugins
-
-
Constructor Detail
-
JcrGroovyCompiler
public JcrGroovyCompiler(JcrGroovyClassLoaderProvider classLoaderProvider)
-
JcrGroovyCompiler
public JcrGroovyCompiler()
-
-
Method Detail
-
compile
public Class<?>[] compile(UnifiedNodeReference... sourceReferences) throws IOException
Compile Groovy source that located insourceReferences. 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 insourceReferences. Compiled sources can be dependent to each other and dependent to Groovy sources that are accessible for this compiler and with additional Groovy sourcessrc. 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 compilesourceReferencessourceReferences- 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 infiles. Compiled sources can be dependent to each other and dependent to Groovy sources that are accessible for this compiler and with additional Groovy sourcessrc. 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 compilefilesfiles- 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 infiles. 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 sourcesfiles. Result array includes URLs offilesplus 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 analyzefilesfiles- set of sources for analyzing- Returns:
- URLs
- Throws:
IOException- if any i/o errors occurs
-
start
public void start()
- Specified by:
startin interfaceorg.picocontainer.Startable- See Also:
Startable.start()
-
stop
public void stop()
- Specified by:
stopin interfaceorg.picocontainer.Startable- See Also:
Startable.stop()
-
-