title: Spring @Autowired - Instantiate new bean
body: <p>Need some help with Spring autowiring, and scopes.</p>
  
  <p>Here is the basic app structure:</p>
  
  <ol>
  <li><p>I have an CustomHttpClient, annotated as @Component, and also pulling some config-related properties from application.properties file (via @Value annotation).</p></li>
  <li><p>CustomHttpClient is used by several services in my application. Whenever I'm using the CustomHttpClient, I autowire an instance of that via:</p>
  
  <pre><code>@Autowired
  private CustomHttpClient httpClient;
  </code></pre></li>
  <li><p>I use interceptor to modify some of the variables inside CustomHttpClient, like so:</p>
  
  <pre><code>public class MyInterceptor extends HandlerInterceptorAdapter {
  @Autowired CustomHttpClient httpClient;
  
  @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
  httpClient.setSomeProperty(newValue);
  ...
  </code></pre></li>
  </ol>
  
  <p>Now, here is the problem. If I have everything set up as described above, then whenever I change any setting of the CustomHttpClient via interceptor, that new value is persisted for all other clients, as long as VM is running. So when I run httpClient.setSomeProperty() - that setting is now permanently saved. Even if I connect to the application from another client.</p>
  
  <p>Basically what I need to have are two things:</p>
  
  <ol>
  <li>Still being able to override default settings of the CustomHttpClient via interceptor (request interceptor, configured via ).</li>
  <li>Make sure a new instance of CustomHttpClient is created for every request (after the interceptor does its' magic).</li>
  </ol>
  
  <p>I tried changing the scope of CustomHttpClient to @Scope("prototype"), but that way I can no longer change settings of CustomHttpClient with an interceptor.</p>