info.magnolia.module.groovy.support.classes
Class MgnlGroovyClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by groovy.lang.GroovyClassLoader
                  extended by info.magnolia.module.groovy.support.classes.MgnlGroovyClassLoader

public final class MgnlGroovyClassLoader
extends groovy.lang.GroovyClassLoader

Magnolia class loader which extends GroovyClassLoader and internally uses MgnlGroovyResourceLoader.

Version:
$Id$
Author:
fgrilli
See Also:
isSourceNewer(URL, Class), MgnlGroovyClassLoader.AddDefaultImportOperation, MgnlGroovyClassLoader.PackageAndClassNameConsistencyOperation

Nested Class Summary
 
Nested classes/interfaces inherited from class groovy.lang.GroovyClassLoader
groovy.lang.GroovyClassLoader.ClassCollector, groovy.lang.GroovyClassLoader.InnerLoader
 
Field Summary
 
Fields inherited from class groovy.lang.GroovyClassLoader
classCache, sourceCache
 
Constructor Summary
MgnlGroovyClassLoader(HierarchyManagerProvider hmp)
           
 
Method Summary
protected  org.codehaus.groovy.control.CompilationUnit createCompilationUnit(org.codehaus.groovy.control.CompilerConfiguration config, CodeSource codeSource)
           
protected  boolean isSourceNewer(URL source, Class cls)
          Source newer in our case means that the groovy source representing a certain class in the scripts repository is more recent than that of the corresponding class currently loaded in this classloader (i.e.
 void verify(String source, boolean enforceCompileChecks, String mgnlPath)
          Checks that the given source compiles correctly and, in case of a script which has to act as a class, that some consistency constraints imposed by our classloading mechanism are enforced.
 
Methods inherited from class groovy.lang.GroovyClassLoader
addClasspath, addURL, clearCache, createCollector, defineClass, defineClass, defineClass, defineClass, expandClassPath, generateScriptName, getClassCacheEntry, getClassPath, getLoadedClasses, getPermissions, getResourceLoader, getTimeStamp, isRecompilable, isShouldRecompile, loadClass, loadClass, loadClass, parseClass, parseClass, parseClass, parseClass, parseClass, parseClass, parseClass, recompile, removeClassCacheEntry, setClassCacheEntry, setResourceLoader, setShouldRecompile
 
Methods inherited from class java.net.URLClassLoader
definePackage, findClass, findResource, findResources, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MgnlGroovyClassLoader

public MgnlGroovyClassLoader(HierarchyManagerProvider hmp)
Parameters:
hmp - HierarchyManagerProvider - it must not be null
Method Detail

createCompilationUnit

protected org.codehaus.groovy.control.CompilationUnit createCompilationUnit(org.codehaus.groovy.control.CompilerConfiguration config,
                                                                            CodeSource codeSource)
Overrides:
createCompilationUnit in class groovy.lang.GroovyClassLoader

isSourceNewer

protected boolean isSourceNewer(URL source,
                                Class cls)
                         throws IOException
Source newer in our case means that the groovy source representing a certain class in the scripts repository is more recent than that of the corresponding class currently loaded in this classloader (i.e. it has been changed). Please note that if source protocol is file, then recompilation is forced otherwise the caller gets the old class in the current classloader which might be the compiled script from the scripts repository if the latter (the script, that is) was just disabled.

Overrides:
isSourceNewer in class groovy.lang.GroovyClassLoader
Throws:
IOException

verify

public final void verify(String source,
                         boolean enforceCompileChecks,
                         String mgnlPath)
                  throws org.codehaus.groovy.control.CompilationFailedException
Checks that the given source compiles correctly and, in case of a script which has to act as a class, that some consistency constraints imposed by our classloading mechanism are enforced. Throws a CompilationFailedException in case of compilation failure. For the applied constraints, see PackageAndClassNameConsistencyOperation

Parameters:
source - - String the Groovy source
enforceCompileChecks - - boolean if true enforce additional compile time checks
mgnlPath - - String the path to the script in the repository. The substring after the last '/' is assumed to be the script name itself. Will be ignored if enforceCompileChecks is false. Cannot be null if enforceCompileChecks is true.
Throws:
org.codehaus.groovy.control.CompilationFailedException


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.