From 6fb74e661005757eca726f89ead3a584669a977d Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 24 Feb 2005 04:40:30 +0000 Subject: [PATCH] Allow an application to add things to the context before passing it on to the logic. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1595 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/velocity/Application.java | 10 ++++++++++ .../com/samskivert/velocity/DispatcherServlet.java | 3 +++ 2 files changed, 13 insertions(+) diff --git a/projects/samskivert/src/java/com/samskivert/velocity/Application.java b/projects/samskivert/src/java/com/samskivert/velocity/Application.java index 1713f271..e565b6bb 100644 --- a/projects/samskivert/src/java/com/samskivert/velocity/Application.java +++ b/projects/samskivert/src/java/com/samskivert/velocity/Application.java @@ -164,6 +164,16 @@ public class Application { } + /** + * Allows derived aplication classes to prepare an invocation context + * prior to the logic class being invoked. They may wish to add + * standard tools to the context or do any other request-invariant + * preparation. + */ + protected void prepareContext (InvocationContext ctx) + { + } + /** * This should be overridden by the application implementation to * perform any necessary cleanup. diff --git a/projects/samskivert/src/java/com/samskivert/velocity/DispatcherServlet.java b/projects/samskivert/src/java/com/samskivert/velocity/DispatcherServlet.java index 63430737..c8b66aab 100644 --- a/projects/samskivert/src/java/com/samskivert/velocity/DispatcherServlet.java +++ b/projects/samskivert/src/java/com/samskivert/velocity/DispatcherServlet.java @@ -334,6 +334,9 @@ public class DispatcherServlet extends VelocityServlet CurrencyTool ctool = new CurrencyTool(req); ictx.put(CURRENCYTOOL_KEY, ctool); + // allow the application to prepare the context + _app.prepareContext(ictx); + // resolve the appropriate logic class for this URI and // execute it if it exists String path = req.getServletPath();