From 2f2ef00d1fcbd11a8b03bf67158c656a4621ad5c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 12 Jan 2017 21:15:22 +0100 Subject: [PATCH] BeanDefinitionBuilder supports factory method on factory bean Issue: SPR-15098 (cherry picked from commit 9e6aa0f) --- .../factory/support/BeanDefinitionBuilder.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java index a1533835f95..6eb6ec52405 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -159,13 +159,25 @@ public class BeanDefinitionBuilder { } /** - * Set the name of the factory method to use for this definition. + * Set the name of a static factory method to use for this definition, + * to be called on this bean's class. */ public BeanDefinitionBuilder setFactoryMethod(String factoryMethod) { this.beanDefinition.setFactoryMethodName(factoryMethod); return this; } + /** + * Set the name of a non-static factory method to use for this definition, + * including the bean name of the factory instance to call the method on. + * @since 4.3.6 + */ + public BeanDefinitionBuilder setFactoryMethodOnBean(String factoryMethod, String factoryBean) { + this.beanDefinition.setFactoryMethodName(factoryMethod); + this.beanDefinition.setFactoryBeanName(factoryBean); + return this; + } + /** * Add an indexed constructor arg value. The current index is tracked internally * and all additions are at the present point.