<p>Spring IoC container gives you <a href="http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-arbitrary-method-replacement" rel="nofollow noreferrer">an option</a> of replacing a method of a bean. Can someone provide a real life example of using this feature to solve real life problem?</p>

<p>I can see this used for adapting an old legacy code (w/o sources) to work with your app. But I think I would consider writing an adapter class using the legacy code directly instead of Spring method replacement approach.</p>

Using spring IoC now I can change my Lucene Analyzers to whatever I want just changing a configuration 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 the code:
```
```
Analyzer analyzer  = (Analyzer) BeanLoader.getFactory().getBean("DocumentAnalyzer");
```
```