List of usage examples for org.apache.commons.jelly JellyContext compileScript
public Script compileScript(InputSource source) throws JellyException
From source file:com.cyclopsgroup.waterview.jelly.JellyEngine.java
/** * Get script with give path and package name * * @param scriptPath Script path/*from w ww .ja v a 2 s .c o m*/ * @param packageName Look for it in this package * @param defaultScript Return as default value * @return Script object * @throws JellyException Throw it out */ public Script getScript(String packageName, String scriptPath, Script defaultScript) throws JellyException { String fullPath = scriptPath; String pkg = moduleManager.getPackageName(packageName); if (StringUtils.isNotEmpty(pkg)) { fullPath = pkg.replace('.', '/') + scriptPath; } Script script = null; synchronized (this) { if (getCacheManager().contains(this, fullPath)) { script = (Script) getCacheManager().get(this, fullPath); } else { final URL resource = getClass().getClassLoader().getResource(fullPath); if (resource == null) { script = DUMMY_SCRIPT; } else { JellyContext jc = new JellyContext(getGlobalContext()); final Script s = jc.compileScript(resource); script = new Script() { public Script compile() throws JellyException { return this; } public void run(JellyContext context, XMLOutput output) throws JellyTagException { TagSupport.addScriptResource(resource, context); try { s.run(context, output); } catch (JellyTagException e) { throw e; } finally { TagSupport.removeScriptResource(resource, context); } } }; } getCacheManager().put(this, fullPath, script); } } return script == DUMMY_SCRIPT ? defaultScript : script; }