You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Michal Chmielewski <me...@liquid.net> on 2002/11/27 18:35:06 UTC

Contexts and Profiling

Clear DayThe velocity context is map of keys to objects. These objects have
methods and are possibly of quite varying complexity and are in fact the
only "contract" between the code that prepares them for the template and the
actual template.

Anyone written a tool/template that could be used as an initial template
that would show:

  - all the context objects in the current context/parent context
  - print out their public interfaces (ie. what the methods/fields are
available to reference)
  - allow for integration of this with javadoc or source browser.

I am not talking here about an editor plugin of some sort, just a template
that would dump out the current context and pretty print the
objects/methods/fields of the context objects.

The other topic is profiling. Does Velocity have anything like this ?

-michal




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


Re: Contexts and Profiling

Posted by Ch...@dlr.de.
I have created a context dump tool. See attachment.
I use a layout approach like turbine and the layout template does:

#if( $debug )
   #parse( "dump.vm" )
#end

The debug flag is passed in as a query parameter and then cached in the
session attributes. This way I just have to switch on debugging and see
the dump attached to every page:
## ------------------------------------------------------------------------
## Decode dubug flag state
## ------------------------------------------------------------------------
## and save debug flag in session (not in the query string)
## get the debug flag state from the session (false is the default)
#set( $debug = false )
#set( $debug = $!app.get("debug") )
#if( !$debug )
   #set( $debug = false )
#end
## overlay the debug flag with possible value from the QueryString
#set( $debug = $parameters.getBoolean("debug", $debug) )
## promote the state into the session
#call( $app.put("debug", $debug) )
##

This has worked nice for me. Some improvements are possile:
* Add a #context directive to put the current context into the context
   for dumping
* Add additional flags to tell the dumper to dump a specific object
   content or its API.
* Output other formats... (I got a version for plain text)

Cheers,
Christoph

Michal Chmielewski wrote:
> Clear DayThe velocity context is map of keys to objects. These objects have
> methods and are possibly of quite varying complexity and are in fact the
> only "contract" between the code that prepares them for the template and the
> actual template.
> 
> Anyone written a tool/template that could be used as an initial template
> that would show:
> 
>   - all the context objects in the current context/parent context
>   - print out their public interfaces (ie. what the methods/fields are
> available to reference)
>   - allow for integration of this with javadoc or source browser.
> 
> I am not talking here about an editor plugin of some sort, just a template
> that would dump out the current context and pretty print the
> objects/methods/fields of the context objects.
> 
> The other topic is profiling. Does Velocity have anything like this ?
> 
> -michal
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 

-- 
:) Christoph Reck