|
|
|
@ -54,12 +54,15 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
throw new BeanInstantiationException(clazz, "Specified class is an interface"); |
|
|
|
throw new BeanInstantiationException(clazz, "Specified class is an interface"); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor>() { |
|
|
|
if (System.getSecurityManager() != null) { |
|
|
|
|
|
|
|
constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor>() { |
|
|
|
public Constructor run() throws Exception { |
|
|
|
public Constructor run() throws Exception { |
|
|
|
return clazz.getDeclaredConstructor((Class[]) null); |
|
|
|
return clazz.getDeclaredConstructor((Class[]) null); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
constructorToUse = clazz.getDeclaredConstructor((Class[]) null); |
|
|
|
|
|
|
|
} |
|
|
|
beanDefinition.resolvedConstructorOrFactoryMethod = constructorToUse; |
|
|
|
beanDefinition.resolvedConstructorOrFactoryMethod = constructorToUse; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) { |
|
|
|
catch (Exception ex) { |
|
|
|
@ -127,14 +130,19 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
Object factoryBean, final Method factoryMethod, Object[] args) { |
|
|
|
Object factoryBean, final Method factoryMethod, Object[] args) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
if (System.getSecurityManager() != null) { |
|
|
|
|
|
|
|
AccessController.doPrivileged(new PrivilegedAction<Object>() { |
|
|
|
|
|
|
|
public Object run() { |
|
|
|
|
|
|
|
ReflectionUtils.makeAccessible(factoryMethod); |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
ReflectionUtils.makeAccessible(factoryMethod); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// It's a static method if the target is null.
|
|
|
|
// It's a static method if the target is null.
|
|
|
|
AccessController.doPrivileged(new PrivilegedAction<Object>() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Object run() { |
|
|
|
|
|
|
|
ReflectionUtils.makeAccessible(factoryMethod); |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return factoryMethod.invoke(factoryBean, args); |
|
|
|
return factoryMethod.invoke(factoryBean, args); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (IllegalArgumentException ex) { |
|
|
|
catch (IllegalArgumentException ex) { |
|
|
|
@ -151,5 +159,4 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
"Factory method [" + factoryMethod + "] threw exception", ex.getTargetException()); |
|
|
|
"Factory method [" + factoryMethod + "] threw exception", ex.getTargetException()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|