You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Geir Magnusson Jr." <ge...@optonline.net> on 2001/01/03 08:36:07 UTC

Context Changes

All context changes are committed.  Tonights tarball should have all the
changes.  If something is broken, shout immediately (or fix it), and go
to the previous tarball if you didn't backup.

Summary
-------
There should be no [real] fundamental functional changes.  The changes
are in organization, class naming, structure and implementation.  Other
than the new chaining feature, the functionality should be identical. 
Everything tests out well in the testbed, it runs at the same speed,
etc.

For users with their own applications :

The context implementation class changed from
  
   org.apache.velocity.Context

to  

  org.apache.velocity.VelocityContext;

For everyone, app users as well as servlet users that derive from
VelocityServlet, there is still an interface called Context, and if you
have an API that loads, examines or uses the context (like Generator in
texen appears to, and the handleRequest() method for servlets), you can
leave Context in your method signatures as is and just make sure you
change the import statement from org.apache.velocity.Context to
org.apache.velocity.context.Context and all should be well.

What We Got
-----------
The biggest thing we get out of this is 'Chaining Contexts'.  See
previous list traffic for the discussion, but the upshot is that you can
take a context, make a new one around it, and everything in the 1st
context is visible via the get() method of the new one, as long as the
new one doesn't 'mask' the object with it's own.  Some of the final
details regarding how these work, and the spec on dealing with null keys
and values, are still in discussion, but this will be incredibly
useful.  The testbed tests the chaining context mechanism, so if you
want to see it in action, there's the place to go.  something like
src/java/org/apache/velocity/test/TemplateTestCase.java

Another thing we get is the ability to make our own context
implementations, if you are so possessed.  The provided VelocityContext
impl should be adequate for most needs, but if you want to, you now
can.  There are a few examples now in the examples directory, including
one that utilizies a TreeMap for the storage mechanism, and one that
uses a MySQL DB for the storage mechanism in the context.  These are
unsupported and for demonstration purposes only.  

And there's more, but more on this later tomorrow. :)

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity