Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.JellyContext


        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
        {
View Full Code Here


            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

        if (context == null) {
            // take off the name off the URL
            String text = getUrl().toString();
            int idx = text.lastIndexOf('/');
            text = text.substring(0, idx + 1);
            JellyContext parentContext =  new JellyContext(getRootContext(), new URL(text));
            context = new AntJellyContext(project, parentContext);
           
            // register the Ant tag library
            context.registerTagLibrary( "jelly:ant", new AntTagLibrary() );
        }
View Full Code Here

     *
     * @param script is the URL to the script which should create a TestSuite
     * @return a newly created TestSuite
     */
    public static TestSuite createTestSuite(URL script) throws Exception {
        JellyContext context = new JellyContext(script);
        XMLOutput output = XMLOutput.createXMLOutput(System.out);
        context = context.runScript(script, output);
        TestSuite answer = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite");
        if ( answer == null ) {
            log.warn( "Could not find a TestSuite created by Jelly for the script:" + script );
            // return an empty test suite
            return new TestSuite();
        }
View Full Code Here

        // or something?
        TestCase testCase = new TestCase(name) {
            protected void runTest() throws Throwable {
                // create a new child context so that each test case
                // will have its own variable scopes
                JellyContext newContext = new JellyContext( context );
               
                // disable inheritence of variables and tag libraries
                newContext.setExportLibraries(false);
                newContext.setExport(false);
               
                // invoke the test case
                getBody().run(newContext, output);
            }
        };
View Full Code Here

     * @see net.sf.toxicity.pipeline.AbstractMatchingPipeline#process(org.w3c.dom.Document)
     */
    @Override
    public Document process(Document pIn) {
       
        JellyContext context = createContext();
        //context.registerTagLibrary("jelly:toxicity", mToxicityTagLibrary);
       
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XMLOutput xmlOutput = XMLOutput.createXMLOutput(baos);
           
            InputSource is = XmlUtil.getInputSourceFromDom(pIn);
            // jelly will throw a malformed url exception if no system identifier is specified
            is.setSystemId("http://toxicity.sourceforge.net");
           
            context.runScript(is, xmlOutput);
            xmlOutput.flush();
           
            return XmlUtil.getDomFromInputStream(new ByteArrayInputStream(baos.toByteArray()));
           
        } catch (Exception e) {
View Full Code Here

       
    }
   
    protected JellyContext createContext() {
       
        JellyContext context = new JellyContext();
        log.debug("Preparing jelly context: " + context);
       
        HttpServletRequest request = ToxicityRequestFilter.getCurrentRequest();
        ServletContext servletContext = ToxicityRequestFilter.getCurrentServletContext();
        VariableManagerHelper mgr = new VariableManagerHelper(request, request.getSession(false), servletContext);
        mgr.initObject(context, new VariableManagerHelper.VariableSetter() {
           public void setVariable(Object obj, String attrName, Object attrValue) {
               JellyContext ctx = (JellyContext)obj;
               ctx.setVariable(attrName, attrValue);
           }
        });
       
        return context;
    }
View Full Code Here

            log.debug("Invoking dynamic tag with attributes: " + attributes);
        }
        attributes.put("org.apache.commons.jelly.body", getBody());
       
        // create new context based on current attributes
        JellyContext newJellyContext = context.newJellyContext(attributes);
        getTemplate().run(newJellyContext, output);
    }
View Full Code Here

    }

    public void setUp() throws Exception {
        super.setUp();
        jelly = new Jelly();
        context = new JellyContext();
        xmlOutput = XMLOutput.createDummyXMLOutput();
    }
View Full Code Here

                throws ProcessingException,SAXException,IOException {

        super.setup(resolver, objectModel, src, params);

        // Initialize the Jelly context
        this.jellyContext = new JellyContext();
       
        // Update JellyContext with sitemap parameters
        this.updateContext(params);
    }
View Full Code Here

TOP

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

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.