Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Dynamic type casting

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;
    }
}
================================================



Back to the top