Good point... sometimes I don't see obvious things...
Tanks,
Richard

2009/3/16 Cosmin Marginean <[email protected]>:
> When it comes to the whole request, I guess you can put a filter on top
> of all the filters to handle this so you don't necessarily need a
> Stripes facility for this.
>
> Regards,
> Cosmin
>> Hello list,
>> I need to write an interceptor to log the execution time for a
>> request. Nothing's more easy than that - I thought. Just intercept the
>> most low level Stage, execute the others stages in between and then
>> log the time. But i didn't find a way to intercept the whole request.
>> What I've done so far is this interceptor:
>> @Intercepts(
>> {
>>       LifecycleStage.RequestInit,
>>       LifecycleStage.ActionBeanResolution,
>>       LifecycleStage.HandlerResolution,
>>       LifecycleStage.BindingAndValidation,
>>       LifecycleStage.CustomValidation,
>>       LifecycleStage.EventHandling,
>>       LifecycleStage.ResolutionExecution,
>>       LifecycleStage.RequestComplete })
>> public class CallTimeInterceptor implements Interceptor {
>>       private static final Logger logger =
>> Logger.getLogger(CallTimeInterceptor.class);
>>       private static final String FORMAT_STRING = "Call to {0}, stage {1}
>> took {2}ms";
>>
>>       public Resolution intercept(ExecutionContext context) throws Exception 
>> {
>>               if (logger.isInfoEnabled()) {
>>                       long nanoTime = System.nanoTime();
>>                       Resolution proceed = context.proceed();
>>                       logger.info(MessageFormat.format(FORMAT_STRING,
>> context.getActionBeanContext().getRequest().getRequestURL(), context
>>                                       .getLifecycleStage(), 
>> Double.valueOf(System.nanoTime() -
>> nanoTime) / 1000000.0));
>>                       return proceed;
>>               } else
>>                       return context.proceed();
>>       }
>> }
>>
>> This creates the following logEntries:
>> [ INFO] 10:25:26 ....controllers.interceptors.CallTimeInterceptor:31 -
>> Call to http://127.0.0.1:8080/dwhfe/pub/Authentication.htm, stage
>> RequestInit took 0,103ms
>> [ INFO] 10:25:27 ...controllers.interceptors.CallTimeInterceptor:31 -
>> Call to http://127.0.0.1:8080/dwhfe/pub/Authentication.htm, stage
>> ActionBeanResolution took 506,321ms
>> [ INFO] 10:25:27 ...controllers.interceptors.CallTimeInterceptor:31 -
>> Call to http://127.0.0.1:8080/dwhfe/pub/Authentication.htm, stage
>> HandlerResolution took 3,613ms
>> [ INFO] 10:25:27 ...controllers.interceptors.CallTimeInterceptor:31 -
>> Call to http://127.0.0.1:8080/dwhfe/pub/Authentication.htm, stage
>> BindingAndValidation took 0,013ms
>> [ INFO] 10:25:27 ...controllers.interceptors.CallTimeInterceptor:31 -
>> Call to http://127.0.0.1:8080/dwhfe/pub/Authentication.htm, stage
>> EventHandling took 3,761ms
>> [ INFO] 10:25:27 ...controllers.interceptors.CallTimeInterceptor:31 -
>> Call to http://127.0.0.1:8080/dwhfe/pub/Authentication.htm, stage
>> ResolutionExecution took 467,878ms
>> [ INFO] 10:25:27 ...controllers.interceptors.CallTimeInterceptor:31 -
>> Call to http://127.0.0.1:8080/dwhfe/pub/Authentication.htm, stage
>> RequestComplete took 0,013ms
>>
>> I googled around but didn't find a way to configure the interceptor in
>> a way, that it encapsulates the whole call, not only the single
>> stages. Of course I could write the startTime into the request in life
>> cycle RequestInit and read it out in RequestComplete but I'm scared of
>> the possible performance hit. So is there a way to do this?
>>
>> Thanks for your time,
>> Richard
>>
>> ------------------------------------------------------------------------------
>> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
>> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
>> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
>> software that enables intelligent coding and step-through debugging.
>> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
>> _______________________________________________
>> Stripes-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to