Find target domain object argument in a manner that works if nulls are presented for the domain object argument.

This commit is contained in:
Ben Alex 2004-12-03 06:43:17 +00:00
parent e75fc613b1
commit 07e2037251
1 changed files with 10 additions and 12 deletions

View File

@ -330,13 +330,14 @@ public class BasicAclEntryVoter implements AccessDecisionVoter,
}
private Object getDomainObjectInstance(Object secureObject) {
if (secureObject instanceof MethodInvocation) {
MethodInvocation invocation = (MethodInvocation) secureObject;
for (int i = 0; i < invocation.getArguments().length; i++) {
Class argClass = invocation.getArguments()[i].getClass();
// Check if this MethodInvocation provides the required argument
Method method = invocation.getMethod();
Class[] params = method.getParameterTypes();
if (processDomainObjectClass.isAssignableFrom(argClass)) {
for (int i = 0; i < params.length; i++) {
if (processDomainObjectClass.isAssignableFrom(params[i])) {
return invocation.getArguments()[i];
}
}
@ -345,7 +346,4 @@ public class BasicAclEntryVoter implements AccessDecisionVoter,
+ invocation + " did not provide any argument of type: "
+ processDomainObjectClass);
}
return null; // should never happen
}
}