public Class loadScriptByName ( String scriptName ) throws ResourceException , ScriptException { URLConnection conn = rc . getResourceConnection ( scriptName ) ; String path = conn . getURL ( ) . toExternalForm ( ) ; ScriptCacheEntry entry = scriptCache . get ( path ) ; Class clazz = null ; if ( entry != null ) clazz = entry . scriptClass ; try { if ( isSourceNewer ( entry ) ) { try { String encoding = conn . getContentEncoding ( ) != null ? conn . getContentEncoding ( ) : config . getSourceEncoding ( ) ; String content = IOGroovyMethods . getText ( conn . getInputStream ( ) , encoding ) ; clazz = groovyLoader . parseClass ( content , path ) ; } catch ( IOException e ) { throw new ResourceException ( e ) ; } } } finally { forceClose ( conn ) ; } return clazz ; }
Get the class of the scriptName in question so that you can instantiate Groovy objects with caching and reloading .