[ 
https://issues.apache.org/jira/browse/VELOCITY-102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12622894#action_12622894
 ] 

Nathan Bubna commented on VELOCITY-102:
---------------------------------------

I also liked context.put("math", Math.class).   I'm not sure what you mean by 
scanning instances for static classes, but public static field support is 
another conversation and an old one at that.  I'm open to it, but let's save it 
for another bug. :)

Anyway, i think if you are going to implement this, then you should go on 
whichever path you prefer.  "Them that do the work make the decisions", as they 
say.  Do what seems best to you.

> 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]

Reply via email to