From 29d60448cd19bce99bfa2c73ca760d05dea47263 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 12 Oct 2012 23:33:18 +0200 Subject: [PATCH] Polishing --- .../support/SimpleInstantiationStrategy.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java index 4a81e970a8..b06904221f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java @@ -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"); * 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 currentlyInvokedFactoryMethod = new ThreadLocal(); + + /** + * 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(); + } + + public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) { // Don't override the class with CGLIB if no overrides. if (beanDefinition.getMethodOverrides().isEmpty()) { @@ -147,7 +158,8 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { try { currentlyInvokedFactoryMethod.set(factoryMethod); return factoryMethod.invoke(factoryBean, args); - } finally { + } + finally { if (priorInvokedFactoryMethod != null) { 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(); - } }