dev@jax-ws.java.net

Re: Proposal for WebServiceFeature Extension

From: Rama Pulavarthi <Rama.Pulavarthi_at_Sun.COM>
Date: Thu, 19 Oct 2006 20:43:46 -0700

Jitendra Kotamraju wrote:
> Kohsuke Kawaguchi wrote:
>> Rama Pulavarthi wrote:
>>> Spec defines two feature annotaions @Addressing and @MTOM. The
>>> feature extensions are growing daily (@MemberSubmissionAddressing,
>>> @Stateful, @OptimalEncoding....) How to deal with these growing
>>> annotations?
>>
>> I think the problem you are trying to solve is real, and I'm happy to
>> see that you are attacking it, but I have a problem with your solution.
>>
>> You are serving two audience here. One is the system-level developers
>> that extend the JAX-WS RI (people like Paul or me), and the other is
>> the JAX-WS RI users, who ultimately uses all those things.
>>
>> You need to have a mechanism that the former people can use, while
>> not making anything uglier for the latter. IMO your approach has a
>> problem with the 2nd part of this, because you are exposing a method
>> that JAX-WS users would see.
>>
>> I think a better approach is a constructor annotation. You ask Paul
>> to define 'Foo' feature like this (the same with your proposal so far):
>>
>> @Target(ElementType.TYPE)
>> @Retention(RetentionPolicy.RUNTIME)
>> @Documented
>> @WebServiceFeatureAnnotation(id=FooFeature.ID,bean=FooFeature.class)
>> public @interface Foo {
>> /**
>> * Specifies param2 option
>> */
>> boolean param2() default true;
>>
>> /**
>> * Specifies param1 option
>> */
>> String param1() default "";
>> }
>>
>> but instead of defining WebServiceFeatureEx, ask him to define
>> FooBean like this:
>>
>> public class FooFeature extends WebServiceFeature {
>> public static final String ID = "foo";
>> private final boolean param2;
>> private final String param1;
>>
>> public FooFeature(
>> @FeatureParameter("param1") String param1,
>> @FeatureParameter("param2") boolean param2){
>> this.param1 = param1;
>> this.param2 = param2;
>> }
>> }
>>
>> This approach minimizes the exposure of this mechanism to the users.
> What's the real advantage of @FeatureParamer ? to figure out setter
> method ?
>
> If the FooFeature follows the bean pattern, the runtime can get the
> values from the annotation and populate the bean.
>
> FooFeature feature = new FooFeature()
> feature.setParam2(FooAnn.param2())
>
The above may not work as RI has no idea about existence of
fooAnn.param2().

The user may change the order of elements, @Foo(param2=true,param1="xyz")
The user may leave some elements to defaults, @Foo(param2=true)
How can we know which element setter to call?
 From the annotation, can we get elements using reflection?

Even with kohsuke proposal, I am not sure how we can do this if the user
changes the order or leaves some elements.
Do we need to use Mirror API to figure out how to invoke the constructor?
And, still we may need a Marker interface WebServiceFeatureEx for all
feature extensions to obey these rules.

thanks,
Rama Pulavarthi
,

> Jitu
>>
>>
>>> Currently, There is no easy way get a WebServiceFeature instance
>>> from a feature annotation. The WebServiceFeatureAnnotation.bean()
>>> gives only the associated class.
>>> So, I propose all feature extensions to extend
>>> com.sun.xml.ws.api.WebServiceFeatureEx. With this we can get an
>>> WebServiceFeature Object easily.
>>> This is extensible and we don't have deal with feature annotation
>>> extensions in the future. RI already has provided extension points
>>> for WSDL Generation, WSDL Parsing, Runtime through Pipes/Tubes.
>>>
>>> If @Foo(param1="xyz",param2=true) is present on an impl class,
>>> RI will get an instance of FooFeature from
>>> @Foo(param1="xyz",param2=true) and sets it on WSBinding.
>>> Corresponding FooTube or FooWSDLExtensions will handle this feature
>>> at runtime/wsdl generation.
>>> ---------------
>>> package com.sun.xml.ws.api;
>>> import javax.xml.ws.WebServiceFeature;
>>> import java.lang.annotation.Annotation;
>>>
>>> public abstract class WebServiceFeatureEx extends WebServiceFeature {
>>> public abstract WebServiceFeatureEx getFeatureObject(Annotation
>>> ann);
>>> }
>>> ---------------
>>> package com.sun.xml.ws;
>>>
>>> @Target(ElementType.TYPE)
>>> @Retention(RetentionPolicy.RUNTIME)
>>> @Documented
>>> @WebServiceFeatureAnnotation(id=FooFeature.ID,bean=FooFeature.class)
>>> public @interface Foo {
>>> /**
>>> * Specifies param2 option
>>> */
>>> boolean param2() default true;
>>>
>>> /**
>>> * Specifies param1 option
>>> */
>>> String param1() default "";
>>> }
>>> -----------------
>>> import java.lang.annotation.Annotation;
>>>
>>> public class FooFeature extends WebServiceFeatureEx {
>>> public static final String ID = "foo";
>>> boolean param2 = false;
>>> String param1= null;
>>>
>>> public FooFeature(String param1, boolean param2){
>>> this.param1 = param1;
>>> this.param2 = param2;
>>> }
>>>
>>> public WebServiceFeatureEx getFeatureObject(Annotation ann) {
>>> if(!(ann instanceof Foo))
>>> return null;// or throw Exception
>>> Foo foo = (Foo)ann;
>>> // Each feature knows how to deal with its annotation
>>> return new FooFeature(foo.param1(),foo.param2());
>>> }
>>>
>>> public String getParam1() {
>>> return param1;
>>> }
>>> public boolean getParam2() {
>>> return param2;
>>> }
>>> public String getID() {
>>> return ID;
>>> }
>>> ----------------------------
>>>
>>> thanks,
>>> Rama Pulavarthi
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_jax-ws.dev.java.net
>>> For additional commands, e-mail: dev-help_at_jax-ws.dev.java.net
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jax-ws.dev.java.net
> For additional commands, e-mail: dev-help_at_jax-ws.dev.java.net
>