You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Claude Brisson (JIRA)" <ji...@apache.org> on 2016/07/21 18:16:20 UTC

[jira] [Closed] (VELOCITY-831) Chained contexts do not expose static classes from the contexts being chained

     [ https://issues.apache.org/jira/browse/VELOCITY-831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claude Brisson closed VELOCITY-831.
-----------------------------------
       Resolution: Cannot Reproduce
         Assignee: Claude Brisson
    Fix Version/s: 1.7.x

I cannot reproduce your problem, event with Velocity 1.7. Please reopen with additional details, or a complete minimal test case.

> Chained contexts do not expose static classes from the contexts being chained
> -----------------------------------------------------------------------------
>
>                 Key: VELOCITY-831
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-831
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.7.x
>            Reporter: Steve O'Hara
>            Assignee: Claude Brisson
>            Priority: Minor
>             Fix For: 1.7.x
>
>
> As a performance improvement, I decided to put all our static context objects into a context that would be the basis of all new contexts e.g.
>     private static Context chainedContext;
>     static {
>         chainedContext = Z_getDefaultVelocityContext();
>     }
>     private static Context Z_getDefaultVelocityContext() {
>         Context context = new VelocityContext();
>         context.put("TmpDir", Common.getTemporaryDirectory());
>         context.put("math", new MathTool());
>         context.put("number", new NumberTool());
>         context.put("sort", new SortTool());
>         context.put("LSQUARE_CHAR", '[');
>         context.put("RSQUARE_CHAR", ']');
>         context.put("LCURLY_CHAR", '{');
>         context.put("RCURLY_CHAR", '}');
>         context.put("DOT_CHAR", '.');
>         context.put("NEWLINE", '\n');
>         context.put("HASH", '#');
>         context.put("DOLLAR", '$');
>         context.put("DQUOTE", '"');
>         context.put("Utils", Common.class);
>         return context;
>     }
>     public static Context getVelocityContext(boolean runtimeMode) {
>         Context context = new VelocityContext(chainedContext);
>         context.put("Context", context);
>         return context;
>     }
> The problem is that in this configuration, $Utils is not available in the scripts.
> All the other instantiated objects are OK.  Works fine of course if the static class is added to each outer context.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org