Override xml-defined spring bean in java-based configuration -
i'm extending complete product called hippo cms own rest interface. hippo cms using apache cxf rest , acquires resources definitions spring bean defined somewhere in hippo cms sources. definition this:
<bean id="jaxrsrestplainresourceproviders" class="org.springframework.beans.factory.config.methodinvokingfactorybean"> <property name="targetclass" value="org.apache.commons.collections.listutils" /> <property name="targetmethod" value="union" /> <property name="arguments"> <list> <ref bean="customrestplainresourceproviders" /> <ref bean="defaultrestplainresourceproviders" /> </list> </property> </bean> <bean id="defaultrestplainresourceproviders" class="org.springframework.beans.factory.config.listfactorybean"> <property name="sourcelist"> <list> </list> </property> </bean> <!-- default empty list of custom plain resource providers overriden. --> <bean id="customrestplainresourceproviders" class="org.springframework.beans.factory.config.listfactorybean"> <property name="sourcelist"> <list> </list> </property> </bean>
i need override customrestplainresourceproviders
bean own bean. works fine xml configuration looking this:
<bean id="customrestplainresourceproviders" class="org.springframework.beans.factory.config.listfactorybean"> <property name="sourcelist"> <list> <bean class="org.apache.cxf.jaxrs.lifecycle.singletonresourceprovider"> <constructor-arg> <bean class="com.xxx.rest.folderstructureresource"/> </constructor-arg> </bean> </list> </property> </bean>
but doesn't work if define bean in java configuration class (which in case of other beans works fine):
@bean(name = "customrestplainresourceproviders") public listfactorybean customrestplainresourceproviders() { listfactorybean listfactorybean = new listfactorybean(); listfactorybean.setsourcelist( lists.newarraylist( new singletonresourceprovider( new folderstructureresource(repository()) ) ) ); return listfactorybean; }
is there way override bean defined in xml configuration bean created in java configuration class?
what version of spring using? believe issues addressed in 4.2.
Comments
Post a Comment