title: Optimize spring application context load time by removing ConfigurationPostProcessor
body: <p>This question is directed to people who are familiar/interested in Spring's internals. Pivotal guys- I hope you come across this.</p>
  
  <p>My application uses spring DI. We mix annotation based beans like @Service and @component with plain old xml based beans. </p>
  
  <p>At some point the load times of the application context have become unbearable (30-90 sec) depending on developer machine.</p>
  
  <p>I ran a profiler on on the loading of the application context and found an interesting thing:</p>
  
  <p>it spends a large portion of the time inside <code>org.springframework.context.annotation.ConfigurationClassPostProcessor</code>, specifically in processConfigBeanDefinitions.</p>
  
  <p>It iterates over a list of candidates, checking whether the are annotated with "@Bean" or "@Configuration" or any of their buddies.</p>
  
  <p>I am willing to give up on annotation based configuration based on the observation that it takes so much time. </p>
  
  <p>I found a way to remove this post processor by implementing a BeanDefinitionRegistryPostProcessor and removing org.springframework.context.annotation.internalConfigurationAnnotationProcessor. Indeed it sped up the load time significantly. </p>
  
  <p>so the question is:</p>
  
  <ol>
  <li>is this safe? or is it a dangerous hack?</li>
  <li>it seems that this class does not respect the package name configured in the  section- it iterates over too many candidates. Why is that?</li>
  <li>Other suggestions?</li>
  </ol>