Polishing

This commit is contained in:
Juergen Hoeller
2012-10-12 23:33:18 +02:00
committed by unknown
parent a6ce821ad8
commit 29d60448cd

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2010 the original author or authors. * Copyright 2002-2012 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.
@@ -44,6 +44,17 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
private static final ThreadLocal<Method> currentlyInvokedFactoryMethod = new ThreadLocal<Method>(); private static final ThreadLocal<Method> currentlyInvokedFactoryMethod = new ThreadLocal<Method>();
/**
* Return the factory method currently being invoked or {@code null} if none.
* <p>Allows factory method implementations to determine whether the current
* caller is the container itself as opposed to user code.
*/
public static Method getCurrentlyInvokedFactoryMethod() {
return currentlyInvokedFactoryMethod.get();
}
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) { public Object instantiate(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()) {
@@ -147,7 +158,8 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
try { try {
currentlyInvokedFactoryMethod.set(factoryMethod); currentlyInvokedFactoryMethod.set(factoryMethod);
return factoryMethod.invoke(factoryBean, args); return factoryMethod.invoke(factoryBean, args);
} finally { }
finally {
if (priorInvokedFactoryMethod != null) { if (priorInvokedFactoryMethod != null) {
currentlyInvokedFactoryMethod.set(priorInvokedFactoryMethod); currentlyInvokedFactoryMethod.set(priorInvokedFactoryMethod);
} }
@@ -171,12 +183,4 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
} }
} }
/**
* Return the factory method currently being invoked or {@code null} if none.
* Allows factory method implementations to determine whether the current
* caller is the container itself as opposed to user code.
*/
public static Method getCurrentlyInvokedFactoryMethod() {
return currentlyInvokedFactoryMethod.get();
}
} }