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 a1533835f9..6eb6ec5240 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.