[seam-issues] [JBoss JIRA] Commented: (SOLDER-110) @DefaultBean does not work on generic types
George Gastaldi (JIRA)
jira-events at lists.jboss.org
Fri Jun 17 16:28:23 EDT 2011
[ https://issues.jboss.org/browse/SOLDER-110?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12609548#comment-12609548 ]
George Gastaldi commented on SOLDER-110:
----------------------------------------
Here is a snippet to get the actual type arguments from a class:
{code:java}
private Type[] getConverterTypeGenerics(Class<?> clazz) {
Type[] genericInterfaces = clazz.getGenericInterfaces();
for (Type type : genericInterfaces) {
if (type instanceof ParameterizedType) {
return ((ParameterizedType) type).getActualTypeArguments();
}
}
return null;
}
{code}
> @DefaultBean does not work on generic types
> -------------------------------------------
>
> Key: SOLDER-110
> URL: https://issues.jboss.org/browse/SOLDER-110
> Project: Seam Solder
> Issue Type: Bug
> Affects Versions: 3.0.0.Final
> Reporter: George Gastaldi
>
> DefaultBean should work on generic types also, check the example below:
> {code:java}
> public interface Converter<S, T> {
> T convert(S source);
> }
> @DefaultBean(Converter.class)
> public class DozerConverter implements Converter<Object, Object> {
> @Inject
> public DozerConverter(InjectionPoint ip) {
> }
> @Override
> public Object convert(Object source) {
> }
> }
> public class ConverterTest {
>
> @Inject
> private Converter<String, Integer> converter;
>
> ...
> }
> {code}
> When running the test, it fails with a org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Converter<String, Integer>] with qualifiers [@Default] at injection point [[field] @Inject private org.jboss.seam.solder.test.converter.ConverterTest.converter], since the generic types are different (but possible, since the default bean it´s supposed to handle object to object conversion).
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues
mailing list