You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Vinay Chandran <sa...@yahoo.com> on 2002/09/01 03:22:49 UTC

Re: [Jelly][Submit]A Jelly Servlet

Hi,
I agree that we need NOT have a "compiled script"
mechanism in case of serving 
jelly scripts through servlets, we can do well with a
in-RAM cache.

BTW, I ran into a silly problem with jsl taglibs (code
snippet attached)
I am running the Script obj that one obtains in a
loop.
The output appears as expected the 1st  time , 
but then onwards the stylesheets doesn't seem to work 
on the XML document.
(Hope that I aint doing anything wrong here)
Regards,
Vinay

/*** Snippet Begins ***/

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;

import org.apache.commons.jelly.Jelly;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput;

/**
 * testing repeated executing of Script
 * 
 * @author <a href="mailto:vinayc@apache.org">Vinay
Chandran</a>
 */
public class TestJSL
{
    public static void main(String[] args) throws
Exception
    {
        Jelly jelly = new Jelly();
       
jelly.setScript("src/test/org/apache/commons/jelly/jsl/example.jelly");
        Script script = jelly.compileScript();
        JellyContext context=new JellyContext();
        for (int i = 0; i < 3; i++)
        {
            ByteArrayOutputStream baos = new
ByteArrayOutputStream();
            XMLOutput out =
XMLOutput.createXMLOutput(baos);
            script.run(context, out);
            out.flush();
            System.out.println(i + ":" +
baos.toString());

        }
    }
}

/*** Snippet Ends***/
--- James Strachan <ja...@yahoo.co.uk> wrote:
> From: "James Elson" <ja...@xini.com>
> > Quoting Vinay Chandran <sa...@yahoo.com>:
> >
> > > Once we can somehow manage to externalize the
> state
> > > of the Script obj into a file(store) we can
> > > very well have a scenario whereby we can
> distribute
> > > compiled-scripts too.(thoughts?)
> >
> > Is it really that necessary? I agree that you
> wouldn't want to
> parse/compile the
> > Jelly script each time you request a page, but it
> seems like a bit of
> overhead
> > to compile them and keep them stored on disk.
> Wouldn't it be better to
> keep a
> > cache of compiled Script objects in memory (maybe
> with a limit of the
> number,
> > throwing away the least recently used). Suppose it
> depends on the
> complexity and
> > size of the scripts.
> 
> Agreed. I think serializing them is a bit over the
> top, they are fairly
> lightweight to parse anyways.
> 
> 
> > I'd like to use Jelly scripts rather like JSP in
> that an update to the
> .jelly
> > file on disk would still be picked up immediately
> (without any of the
> nasty JSP
> > classloader issues!). A simple cache that checks
> the timestamp of the file
> > against a cached version before re-parsing should
> do.
> 
> Agreed. I guess much of all this has been done in
> Velocity, it might be
> possible to share code somehow, or at least avoid
> reinventing the wheel.
> 
> 
> > What's the performance diffence between parsing a
> Jelly script from disk
> and
> > deserializing a Script object?
> >
> > Not sure why you'd want to distrubute compiled
> scripts rather than the XML
> > source though.
> 
> Agreed. I think just having a RAM cache is all we
> need for now.
> 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> __________________________________________________
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>