dev@jsr311.java.net

Re: JSR311: GenericEntity state should be settable

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 21 Aug 2008 13:57:52 -0400

I think I prefer the idea of a new constructor on GenericEntity, it
keeps all the generic entity stuff in one place that way.

Given that you pass in the entity, the constructor doesn't need the
rawType parameter.

Marc.

On Aug 20, 2008, at 6:04 PM, Bill Burke wrote:

> "by applications using reflection to construct the entity" i.e.
>
> @GET
> public Response myGenericDispatch()
> {
> Method method = ...;
> Object entity = method.invoke(...);
> return
> Response
> .ok(entity).genericType(method.getGenericReturnType()).build();
> }
>
>
> Marc Hadley wrote:
>> Hmm. But how would users get the value of genericType except via
>> the same trick that GenericEntity uses - in which case why wouldn't
>> they just use that directly ? Normally type erasure removes the
>> necessary information so you can't get the generic type at runtime
>> which is why we added GenericEntity...
>> Marc.
>> On Aug 20, 2008, at 4:09 PM, Bill Burke wrote:
>>> https://jsr311.dev.java.net/issues/show_bug.cgi?id=48
>>>
>>> GenericEntity should have an additional constructor so that
>>> rawType, type, and
>>> entity can be set by applications using reflection to construct
>>> entity objects.
>>>
>>> public GenericEntity(Class rawType, Type genericType, T entity)
>>> {
>>> this.rawType = rawType;
>>> this.genericType = genericType;
>>> this.entity = entity;
>>> }
>>>
>>> This would allow applications that are using reflection to set the
>>> generic type.
>>> It would be public as it doesn't make much sense to require
>>> extending.
>>>
>>>
>>> --
>>> Bill Burke
>>> JBoss, a division of Red Hat
>>> http://bill.burkecentral.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
>>> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>>>
>> ---
>> Marc Hadley <marc.hadley at sun.com>
>> CTO Office, Sun Microsystems.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
>> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.