public void loadResource(final InputStream inputStream) throws ResourceInitializationException {
   ClassLoader parent = getClass().getClassLoader();
   GroovyClassLoader groovyClassLoader = new GroovyClassLoader(parent);
   try {
     String scriptString = getScriptHeader();
     StringWriter writer = new StringWriter();
     IOUtils.copy(inputStream, writer);
     scriptString += "\n" + writer.toString();
     scriptString += "\n" + getScriptFooter();
     Class<?> groovyClass = groovyClassLoader.parseClass(scriptString);
     LOGGER.info("Loading groovy variant rules");
     this.script = (GroovyObject) groovyClass.newInstance();
     this.script.invokeMethod("init", new Object[] {});
     initProfilingWithZeroCount();
     LOGGER.info("Groovy variant rules loaded.");
   } catch (Exception e) {
     LOGGER.error("Could not load the groovy variant rules resource");
     throw new ResourceInitializationException(e);
   } finally {
     try {
       groovyClassLoader.close();
     } catch (IOException e) {
       LOGGER.warn("Could not close groovy class loader");
     }
   }
 }
 @Override
 public void close() {
   loader.clearCache();
   try {
     loader.close();
   } catch (IOException e) {
     logger.warn("Unable to close Groovy loader", e);
   }
 }