Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.Script


    }

    private String renderContent(AbstractBuild<?, ?> build, InputStream inputStream, TaskListener listener)
            throws JellyException, IOException {
        JellyContext context = createContext(new ScriptContentBuildWrapper(build), build, listener);
        Script script = context.compileScript(new InputSource(inputStream));
        if (script != null) {
            return convert(build, context, script);
        }
        return null;
    }
View Full Code Here


    private final String currentDescriptorByNameUrl;

    public RenderOnDemandClosure(JellyContext context, String attributesToCapture) {
        List<Script> bodyStack = new ArrayList<Script>();
        for (JellyContext c = context; c!=null; c=c.getParent()) {
            Script script = (Script) c.getVariables().get("org.apache.commons.jelly.body");
            if(script!=null) bodyStack.add(script);
        }
        this.bodyStack = bodyStack.toArray(new Script[bodyStack.size()]);
        assert !bodyStack.isEmpty();    // there must be at least one, which is the direct child of <l:renderOnDemand>
View Full Code Here

         * can override {@link ModelObjectWithContextMenu#doContextMenu(StaplerRequest, StaplerResponse)}
         * directly to provide alternative semantics.
         */
        public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response) throws JellyException, IOException {
            WebApp webApp = WebApp.getCurrent();
            final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript("sidepanel");
            if (s!=null) {
                JellyFacet facet = webApp.getFacet(JellyFacet.class);
                request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us
                request.setAttribute("mode","side-panel");
                // run sidepanel but ignore generated HTML
                facet.scriptInvoker.invokeScript(request,response,new Script() {
                    public Script compile() throws JellyException {
                        return this;
                    }

                    public void run(JellyContext context, XMLOutput output) throws JellyTagException {
                        Functions.initPageVariables(context);
                        s.run(context,output);
                    }
                },self,new XMLOutput(new DefaultHandler()));
            } else
            if (self instanceof Actionable) {
                // fallback
View Full Code Here

    public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
        checkPermission(ADMINISTER);

        try {
            MetaClass mc = WebApp.getCurrent().getMetaClass(getClass());
            Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader()));
            new JellyRequestDispatcher(this,script).forward(req,rsp);
        } catch (JellyException e) {
            throw new ServletException(e);
        }
    }
View Full Code Here

        JellyScriptHousing jellyScriptHousing = new JellyScriptHousing();

        try
        {
            // Now lets compile the script once so we can use it repeatedly.
            Script script = JellyUtils.compileScript( jelly, systemId, project.getContext() );

            jellyScriptHousing.setProject( project );
            jellyScriptHousing.setScript( script );
        }
        catch ( Exception e )
View Full Code Here

        {
            if ( log.isDebugEnabled() )
            {
                log.debug( "Jelly script to parse : " + jellyScriptHousing.getSource().toURL() );
            }
            Script script = JellyUtils.compileScript( jellyScriptHousing.getSource(), context );

            context.setRootURL( oldRoot );
            context.setCurrentURL( oldCurrent );

            return script;
View Full Code Here

    void runScript( JellyScriptHousing jellyScriptHousing, MavenJellyContext context )
        throws Exception
    {
        log.debug( "running script " + jellyScriptHousing.getSource() );

        Script s = jellyScriptHousing.getScript();
        if ( s == null )
        {
            s = loadScript( jellyScriptHousing );
            jellyScriptHousing.setScript( s );
        }
        if ( context.getVariable( PLUGIN_HOUSING ) != null )
        {
            throw new IllegalStateException( "nested plugin housings" );
        }
        context.setVariable( PLUGIN_HOUSING, jellyScriptHousing );
        s.run( context, context.getXMLOutput() );
        context.removeVariable( PLUGIN_HOUSING );
    }
View Full Code Here

        {
            context.setRootURL( rootUrl );
            context.setCurrentURL( rootUrl );
        }

        Script script = compileScript( scriptInputStream, systemId, context );
        script.run( context, output );

        context.setRootURL( oldRoot );
        context.setCurrentURL( oldCurrent );
    }
View Full Code Here

     */
    public static Script compileScript( File scriptFile, JellyContext context )
        throws Exception
    {
        FileInputStream fis = null;
        Script result = null;
        try
        {
            fis = new FileInputStream( scriptFile );
            result = compileScript( fis, scriptFile.toURL().toString(), context );
        }
View Full Code Here

        XMLReader reader = factory.newSAXParser().getXMLReader();
        XMLParser parser = new XMLParser( reader );
        parser.setContext( context );
        parser.setClassLoader( context.getClassLoader() );

        Script script = null;

        InputSource source = null;
        if ( encoding != null )
        {
            InputStreamReader isr = null;
            try
            {
                isr = new InputStreamReader( scriptInputStream, encoding );
                source = new InputSource( isr );

            }
            finally
            {
                if ( isr != null )
                {
                    try
                    {
                        isr.close();
                    }
                    catch ( IOException e )
                    {
                        log.debug( "WARNING: Cannot close stream!", e );
                    }
                    isr = null;
                }
            }

        }
        else
        {
            source = new InputSource( scriptInputStream );
        }

        if ( systemId != null )
        {
            source.setSystemId( systemId );
        }
        if ( log.isDebugEnabled() )
            log.debug( "the system identifier to help resolve relative URLs : " + systemId );
        script = parser.parse( source );

        script = script.compile();

        return script;
    }
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.