velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Perfect Tao" <Perfe...@HZ.WebEx.com>
Subject RE: need implement like AOP
Date Fri, 01 Apr 2005 02:13:00 GMT

Hi Christian

Thank you very much , I will compare blue print  your give me .
Where is o.a.v.util.introspection.UberspectImpl ?
I think the next version Velocity maybe enhance the inject function 
Now AOP is very fashionable. :@)
 
 
Best Regards
Perfect Tao
Email: perfectt@hz.webex.com
Yahoo Messeger ID: perfect_tao
Skype ID :perfect_tao
====================================
   The doors of wisdom are never shut.  
=====================================

-----Original Message-----
From: Simon Christian [mailto:simon@stoutstick.com] 
Sent: 2005年3月31日 19:55
To: Velocity Users List
Subject: Re: need implement like AOP

Hi Tao,

I don't think there's an easy way to do this, though there are a few 
avenues to explore:

1. Look at the EventCartridge & EventHandlers, specifically implementing 
o.a.v.app.event.ReferenceInsertionEventHandler would allow you to do 
*something* just before the value is put into the template (I realise 
this isn't quite what you want to do).

Chapter 9 at: http://jakarta.apache.org/velocity/developer-guide.html


2. This would be the best way: implement your own introspector, probably 
  extending o.a.v.util.introspection.UberspectImpl and wrapping the 
calls to that implementation. I'd imagine others would be interested in 
your results if you did choose this approach.


3. The hack approach: wrap all your getXXX calls in a macro which does 
something either side of the call. Something along the lines of:

#macro( doAOPGet $object $variableName )
.. your pre-get stuff here
$object.get( "$variableName" )
.. your post-get stuff here
#end


Hope I'm not too far off the target - not yet gotten into AOP so not 
really sure what you might typically want to achieve!

- simon


Perfect Tao wrote:
> Hi Velocity fans
>  
> I have a question of Velocity 
> 
> I need a function:
> It is exec a especial method before or after exec every getXXX() when  merge template
> 
> Like AOP function.
> 
> How implement it?. Or tell me idea. I wrote code by your idea. ☺
> 
> 
>  
>  
> Thank you
>  
>  
> Best Regards
> Perfect Tao
> Email: perfectt@hz.webex.com
> Yahoo Messeger ID: perfect_tao
> Skype ID :perfect_tao
> ====================================
>    The doors of wisdom are never shut.  
> ====================================

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


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


Mime
View raw message