Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.Script


        JobDetail  detail = jobContext.getJobDetail();

        JobDataMap data   = detail.getJobDataMap();

        Script script = (Script) data.get( "jelly.script" );

        JellyContext jellyContext = (JellyContext) data.get( "jelly.context" );

        XMLOutput    output       = (XMLOutput) data.get( "jelly.output" );

        try
        {
            script.run( jellyContext,
                        output );
            output.flush();
        }
        catch (Exception e)
        {
View Full Code Here


            log( "Running script: " + getUrl() );
            if ( output != null ) {
                log( "Sending output to: " + output );
            }
           
            Script script = compileScript();
            JellyContext context = getJellyContext();
            context.setVariable( "project", project );
            script.run( context, getXMLOutput() );
            getXMLOutput().close();
        }
        catch (Exception e) {
            throw new BuildException(e, location);
        }
View Full Code Here

     * Compiles the script
     */
    protected Script compileScript() throws Exception {
        XMLParser parser = new XMLParser();
        parser.setContext(getJellyContext());
        Script script = parser.parse(getUrl().toString());
        script = script.compile();
        if (log.isDebugEnabled()) {
            log.debug("Compiled script: " + getUrl());
        }
        return script;
    }
View Full Code Here

    // Tag interface
    //-------------------------------------------------------------------------                   
    public void doTag(XMLOutput output) throws Exception {
        // Try find find the body from the reserved 'org.apache.commons.jelly.body' variable
        Script script = (Script) context.getVariable("org.apache.commons.jelly.body");
        if (script != null) {
            script.run(context, output);
        }
        else {
            // note this mechanism does not work properly for arbitrarily
            // nested dynamic tags. A better way is required.
            Tag tag = findAncestorWithClass(this, DynamicTag.class);
View Full Code Here

    public Tag createTag(String name)
        throws Exception {

        Object value = templates.get(name);
        if ( value instanceof Script ) {           
            Script template = (Script) value;
            return new DynamicTag(template);
        }
        else if ( value instanceof TagFactory ) {
            TagFactory factory = (TagFactory) value;
            return factory.createTag();
View Full Code Here

    // Script interface
    //-------------------------------------------------------------------------                   
    public Script compile() throws Exception {
        int size = list.size();
        if (size == 1) {
            Script script = (Script) list.get(0);
            return script.compile();
        }
        // now compile children
        for (int i = 0; i < size; i++) {
            Script script = (Script) list.get(i);
            list.set(i, script.compile());
        }
        return this;
    }
View Full Code Here

            Script script = scripts[i];
            script.run(context, output);
        }
*/   
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            Script script = (Script) iter.next();
            script.run(context, output);
        }
    }
View Full Code Here

    // Script interface
    //-------------------------------------------------------------------------
    public Script compile() throws JellyException {
        int size = list.size();
        if (size == 1) {
            Script script = (Script) list.get(0);
            return script.compile();
        }
        // now compile children
        for (int i = 0; i < size; i++) {
            Script script = (Script) list.get(i);
            list.set(i, script.compile());
        }
        return this;
    }
View Full Code Here

            Script script = scripts[i];
            script.run(context, output);
        }
*/
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            Script script = (Script) iter.next();
            script.run(context, output);
        }
    }
View Full Code Here

    public void testGetIntegerMaxValue() throws Exception {

        setUpScript( "testGetStaticTag.jelly" );

        Script script = getJelly().compileScript();

        getJellyContext().setVariable( "test.Integer.MAX_VALUE",
                                       Boolean.TRUE );

        script.run( getJellyContext(), getXMLOutput() );

        assertEquals( new Integer(java.lang.Integer.MAX_VALUE),
                      getJellyContext().getVariable("value" ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.Script

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.