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

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

java.lang.Math seems like a good enough general example.  At least, everyone 
knows it and its static nature, so the problem is apparent.  Though i'm not 
entirely sure how Adrian intends to do this, I don't think this is likely to 
take more code than something along the lines of Jim Seach's tweak to 
UberspectImpl.getMethod above (just fixed to maintain backwards compatibility). 
  Seems like a pretty small code effort (new docs and tests aside) for a 
feature that appears sufficiently desired by people.  As long as someone who 
wants it does the work, i have no problem with the basic idea.  I only object 
to the "automatic names" idea, as that does open up new complications and 
implies a change to Context (a very public interface).

> 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