On 4/17/12 1:53 PM, Adam Bien wrote:
>>
>> Ok, got it.
>>
>>> But that's besides the point. I think a way to propagate per-request config/metadata is essential. I don't understand why you are balking at this so vehemently. Its a very simple addition.
>>
>> I am not against the addition per se. I am just not happy about the proposed solution. Adding a mutable method to an existing immutable API feels wrong. I am thinking that we could make this information injectable. (E.g. in Jersey we have FeaturesAndProperties injectable interface that we use exactly for this purpose.) Since I am seeing some common aspects with client.Configuration, perhaps we can extract a common super-interface from there and make it injectable? E.g.
>>
>> public interface Configuration {
>> Map<String, Object> getProperties();
>> Object getProperty(String name);
>> Configuration setProperties(Map<String, ? extends Object> properties);
>> Configuration setProperty(String name, Object value);
>>
>> // perhaps we can make Feature part of the common API too?
>> Set<Feature> getFeatures();
>> boolean isEnabled(Class<? extends Feature> feature);
>> Configuration enable(Feature feature) throws IllegalStateException;
>> Configuration disable(Class<? extends Feature> feature) throws IllegalStateException;
>> }
>>
>> public interface ClientConfiguration extends Configuration { ... }
>>
>> Alternatively, we could also make the mutable properties map injectable itself. E.g.
>>
>> @Context Map<String, Object> properties;
>>
>> or with a qualifier (better aligned with JSR-330, JSR-299 injection style)
>>
>> @Context @Properties Map<String, Object> properties;
>> @Context @Property("foo") Object fooValue;
>>
>> or using a custom injection annotation (better aligned with JAX-RS injection style)
>>
>> @Properties Map<String, Object> properties;
>> @Property("foo") Object fooValue;
>
> +1 But: why @Context and not @Inject?
Wouldn't @Inject bring in an extra dependency? I don't like that idea
for standalone jax-rs.
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com