title: spring conditional feature enabling
body: <p>For this question, say, we have a MVC configuration class:</p>
  
  <pre><code>@Configuration
  public class MvcConfig extends WebMvcConfigurationSupport {
  
     @Bean
     public ViewResolver viewResolver() {
        return new InternalResourceViewResolver();
     }
     // bla-bla
  
  }
  </code></pre>
  
  <p>I have several bean definitions as usual in a configuration class. The question is while enabling some features such as <code>@EnableCaching</code>, <code>@EnableMBeanExport</code>, <code>@EnableAspectJAutoProxy</code>, how can i control enabling process of those features, ie:</p>
  
  <pre><code>@Configuration
  // @EnableCaching instead of this
  public class MvcConfig extends WebMvcConfigurationSupport {
  
     @Autowired
     SomeResource someResource;
  
     @Bean
     public SomeBean someBean() {
        if(someResouce.someEvaluation(someParam)) {
           enableCaching();   // is that enabling possible?
        }
     }
  
     @Bean
     public ViewResolver viewResolver() {
        return new InternalResourceViewResolver();
     }
     // bla-bla
  
  }
  </code></pre>
  
  <p><em>NOTE:</em> I'm using spring 3.2.x</p>