Mike Kienenberger wrote:
Well, the easy answer to this part of the question is to implement a custom Uberspect.

http://jakarta.apache.org/velocity/api/org/apache/velocity/util/introspection/Uberspect.html

There's examples of this on the wiki:

http://wiki.apache.org/jakarta-velocity/MultiUberspect
http://wiki.apache.org/jakarta-velocity/LuceneDocumentUberspect

Thanks, I'll take a look.

or otherwise a way to make these POJOs immutable?

Outside of the scope of velocity, but really the heart of the problem even with a custom Uberspect.
At some point you either need to enumerate all objects you want to be immutable (or mutable), or you need to only stick immutable objects into the context. Personally, I think the second method is easier and safer.


Why don't you stick your POJOs into the template as a wrapper object (delegate), with only the getter methods exposed?

Yes, I was looking for something more like this. I know this is tangential to Velocity, but figured it might be something others had faced when trying to restrict what template authors could do.


I was looking to extend VelocityContext to add a putImmutable(key, object) method. This would create an AOP-style proxy object that will fail on any set method but otherwise just hand calls to the underlying POJO. Probably something CGLIB could do for me.

--
Serge Knystautas
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to