I'd like to elaborate after some thought. Again, I think
ContextResolver is a ad-hoc hack to get the Jersey JAXB Provider to work
effectively. It smells like a hack because of JAX-RS's current reliance
on constructing providers and resources from raw classes rather than
letting registering raw classes for Providers and Resources rather than
allowing the application
Again, I think a JAXB Provider like implementation with pluggable
JAXBContext functionality would be better served by either:
a) Subclassing the vendor-provided JAXB Provider and registering a
custom JAXB Provider class. i.e. (partial pseudocode)
@Provider
@ProduceMime...
public class MyCustomJAXB extens JBossJAXBProvider {
isReadable(..);
isWriteable(...);
This example just overrides the isReadable/isWritable methods
b) Allowing the application to instantiate/construct the
Provider/Resource objects itself through plain Java code, Spring, Seam,
Guice, or even Web Beans. We can make this portable by extending
ApplicationConfig (like I discussed in a previous email) with methods
that also return Objects for resources and providers:
List<Object> getProviderInstances();
List<Object> getResourceInstances();
Bill Burke wrote:
> Nevermind, I was totally confused on what ContextResolver was. From
> reading things closer, you can only inject ContextResolver instances.
>
> Still...I don't like this class or its use. Seems very half-baked to me.
>
>
> Bill Burke wrote:
>> The "type" parameter to getContext() seems redundant, am I missing
>> something?
>>
>> public interface ContextResolver<T>
>> {
>> T getContext(Class<?> type);
>> }
>>
>> For this example:
>>
>> @Context CustomInjectedType custom;
>>
>> @Provider
>> public class MyCustom implements ContextResolver<CustomInjectedType> {}
>>
>>
>> Isn't <T> enough information for the JAX-RS runtime to resolve what to
>> inject? All the runtime has to do is do
>> providerClass.getGenericInterfaces() and see what is a ContextResolver
>> and pull the type form that.
>>
>> Or, am I missing what ContextResolver is supposed to do?
>>
>> Thanks
>>
>>
>>
>>
>>
>>
>>
>
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com