import java.security.Principal;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import javax.security.auth.Subject;
import javax.servlet.Filter;
/**
* Cache every object for which we are creating method on it.
*/
- private static HashMap<Object,Method[]> objectCache =
- new HashMap<Object,Method[]>();
+ private static final Map<Object,Method[]> objectCache =
+ new ConcurrentHashMap<Object,Method[]>();
private static final org.apache.juli.logging.Log log=
org.apache.juli.logging.LogFactory.getLog( SecurityUtil.class );
throws java.lang.Exception{
Method method = null;
- Method[] methodsCache = null;
- if(objectCache.containsKey(targetObject)){
- methodsCache = objectCache.get(targetObject);
+ Method[] methodsCache = objectCache.get(targetObject);
+ if(methodsCache == null) {
+ method = createMethodAndCacheIt(methodsCache,
+ methodName,
+ targetObject,
+ targetType);
+ } else {
method = findMethod(methodsCache, methodName);
- if (method == null){
+ if (method == null) {
method = createMethodAndCacheIt(methodsCache,
methodName,
targetObject,
targetType);
}
- } else {
- method = createMethodAndCacheIt(methodsCache,
- methodName,
- targetObject,
- targetType);
}
execute(method, targetObject, targetArguments, principal);
final Object[] targetArguments,
Principal principal)
throws java.lang.Exception{
+
Method method = null;
-
- Method[] methodsCache = null;
- if(objectCache.containsKey(targetObject)){
- methodsCache = objectCache.get(targetObject);
+ Method[] methodsCache = objectCache.get(targetObject);
+ if(methodsCache == null) {
+ method = createMethodAndCacheIt(methodsCache,
+ methodName,
+ targetObject,
+ targetType);
+ } else {
method = findMethod(methodsCache, methodName);
- if (method == null){
+ if (method == null) {
method = createMethodAndCacheIt(methodsCache,
methodName,
targetObject,
targetType);
}
- } else {
- method = createMethodAndCacheIt(methodsCache,
- methodName,
- targetObject,
- targetType);
}
execute(method, targetObject, targetArguments, principal);
Subject subject = null;
PrivilegedExceptionAction<Void> pea =
new PrivilegedExceptionAction<Void>(){
+ @Override
public Void run() throws Exception{
method.invoke(targetObject, targetArguments);
return null;