/** * Returns a {@link GroovyClassLoader} that contains all scripts from the database. This method is * synchronized, so you can call scripts even though they are just being reloaded from the * database. */ private void getGroovyScripts() { try { InputStream grooving = null; StringBuilder sb = new StringBuilder(); try { URL groovyURL = ApplicationBean.getInstance() .getServletContext() .getResource("/WEB-INF/classes/plugins/groovy/system/DefaultActionHandler.groovy"); grooving = groovyURL.openStream(); byte[] buffer = new byte[2048]; int length; while ((length = grooving.read(buffer)) != -1) { sb.append(new String(buffer, 0, length)); } grooving.close(); } catch (Exception exx) { LOGGER.warn( "Could not load " + Constants.getGroovyURL() + "DefaultActionHandler.groovy. This is normal for the test environment."); } // get the sources from DB and parse them... Class<?> parsedClass = groovyClassLoader.parseClass(sb.toString()); availableClasses.put("plugins.groovy.system.DefaultActionHandler", parsedClass); // class names to get on database... List<TScriptsBean> scriptBeansList = ScriptAdminBL.getAllScripts(); if (scriptBeansList != null) { for (TScriptsBean scriptsBean : scriptBeansList) { Integer scriptType = scriptsBean.getScriptType(); if (scriptType == null || !scriptType.equals(TScriptsBean.SCRIPT_TYPE.PARAMETER_SCRIPT)) { parseScript(scriptsBean.getClazzName(), scriptsBean.getSourceCode()); } } } } catch (Exception ex) { LOGGER.warn("Problem loading Groovy scripts. This is normal for the test environment."); } }