jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: A Feature interface

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 24 Jun 2011 16:33:58 +0200

Hi Bill,

please see inline.

On 06/09/2011 09:49 PM, Bill Burke wrote:
>
>
> On 6/9/11 12:12 PM, Santiago Pericas-Geertsen wrote:
>>
>> On Jun 8, 2011, at 9:52 AM, Bill Burke wrote:
>>
>>>> Is this something we can specify in the javadoc for Invocation.getProperties() and BaseContext.getProperties()?
>>>>
>>>
>>> Yes. But also I'd like to brainstorm a little bit more about this.
>>>
>>>
>>> For example, maybe this is yet another way to bind an interceptor. An interceptor could get a callback with a
>>> properties map and decide whether or not to apply itself.
>>
>> What if we change the DynamicBinding interface as follows:
>>
>> public interface DynamicBinding<T extends BaseContext> {
>> public boolean isBound(T ctx);
>> }
>>
>> That'll give access to everything in the context. Incidentally, why did you use AccessibleObject as the return type
>> of getAppliedTarget() in your original proposal?
>>
>
> I was thinking of something more that was a boot/deployment/init time thing.
>
> public interface Feature {
>
> void bind(Client client);
> void bind(Client client, BaseContext ctx);
> void bindServer(BaseContext ctx);
> }
>
> Or have 2 separete interfaces:
>
> public interface ClientFeature {...}
>
> public interface ServerFeature {...}
>
> Maybre that makes more sense and would allow us to separate client and server easier if we ever wanted JAX-RS client to
> be in JDK.
>
> It would then look like:
>
> clientConfigurate.getClasses().add(MyFeature.class);
>
> or Application.getClasses() would return a MyFeature.class.
>

I wonder if the same functionality is not already covered by the current proposal, which gives a user the ability to

- register filters and handlers for client, resource (link) and invocation
- inherit properties and features from the parent instance
- further customize the properties and features on each particular configurable instance (client, resource link and
invocation)
- access properties and features for each particular request/response (invocation) from within the filter/handler
implementation

Currently you should be able to enable/disable filters and handlers using the features and configure the functionality
of enabled filters and handlers using the properties in the spirit of a low-level API.

Not sure if you already had a chance to look at the Configuration section in the Client API proposal which tries to
explain the basic mechanisms: http://java.net/projects/jax-rs-spec/pages/Low-levelClientAPI#Configuring_API_components

>
> BTW, I noticed that Client doesn't have an registerClass() registerSingleton(). I think this is something that would
> need to be added.

Last version of the Client implements Configurable interface and inherits the register methods from there.

Marek