You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Guo, Jiaqi" <ji...@gmail.com> on 2005/08/02 20:06:16 UTC
[jelly] Can I get the unique ID for current TagScript
When I'm in a home-made Tag class, can I get a unique identifier for the
current TagScript? So that next time the same tag in the same script is
invoked, I know it's the same thing. Therefore, if I want to cache
something I can do it.
I can't take MyTag.hashCode() because Tag is transient object in my
case. Can I do MyTag.getBody().hashCode()? It doesn't sound well for
those tags without body.
Any solution for it? Thanks.
Jiaqi
jiaqi.guo@gmail.com
http://www.cyclopsgroup.com
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [jelly] Can I get the unique ID for current TagScript
Posted by Paul Libbrecht <pa...@activemath.org>.
Jiaqi,
Why do you need a new context every-time ?
Why not set to null (that is erase) all the variables you know are
created ?
Do I understand currently that you wish that tags were cached just
like... it's happening in jelly 1.0 if you keep the thread and
context...
We've been discussing this on commons-dev recently and the default is
now, back, to not cache, that is, to re-create the tag object at each
start-of-run of the tag-script. This can be changed in
JellyContext.setCacheTags(true)...
However, there's nothing with parent contexts in this caching scenario
currently and, as I understand, this is what you would wish, correct ?
That is, you'd wish that tag-caching only happens at root context...
I fear you'll have to adapt TagScript for this yourself.
But as this is our current discussion I would invite you to make this
adaptation in the following way: your tags have a special way to
request caching, namely, they want it at the parent-context (or
root-context?)... so they should be flagged as such. I would suggest to
make an interface such as ReusableTagsForRootContext and let
TagScript's tag-caching routines filter on that.
hope that helps.
paul
PS: the keys to the tag-caches are... the script-objects themselves...
no verbatim id down here... we never thought about such...
Le 4 août 05, à 17:47, Guo, Jiaqi a écrit :
> If I can assume that the creating each course doesn't need context, I
> actually know the full course list after the first time this script
> runs. If I can cache the course list somewhere in TagScript, I don't
> need to create 103 courses again and again. Because <Courses> tag can
> be used somewhere else in this script, I need a key to identify this
> guy. I can't simply save the list in CourseTag class because tag class
> is transient. Another option is forcing script writer to put an id
> attribute. But internal key makes it look simpler.
>
> So my question is can I get unique ID for TagScript where I'm in
> corresponding Tag class.
>
> Let me know if I didn't explain the question clearly. Thanks for your
> time.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [jelly] Can I get the unique ID for current TagScript
Posted by "Guo, Jiaqi" <ji...@gmail.com>.
Hi Hans,
Sorry for late response.
Here's scenario where the same Script runs again and again with
different context. So I keep the Script object and run it with fresh new
JellyContexts which have the same parent JellyContext so that I don't
need to register all the home made tag libraries repeatedly. But
sometimes, the logic executed in MyTag doesn't depend on context at all.
Give you an example which is not the exact one that I'm working on.
<mylib:Courses var="allCourses"> <!--Create a list variable-->
<mylib:CourseOperationSystem/> <!-- Add courses to allCourse
variable one by one-->
<mylib:CourseCompilerConstruction/>
<mylib:CourseAdvancedSoftwareEngineering/>
... another 100 courses...
</mylib:Courses>
<echo>Student ${student} want to take all courses</echo>
<!--student comes from context, it could be different every time the
script runs -->
<mylib:TakeCourses student="${student}" courses="${allCourses}"/>
--------------------------
JellyContext rootContext = new JellyContext();
rootContext.registerTagLibrary("my taglib uri", new MyTagLibrary());
Script script = rootContext.compileScript(theScriptFile);
JellyContext jc = new JellyContext(rootContext);
jc.setVariable("student", "John");
script.run(jc, output);
jc = new JellyContext(rootContext);
jc.setVariable("student", "Tommy");
script.run(jc, output);
...
If I can assume that the creating each course doesn't need context, I
actually know the full course list after the first time this script
runs. If I can cache the course list somewhere in TagScript, I don't
need to create 103 courses again and again. Because <Courses> tag can be
used somewhere else in this script, I need a key to identify this guy. I
can't simply save the list in CourseTag class because tag class is
transient. Another option is forcing script writer to put an id
attribute. But internal key makes it look simpler.
So my question is can I get unique ID for TagScript where I'm in
corresponding Tag class.
Let me know if I didn't explain the question clearly. Thanks for your time.
Regards
Jiaqi
Hans Gilde wrote:
>Well, this doesn't sound like a good thing to be doing. Could you describe
>the purpose, maybe there is another approach?
>
>-----Original Message-----
>From: Guo, Jiaqi [mailto:jiaqi.guo@gmail.com]
>Sent: Tuesday, August 02, 2005 2:06 PM
>To: commons-user@jakarta.apache.org
>Subject: [jelly] Can I get the unique ID for current TagScript
>
>When I'm in a home-made Tag class, can I get a unique identifier for the
>current TagScript? So that next time the same tag in the same script is
>invoked, I know it's the same thing. Therefore, if I want to cache
>something I can do it.
>
>I can't take MyTag.hashCode() because Tag is transient object in my
>case. Can I do MyTag.getBody().hashCode()? It doesn't sound well for
>those tags without body.
>
>Any solution for it? Thanks.
>
>
>
>Jiaqi
>
>jiaqi.guo@gmail.com
>http://www.cyclopsgroup.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [jelly] Can I get the unique ID for current TagScript
Posted by Hans Gilde <hg...@optonline.net>.
Well, this doesn't sound like a good thing to be doing. Could you describe
the purpose, maybe there is another approach?
-----Original Message-----
From: Guo, Jiaqi [mailto:jiaqi.guo@gmail.com]
Sent: Tuesday, August 02, 2005 2:06 PM
To: commons-user@jakarta.apache.org
Subject: [jelly] Can I get the unique ID for current TagScript
When I'm in a home-made Tag class, can I get a unique identifier for the
current TagScript? So that next time the same tag in the same script is
invoked, I know it's the same thing. Therefore, if I want to cache
something I can do it.
I can't take MyTag.hashCode() because Tag is transient object in my
case. Can I do MyTag.getBody().hashCode()? It doesn't sound well for
those tags without body.
Any solution for it? Thanks.
Jiaqi
jiaqi.guo@gmail.com
http://www.cyclopsgroup.com
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: Commons Configuration Ant Task(s)
Posted by Oliver Heger <ol...@t-online.de>.
Hello,
Moran Ben-David wrote:
>Hi all,
>
>Recently I produced an ant extension to Commons Configuration:
>
>http://www.place-base.com/commons-configuration-ant.html
>
>this allows me to load from a Commmons Configuration properties file (i.e.
>one that allows "include" and loaded via the PropertiesConfiguration class).
>
>
I had a short glance. Looks interesting.
>However, it is an extremely rudimentary implementation, so my questions are:
>
>1. Is there a package that provides Ant tasks that call Commons
>Configuration features that any of you know of?
>
>
In our code base we have nothing like that. And I am not aware of other
implementations.
>2. Would the proper namespace for such a package be
>org.apache.commons.configuration.ant?
>
>
I think this depends: If the package was part of commons-configuration,
this name would be appropriate. If it was part of a different code base,
this code base's conventions should be used.
>3. Is there such a package in the works for Commons Configuration?
>
>
No, we don't have plans for such a package yet.
>4. Is this the right list to discuss such bridges between commons-conf and
>ant?
>
>
For the configuration side yes (this list or the commons-dev list if
discussion drifts to technical details). But thinking about it, what you
suggest seems to be an enhancement for ant rather than one for
commons-configuration, right? So maybe you should check out the ant
mailing lists.
>Thanks,
>Moran Ben-David
>
>
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Commons Configuration Ant Task(s)
Posted by Moran Ben-David <mo...@place-base.com>.
Hi all,
Recently I produced an ant extension to Commons Configuration:
http://www.place-base.com/commons-configuration-ant.html
this allows me to load from a Commmons Configuration properties file (i.e.
one that allows "include" and loaded via the PropertiesConfiguration class).
However, it is an extremely rudimentary implementation, so my questions are:
1. Is there a package that provides Ant tasks that call Commons
Configuration features that any of you know of?
2. Would the proper namespace for such a package be
org.apache.commons.configuration.ant?
3. Is there such a package in the works for Commons Configuration?
4. Is this the right list to discuss such bridges between commons-conf and
ant?
Thanks,
Moran Ben-David
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org