1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 08:52:51 +00:00

JUnit test fixes

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-26 20:28:02 -03:00
parent a162b9d6d5
commit 81dea2def4
11 changed files with 233 additions and 250 deletions

View File

@@ -17,6 +17,7 @@
package com.l2jserver.service.cache;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
@@ -75,12 +76,21 @@ public class EhCacheService extends AbstractService implements CacheService {
return method.invoke(instance, args);
final MethodInvocation invocation = new MethodInvocation(
method, args);
Object result = interfaceCache.get(invocation)
.getObjectValue();
if (result == null) {
result = method.invoke(instance, args);
interfaceCache.put(new Element(invocation, result));
}
Element element = interfaceCache.get(invocation);
if (element == null)
return doInvoke(invocation, proxy, method, args);
Object result = element.getObjectValue();
if (result == null)
return doInvoke(invocation, proxy, method, args);
return result;
}
private Object doInvoke(MethodInvocation invocation,
Object proxy, Method method, Object[] args)
throws IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
Object result = method.invoke(instance, args);
interfaceCache.put(new Element(invocation, result));
return result;
}
});