|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2009 the original author or authors. |
|
|
|
* Copyright 2002-2010 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -42,12 +42,10 @@ import org.springframework.util.StringUtils; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
|
|
|
|
|
|
|
|
public Object instantiate( |
|
|
|
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) { |
|
|
|
RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Don't override the class with CGLIB if no overrides.
|
|
|
|
// Don't override the class with CGLIB if no overrides.
|
|
|
|
if (beanDefinition.getMethodOverrides().isEmpty()) { |
|
|
|
if (beanDefinition.getMethodOverrides().isEmpty()) { |
|
|
|
Constructor constructorToUse = (Constructor) beanDefinition.resolvedConstructorOrFactoryMethod; |
|
|
|
Constructor<?> constructorToUse = (Constructor<?>) beanDefinition.resolvedConstructorOrFactoryMethod; |
|
|
|
if (constructorToUse == null) { |
|
|
|
if (constructorToUse == null) { |
|
|
|
final Class clazz = beanDefinition.getBeanClass(); |
|
|
|
final Class clazz = beanDefinition.getBeanClass(); |
|
|
|
if (clazz.isInterface()) { |
|
|
|
if (clazz.isInterface()) { |
|
|
|
@ -60,7 +58,8 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
return clazz.getDeclaredConstructor((Class[]) null); |
|
|
|
return clazz.getDeclaredConstructor((Class[]) null); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
constructorToUse = clazz.getDeclaredConstructor((Class[]) null); |
|
|
|
constructorToUse = clazz.getDeclaredConstructor((Class[]) null); |
|
|
|
} |
|
|
|
} |
|
|
|
beanDefinition.resolvedConstructorOrFactoryMethod = constructorToUse; |
|
|
|
beanDefinition.resolvedConstructorOrFactoryMethod = constructorToUse; |
|
|
|
@ -90,9 +89,8 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
"Method Injection not supported in SimpleInstantiationStrategy"); |
|
|
|
"Method Injection not supported in SimpleInstantiationStrategy"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Object instantiate( |
|
|
|
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, |
|
|
|
RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, |
|
|
|
final Constructor<?> ctor, Object[] args) { |
|
|
|
final Constructor ctor, Object[] args) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (beanDefinition.getMethodOverrides().isEmpty()) { |
|
|
|
if (beanDefinition.getMethodOverrides().isEmpty()) { |
|
|
|
if (System.getSecurityManager() != null) { |
|
|
|
if (System.getSecurityManager() != null) { |
|
|
|
@ -117,16 +115,14 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
* the Method Injection specified in the given RootBeanDefinition. |
|
|
|
* the Method Injection specified in the given RootBeanDefinition. |
|
|
|
* Instantiation should use the given constructor and parameters. |
|
|
|
* Instantiation should use the given constructor and parameters. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected Object instantiateWithMethodInjection( |
|
|
|
protected Object instantiateWithMethodInjection(RootBeanDefinition beanDefinition, |
|
|
|
RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, |
|
|
|
String beanName, BeanFactory owner, Constructor ctor, Object[] args) { |
|
|
|
Constructor ctor, Object[] args) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new UnsupportedOperationException( |
|
|
|
throw new UnsupportedOperationException( |
|
|
|
"Method Injection not supported in SimpleInstantiationStrategy"); |
|
|
|
"Method Injection not supported in SimpleInstantiationStrategy"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Object instantiate( |
|
|
|
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, |
|
|
|
RootBeanDefinition beanDefinition, String beanName, BeanFactory owner, |
|
|
|
|
|
|
|
Object factoryBean, final Method factoryMethod, Object[] args) { |
|
|
|
Object factoryBean, final Method factoryMethod, Object[] args) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
@ -159,4 +155,5 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { |
|
|
|
"Factory method [" + factoryMethod + "] threw exception", ex.getTargetException()); |
|
|
|
"Factory method [" + factoryMethod + "] threw exception", ex.getTargetException()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|