On Apr 21, 2009, at 19:18 , Babak Farhang wrote:
> I'm tinkering with a java, non-blocking, HTTP server implementation
> and am considering tweaking Velocity (because of its
> container-agnostic design) so that I can use it's output in such an
> environment.
>
> Specifically, instead of having the Velocity Template "merge" its
> output to a Writer, I want to create a Template that "merges" output
> to something like a java.util.List<java.nio.ByteBuffer>.
>
> The purpose of this modified output would be to ultimately pass (it in
> the form of a ByteBuffer array) as the argument to a
> java.nio.channels.SocketChannel.write -- a non-blocking "gathering"
> operation.
>
> The idea with the java.util.List<java.nio.ByteBuffer> is that the
> content of some ByteBuffers will be dynamically generated; the
> contents of the rest would be static.
>
> So how to pull this off? The first place I considered hacking was the
> Template class itself (something like intercepting every ASTText
> instance's render method for static content and doing something else
> with the dynamic bits of content). Needless to say, this has a
> 'hacky' feel to it ;) And since I'm new to Velocity, I'm thinking
> maybe there's a more elegant approach.
I'm not sure why you need to hack Velocity for this. You can create
your own Writer that is wired up to do whatever you need, for example
write to a ByteBuffer. Then pass your custom Writer to the merge. Is
there any functionality that this approach wouldn't accommodate?
---------------------------------------------------------------------
To unsubscribe, e-mail:
user-unsubscribe@...
For additional commands, e-mail:
user-help@...