ApplicationContextAware インターフェイスを使用して、ApplicationContext にいくつかの Spring Bean を動的に登録しようとしています。BeanDefitionBuilder を使用して Bean 定義を作成し、それらを DefaultListableBeanFactory.registerBeanDefinition() に登録します。私が構築しようとしている Bean は、XML では次のようになります。
<bean id="compositeBean" class="SomeClass">
<property name="checks">
<list>
<ref bean="bean1"/>
<ref bean="bean2"/>
<ref bean="bean3"/>
</list>
</property>
</bean>
上記の (bean1, bean2, bean3) の BeanDefinitions のリストが利用可能です。使おうとすると
BeanDefinitionBuilder.genericBeanDefinition(SomeClass.class)
.addPropertyValue("checks", checks);
私はエラーで終わります
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'compositeBean': Initialization of bean
failed; nested exception is
org.springframework.beans.ConversionNotSupportedException: Failed to
convert property value of type
'org.springframework.beans.factory.config.BeanDefinition[]' to
required type 'SomeClass[]' for property 'checks'; nested exception is
java.lang.IllegalStateException: Cannot convert value of type
[org.springframework.beans.factory.support.GenericBeanDefinition] to
required type [SomeClass] for property 'checks[0]': no matching
editors or conversion strategy found
Bean 参照のリストを自分の compositeBean にプログラムで追加するにはどうすればよいですか?