public URLConnection getResourceConnection ( String name ) throws ResourceException { name = removeNamePrefix ( name ) . replace ( ' ' , ' ' ) ; //remove the leading / as we are trying with a leading / now if ( name . startsWith ( "WEB-INF/groovy/" ) ) { name = name . substring ( 15 ) ; //just for uniformity } else if ( name . startsWith ( "/" ) ) { name = name . substring ( 1 ) ; } /* * Try to locate the resource and return an opened connection to it. */ try { URL url = servletContext . getResource ( ' ' + name ) ; if ( url == null ) { url = servletContext . getResource ( "/WEB-INF/groovy/" + name ) ; } if ( url == null ) { throw new ResourceException ( "Resource \"" + name + "\" not found!" ) ; } return url . openConnection ( ) ; } catch ( IOException e ) { throw new ResourceException ( "Problems getting resource named \"" + name + "\"!" , e ) ; } }
Interface method for ResourceContainer . This is used by the GroovyScriptEngine .