Real business deal for using spring replace method?
Spring IoC Container provides an option to replace the bean method. Can anyone provide a real world example of using this feature to solve a real life problem?
I see this is being used to adapt old legacy code (no sources) to work with your application. But I think I would consider writing an adapter class using legacy code instead of Spring's replacement method.
source to share
As the documentation says, this is not "publicly available" functionality.
A case where this might be useful, but is to change the functionality of a third party method (you don't necessarily have the source) of the final class, i.e. one whose functionality cannot be changed or extended through inheritance.
I guess this will still be a bit of a hack :)
source to share
Using spring IoC, I can now change my Lucene parsers to whatever I want by simply changing the config file.
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>file.properties</value>
</list>
</property>
</bean>
<bean id="DocumentAnalyzer" class="${lucene.document_analyzer}">
</bean>
<bean id="QueryAnalyzer" class="${lucene.query_analyzer}">
</bean>
<bean id="IndexSearcher" class="org.apache.lucene.search.IndexSearcher" scope="prototype">
<constructor-arg>
<value>${lucene.repository_path}</value>
</constructor-arg>
</bean>
and then in code:
Analyzer analyzer = (Analyzer) BeanLoader.getFactory().getBean("DocumentAnalyzer");
source to share