title: Java EE injection based on type parameters
body: <p>I'm trying to select a bean based on its ParameterizedType.  It looks like there are a phenomenal number of answers here with Google Guice-related solutions, but is this possible with Java EE 7?</p>
  
  <pre><code>public interface Handler&lt;T&gt; { ... }
  
  @ApplicationScoped StringHandler implements Handler&lt;String&gt; { ... }
  @ApplicationScoped IntegerHandler implements Handler&lt;Integer&gt; { ... }
  </code></pre>
  
  <p>Then in some other managed bean:</p>
  
  <pre><code>@Inject private Instance&lt;Handler&lt;?&gt;&gt; handlers;
  
  public &lt;T&gt; Handler&lt;T&gt; handlerFor( Class&lt;T&gt; handledClass )
  {
      // ???
  }
  </code></pre>
  
  <p>So here's the select method in Instance that relates to types:</p>
  
  <pre><code>&lt;U extends T&gt; Instance&lt;U&gt; select(TypeLiteral&lt;U&gt; subtype, Annotation... qualifiers);
  </code></pre>
  
  <p>And the javadoc for TypeLiteral just says that you can do things like</p>
  
  <pre><code> TypeLiteral&lt;List&lt;String&gt;&gt; stringListType = new TypeLiteral&lt;List&lt;String&gt;&gt;() {};
  </code></pre>
  
  <p>Which is terribly unhelpful, because I don't know the types at compile-time.  I do, however, have the Class object as the type parameter argument.</p>
  
  <p>It seems that Guice can handle this just fine by constructing TypeLiteral objects for you.  Is there no similar facility in Java EE 7?</p>