Sorry, my previous mail was missing the question. Here are the full
details with the question:
Please see the question in the
end.
==============MyAspect.java==================== public aspect
MyAspect {
Object around() : execution(* *.load(..)) {
Object receiver = thisJoinPoint.getThis(); String className =
receiver.getClass().getName(); Object[] args =
getArguments(thisJoinPoint); System.out.println("Class:" + className +
"::ARGS:" + args);
Object returnValue =
myapp.PersistenceHandler.load(className, args); /* Here I get common Object,
but the Object is 'className' type. */ return
returnValue; }
private Object[] getArguments(JoinPoint
jp) { Object[] argumentValues = jp.getArgs();
return
argumentValues; } } ===============================================
================Class
A========================= public class A {
public
A load(int id) { // no
implementation return
null;
} } ================================================
================Class
B========================= public class B {
public
B load(int id) { // no
implementation return
null;
} } ===============================================
When I
replace the load() method in 2 classes A & B with my aspect, the advice
is returning the common Object. But the classes A & B should return their
respective type object.
how can I type caste the Object to its original
class in my aspect like this:
Object returnValue =
myapp.PersistenceHandler.load(className, args); return (className)
returnValue; /* Here className is the variable for the class name
*/
[I think it is not possible with JAVA. Is it possible with
AspectJ?]
Thanks in advance! Venkat
|