Ideas Needed to insert Action execution time in DB !!
posted 6 years ago
I briefly explain here my requirement
After sending the response from my application i need to insert the Total action execution time along with some request parameters in DB i do so because Sending the response and insertion in DB should be asynchronous.
1. With the below code i am able to get the action execution time and the parameters passed to it.
How to fetch value of a variable which i have assigned in my action class ??
2. Timer interceptor just logs the time taken by the action is it possible to assign the Timetaken value to a variable ??
Getting an arbitrary property from an arbitrary action isn't possible without reflection, as far as I know. You have to know what methods you can call on an action in order to do it without reflection.
If you're always getting the *same* property from actions then you can create an interface with a getter for that property and have your actions implement that interface. The interceptor would then cast the action to that interface and call interface methods.
I suppose you could create an interface that returns a map, and set named properties in that map from within the action, if you need it to be totally general-purpose, but that entails more busywork in the actions.
Using a reflection helper could probably reduce the clutter in the interceptor to a line or two, I guess.
(Not very organized, but those are my initial thoughts :)