Springs Interceptors

using springs' Method Interceptors i have made a class named Logging Interceptor that interceps all the methods that are called ..

the code is ..

public class LoggingInterceptor implements MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice

{

private static Log log = null;

public LoggingInterceptor()

{}

public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable

{

log = LogFactory.getLog(arg2.getClass());

log.info("Beginning method: "+arg0.getName());

}

public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object arg3) throws Throwable

{

log = LogFactory.getLog(arg3.getClass());

log.info("Ending method: "+arg1.getName());

}

public void afterThrowing(Method m, Object[] args, Object target, Throwable ex)

{

log = LogFactory.getLog(target.getClass());

log.info("Exception in method: "+m.getName()+" Exception is: "+ex.getMessage());

}

}

actually the code is going very fine but i need to know the values of the parameters being passed in the functions. If the parameter is an object, all the values within that object should be retrieved and displayed.

thanks a ton

[1260 byte] By [gurpreet.sainia] at [2007-11-27 11:04:11]
# 1

That second argument - the Object[] - that contains the arguments passed into the method you're intercepting

georgemca at 2007-7-29 12:56:21 > top of Java-index,Java Essentials,Java Programming...
# 2

You are absolutely right ..

But my concern is that when the method is called i need to get the values that have been passed to the function.

gurpreet.sainia at 2007-7-29 12:56:21 > top of Java-index,Java Essentials,Java Programming...
# 3

> You are absolutely right ..

> But my concern is that when the method is called i

> need to get the values that have been passed to the

> function.

And in what way did my reply not address that?

georgemca at 2007-7-29 12:56:21 > top of Java-index,Java Essentials,Java Programming...
# 4

Actually the array that the second argument is providing is of the type Object and that contains the whole object and not what is contained in that. I need the "values" of the arguments not their "types"

gurpreet.sainia at 2007-7-29 12:56:21 > top of Java-index,Java Essentials,Java Programming...
# 5

> Actually the array that the second argument is

> providing is of the type Object and that contains the

> whole object and not what is contained in that. I

> need the "values" of the arguments not their "types"

My first reply still applies, regardless. You seem confused about something, what is it you don't understand?

georgemca at 2007-7-29 12:56:21 > top of Java-index,Java Essentials,Java Programming...
# 6

ok ..

just tell me if i iterate the object array in the function itself and need to print the values that the object contain, how can i do that?

gurpreet.sainia at 2007-7-29 12:56:21 > top of Java-index,Java Essentials,Java Programming...
# 7

Jebus wept!

Cya later buddy, good luck with this. I don't have the patience to keep repeating myself

georgemca at 2007-7-29 12:56:21 > top of Java-index,Java Essentials,Java Programming...
# 8

> just tell me if i iterate the object array in the

> function itself and need to print the values that the

> object contain, how can i do that?

for (Object o : args) {

System.out.println(o);

}

~

yawmarka at 2007-7-29 12:56:21 > top of Java-index,Java Essentials,Java Programming...