|
From: Michael B. <mic...@gm...> - 2008-11-13 18:07:08
|
Apparently the string converter providers must implement the StringConverter interface directly. I was trying to use an abstract base class implementing StringConverter. Could that be relaxed? Michael Brackx |
|
From: Bill B. <bb...@re...> - 2008-11-13 18:54:01
|
I determine the type from the generic information public class MyConverter implements StringConverter<MyType> the implements tells Resteasy that MyConverter convertes MyType.class. Michael Brackx wrote: > Apparently the string converter providers must implement the > StringConverter interface directly. > I was trying to use an abstract base class implementing StringConverter. > Could that be relaxed? > > Michael Brackx > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com |
|
From: Michael B. <mic...@gm...> - 2008-11-13 19:15:21
|
some code to make it understandable
public abstract class ObjectStringConverter<T> implements StringConverter<T> {
public String toString(final T value) {
return value.toString();
}
}
public class TypeStringConverter extends ObjectStringConverter<Type>
implements StringConverter<Type> {
public Type fromString(final String value) {
return Type.fromString(value);
}
}
if TypeStringConverter does not implement StringConverter<Type>
direcly, it is not properly registered
what was asking is to allow
public class TypeStringConverter extends ObjectStringConverter<Type> {
public Type fromString(final String value) {
return Type.fromString(value);
}
}
Michael
On Thu, Nov 13, 2008 at 7:53 PM, Bill Burke <bb...@re...> wrote:
> I determine the type from the generic information
>
> public class MyConverter implements StringConverter<MyType>
>
> the implements tells Resteasy that MyConverter convertes MyType.class.
>
> Michael Brackx wrote:
>>
>> Apparently the string converter providers must implement the
>> StringConverter interface directly.
>> I was trying to use an abstract base class implementing StringConverter.
>> Could that be relaxed?
>>
>> Michael Brackx
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge
>> Build the coolest Linux based applications with Moblin SDK & win great
>> prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the
>> world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Resteasy-developers mailing list
>> Res...@li...
>> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
|
|
From: Michael B. <mic...@gm...> - 2008-11-14 08:27:43
|
a solution could be to loop over the super classes in
ResteasyProviderFactory.addStringConverter()
currently
Type[] intfs = provider.getClass().getGenericInterfaces();
is used
getGenericInterfaces()
Returns the Types representing the interfaces directly implemented by
the class or interface represented by this object.
Michael Brackx
|
|
From: Michael B. <mic...@gm...> - 2008-11-21 11:28:06
|
i committed a "fix" for the following simple parent case
@Provider
public class PersonConverter extends SuperPersonConverter{...}
public class SuperPersonConverter implements StringConverter<Person>{...}
however, the original testcase remains a problem
@Provider
public static class CompanyConverter extends ObjectConverter<Company>{..}
public abstract static class ObjectConverter<T> implements
StringConverter<T>{...}
How can you get the type in this case?
The testcase is SuperStringConverterTest. Uncomment the commented
lines to trigger the problem.
Michael Brackx
|
|
From: Bill B. <bb...@re...> - 2008-11-21 13:28:00
|
Michael Brackx wrote:
> i committed a "fix" for the simple parent case
>
> @Provider
> public class PersonConverter extends SuperPersonConverter{...}
>
> public class SuperPersonConverter implements StringConverter<Person>{...}
>
> however, the original testcase remains a problem
>
> @Provider
> public static class CompanyConverter extends ObjectConverter<Company>{..}
>
> public abstract static class ObjectConverter<T> implements
> StringConverter<T>{...}
>
> How can you get the type in this case?
>
@Provider
public static class CompanyConverter extends ObjectConverter<Company>
implements StringConverter<Company> {}
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|
|
From: Bill B. <bb...@re...> - 2008-11-21 13:30:28
|
Ugh, How about we just add a getType() method to the interface?
Michael Brackx wrote:
> i committed a "fix" for the simple parent case
>
> @Provider
> public class PersonConverter extends SuperPersonConverter{...}
>
> public class SuperPersonConverter implements StringConverter<Person>{...}
>
> however, the original testcase remains a problem
>
> @Provider
> public static class CompanyConverter extends ObjectConverter<Company>{..}
>
> public abstract static class ObjectConverter<T> implements
> StringConverter<T>{...}
>
> How can you get the type in this case?
>
> Michael Brackx
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|
|
From: Michael B. <mic...@gm...> - 2008-11-21 13:54:14
|
On Fri, Nov 21, 2008 at 2:30 PM, Bill Burke <bb...@re...> wrote: > Ugh, How about we just add a getType() method to the interface? seems ugly to me Michael Brackx |
|
From: Michael B. <mic...@gm...> - 2008-11-21 13:57:16
|
> @Provider
> public static class CompanyConverter extends ObjectConverter<Company>
> implements StringConverter<Company> {}
my "fix" for the simple parent case broke that workaround
i fixed this by retuning after the first stringconverter is registered
should multiple stringconverter interfaces per provider be allowed?
Michael Brackx
|
|
From: Michael B. <mic...@gm...> - 2008-11-21 14:17:05
|
> should multiple stringconverter interfaces per provider be allowed? again something that is illegal Michael Brackx |
|
From: Michael B. <mic...@gm...> - 2008-11-21 14:01:10
|
>> however, the original testcase remains a problem
>>
>> @Provider
>> public static class CompanyConverter extends
>> ObjectConverter<Company>{..}
>>
>> public abstract static class ObjectConverter<T> implements
>> StringConverter<T>{...}
>>
>> How can you get the type in this case?
>>
>
>
> @Provider
> public static class CompanyConverter extends ObjectConverter<Company>
> implements StringConverter<Company> {}
what i was trying to ask was how that could be implemented in java.
how to get the actual type of T in this case?
Michael Brackx
|
|
From: Bill B. <bb...@re...> - 2008-11-21 14:15:35
|
Michael Brackx wrote:
>>> however, the original testcase remains a problem
>>>
>>> @Provider
>>> public static class CompanyConverter extends
>>> ObjectConverter<Company>{..}
>>>
>>> public abstract static class ObjectConverter<T> implements
>>> StringConverter<T>{...}
>>>
>>> How can you get the type in this case?
>>>
>>
>> @Provider
>> public static class CompanyConverter extends ObjectConverter<Company>
>> implements StringConverter<Company> {}
>
> what i was trying to ask was how that could be implemented in java.
> how to get the actual type of T in this case?
>
> Michael Brackx
Hmm, i'm not sure.
You can do CompanyConverter.getGenericSuperclass() to get
ObjectConverter<Company> and find Company that way, but what you really
want is CompanyConverter.getGenericSuperclass()
and from that get the generic interfaces. I'm not sure that will work.
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|
|
From: Bill B. <bb...@re...> - 2008-11-21 14:16:34
|
Dude, maybe you should just use delegation instead of inheritance?
Michael Brackx wrote:
>>> however, the original testcase remains a problem
>>>
>>> @Provider
>>> public static class CompanyConverter extends
>>> ObjectConverter<Company>{..}
>>>
>>> public abstract static class ObjectConverter<T> implements
>>> StringConverter<T>{...}
>>>
>>> How can you get the type in this case?
>>>
>>
>> @Provider
>> public static class CompanyConverter extends ObjectConverter<Company>
>> implements StringConverter<Company> {}
>
> what i was trying to ask was how that could be implemented in java.
> how to get the actual type of T in this case?
>
> Michael Brackx
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|
|
From: Michael B. <mic...@gm...> - 2008-11-21 14:30:21
|
does the spec require that the interface is declared on the actual provider class for the other providers? probably it does so the stringconverter should behave in the same way and i should revert the changes Michael Brackx |