dev@jsr311.java.net

Re: JSR311: exception mapping of wrapper exceptions

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 26 Jun 2008 09:19:56 -0400

On Jun 26, 2008, at 3:12 AM, Paul Sandoz wrote:
>>
>> The getContextResolver method offers us an opportunity to simplify
>> things. Rather than injecting a ContextResolver directly with
>> @Context and requiring that the injected instance actually be a
>> proxy that searches for a context resolver of the specified type
>> for a particular class (did I mention it was complicated), instead
>> we can define the method like this:
>>
>> <T> T getContext(Class<T> contextType, Class<?> objectType)
>>
>> So to get a JAXBContext for some JAXB bean Foo you'd write:
>>
>> @Context Providers p;
>> JAXBContext jbc = p.getContext(JAXBContext.class, Foo.class);
>>
>> Much nicer !
>>
>
> From what perspective? from the client i don't think it is easier.
> From that perspective i prefer the current interface.
>

I think its awkward the way you currently have to inject a proxy
implementing ContextResolver<T> that then calls each provider in turn.
Users might reasonably assume that if they implement
ContextResolver<JAXBContext> in a class and then inject a field of the
same type they will get the actual instance of the resolver class.

To be clear I'm not suggesting removing the ContextResolver interface,
just changing how you get access to the contexts that implementations
provide (via the Providers interface).

Marc.

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