Example usage for org.apache.commons.jelly JellyContext getVariables

List of usage examples for org.apache.commons.jelly JellyContext getVariables

Introduction

In this page you can find the example usage for org.apache.commons.jelly JellyContext getVariables.

Prototype

public Map getVariables() 

Source Link

Usage

From source file:com.cyclopsgroup.waterview.jelly.JellyPageRenderer.java

/**
 * Override method render in super class of JellyPageRenderer
 * //  w w w.  j  a  va 2  s .c  om
 * @see com.cyclopsgroup.waterview.PageRenderer#render(com.cyclopsgroup.cyclib.Context, java.lang.String, java.lang.String, com.cyclopsgroup.waterview.UIRuntime)
 */
public void render(Context context, String packageName, String module, UIRuntime runtime) throws Exception {
    XMLOutput jellyOutput = (XMLOutput) context.get("jellyOutput");
    if (jellyOutput == null) {
        jellyOutput = XMLOutput.createXMLOutput(runtime.getOutput());
        context.put("jellyOutput", jellyOutput);
    }

    JellyContext jc = new JellyContext(initialJellyContext);
    for (Iterator i = context.keys(); i.hasNext();) {
        String name = (String) i.next();
        jc.setVariable(name, context.get(name));
    }

    String scriptPath = getScriptPath(packageName, module);
    Script script = getScript(scriptPath);
    synchronized (script) {
        try {
            script.run(jc, jellyOutput);
            runtime.getOutput().flush();
        } catch (Exception e) {
            throw e;
        } finally {
            jc.getVariables().clear();
        }
    }
}

From source file:org.codehaus.nanning.jelly.AspectTagLibrary.java

public static Collection findDefinedRepositories(JellyContext context) {
    Collection result = new LinkedList();
    Map variables = context.getVariables();
    for (Iterator iterator = variables.values().iterator(); iterator.hasNext();) {
        Object value = iterator.next();
        if (value instanceof AspectFactory) {
            result.add(value);//from www .  jav a  2  s  .  com
        }
    }
    return result;
}