Skip to content

Instantly share code, notes, and snippets.

@joserodolfofreitas
Created December 7, 2011 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joserodolfofreitas/1443104 to your computer and use it in GitHub Desktop.
Save joserodolfofreitas/1443104 to your computer and use it in GitHub Desktop.
Producer that produces a Class with T.class as parameter.
public class SqlQueryProducer {
@Inject
BeanManager beanManager;
@Produces
public <T> SqlQuery<T> producesSqlQuery(@New SqlQueryExecutor sqlQueryExecutor, InjectionPoint ip) {
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) ClassUtils.getParameterizedTypeFromAnnotated(ip.getAnnotated());
SqlQuery<T> sqlQuery = new SqlQuery<T>(clazz);
sqlQuery.setQueryExecutor(sqlQueryExecutor);
return sqlQuery;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment