title: Inject cached instances using cdi
body: <p>I want expose instances managed by an external framework to CDI applications using @Inject. These instances must be provided this other framework since their lifecycle is based on various caching strategies. </p>
  
  <p>Ex: same instance is visible within same thread scope, might live across many request scopes, session scope is not applicable. Seems I need to define a new scope targeting these kind of instances?</p>
  
  <p>What is the best way to do this? An extension, is it possible with producer methods?</p>
  
  <p>I almost got it to work with producer methods using the following: </p>
  
  <pre><code>@Inject
  @CustomInject
  FwObject obj;
  
  @Produces
  @CustomInject
  FwObject createConfig(InjectionPoint p) {
    return (FwObject) ctx.get((Class&lt;?&gt;) p.getType());
  }
  </code></pre>
  
  <p>But this force me to be explicit about the type produced which is not possible since there is no common framework interface.</p>
  
  <p>Any help appreciated.</p>