commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Albert Kwong <mandr...@yahoo.com>
Subject [PATCH] [Jelly] JellyServlet.java and JellyContext.java
Date Wed, 23 Apr 2003 10:20:24 GMT
Here's a patch that deals with the JellyServlet.  Hope
you guys find it useful.

    1. Make session and servlet context accessible
from the JellyContext.

    2. Flatten request, session and servlet context
attributes so that they are directly accessible from
the JellyContext. (e.g. ${user} == ${session.user})

    3. Used request.getServletPath() instead of
request.getPathInfo() to retrieve script URL, so that
the servlet can be associated with an extension in
web.xml (e.g. *.jel -> invokes JellyServlet).  This is
more consistent with the Struts and Velocity model.

    4. Fixed memory leakage in JellyServlet by caching
scripts in JellyContext.

    Before this fix, the JVM fails to gc the memory
allocated by JellyServlet, possibly due to some cross
references between the Script and Context objects.  By
caching scripts in JellyContext, an URL is compiled
into Script only once when it is accessed the first
time.  It fixes the memory leakage and at the same
time enhances performance.

    A side effect of this fix is that the servlet will
no longer load scripts automatically when they are
changed.  It may make Jelly script developers a little
unhappy ;)

    Alternatively, the script caching can be
implemented in JellyServlet, and the [cached] Script
object can be passed to the JellyContext via a public
runScript (Script, ...) method.  This alternative has
less impact on the JellyContext object's behavior.  I
have tried this strategy but somehow it isn't working,
so I gave up.

    Yet another alternative is to implement a
release() method in Script to clean up the mess after
it is done.  I haven't looked into this alternative
closely though. Personally I would like to retain the
performance enhancement through caching.

Albert

_________________________________________________________
我的驕傲(容祖兒),合久必婚(李克勤),下一站...天后(Twins)...
Yahoo! 鈴聲下載
http://ringtone.yahoo.com.hk
Mime
View raw message