Object target = invocation.getTargetObject();
if (target instanceof Advised)
{
ClassAdvisor advisor = (ClassAdvisor)((Advised)target)._getAdvisor();
// We will have already gone through the interceptor chain so just invoke on the
// object.
return advisor.invoke(invocation);
}
else
{
if (invocation instanceof MethodInvocation)
{
// For non-advised methods, we can only do public method invocations
org.jboss.aop.joinpoint.MethodInvocation methodInvocation = (org.jboss.aop.joinpoint.MethodInvocation)invocation;
long methodHash = methodInvocation.getMethodHash();
HashMap methodMap = ClassProxyFactory.getMethodMap(target.getClass());
MethodPersistentReference ref = (MethodPersistentReference)methodMap.get(new Long(methodHash));
Method method = (Method)ref.get();
Object[] args = methodInvocation.getArguments();
try
{
return method.invoke(target, args);
}
catch (InvocationTargetException ex)
{
throw ex.getTargetException();
}
}
else
{
throw new RuntimeException("should only be METHOD invocations on a non-advised target object: " + invocation.getClass().getName());
}
}