[
https://issues.apache.org/jira/browse/VELOCITY-102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12623022#action_12623022
]
Adrian Tarau commented on VELOCITY-102:
---------------------------------------
Christopher,
I agree java.lang.Math was not a good example for what I was trying to explain,
anyway on second thought letting the user to choose the name is more
appropriate. Sometime it is good to enforce users to follow a specific path,
but this one is not the right case.
So I will go with context.put(String, Class) and we will so how it goes after
first implementation.
> Add Support for Static Utility Classes
> --------------------------------------
>
> Key: VELOCITY-102
> URL: https://issues.apache.org/jira/browse/VELOCITY-102
> Project: Velocity
> Issue Type: Improvement
> Components: Engine
> Affects Versions: 1.3-rc1
> Environment: Operating System: All
> Platform: All
> Reporter: Juozas Baliuka
> Priority: Minor
> Fix For: 1.6
>
>
> Support for Static Utility Classes is:
> 1) define namespaces
>
> context.defineNamespace("Math").add( java.lang.Math.class ) ;
> used as $Math.sin(0)
> 2) Add / Replace / remove methods in namespace :
>
> context.getNamespace("Math").add(MyRandom.class.getMethod("randomString",new
> Class[]{int.class}))
> used as $Math.randomString(12)
> 3) "union" on namespaces
> context.defineNamespace("Utils")
> .add(context.getNamespace("Math"))
> .add(context.defineNamespace("Collections",Collections.class ) );
> used as:
> $Utils.sin(0)
> $Utils.sort($list)
> 4) Global namespace
> context.getGlobalNamespace().add( Math.class );
> used as $sin(0)
> 5) inline namespaces:
> #use java.lang.Math as Math
> $Math.sin(0)
> #end
> #with Math
> $sin(0)
> #end
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]