You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by ant elder <an...@gmail.com> on 2009/10/23 14:33:50 UTC

Re: Identifying JAX-WS async pooling and callback methods, was Re: svn commit: r828990 - /tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java

Hi Luciano, was just replying about the commit on the other thread but
as you've posted I'll reply here.

All those you've said sound right to me. As you were in the middle of
this but hadn't committed all you code yet I didnt want to reimplement
lots of code that you'd likely already written so I tried to do it as
minimally and noninvasively as possible with just enough to get the
compliance tests passing to see if it worked and the type of code
needed. Now thats in and you're up again do feel free to replace any
or all of it with the code you already have and to fine tune it, and
I'll help with that if you like. Another thing we could also do is
change it so that it actually does make the calls asynchronously
instead of the current under the covers synchronous approach.

   ...ant

On Fri, Oct 23, 2009 at 1:24 PM, Luciano Resende <lu...@gmail.com> wrote:
> Based on the section 11.1 from Java CAA spec, shouldn't we be checking
> for more stuff when identifying the JAX-WS async callback and pooling
> methods ? Below is the snipet from the spec that describes the logic
> to identify the methods:
>
> The additional client-side asynchronous polling and callback methods
> defined by JAX-WS are recognized in a Java interface as follows:
> For each method M in the interface, if another method P in the interface has
>     a) a method name that is M's method name with the characters
> "Async" appended, and
>     b) the same parameter signature as M, and
>     c)a return type of Response<R> where R is the return type of M
> then P is a JAX-WS polling method that isn't part of the SCA interface contract.
> For each method M in the interface, if another method C in the interface has
>    a) a method name that is M's method name with the characters
> "Async" appended, and
>    b) a parameter signature that is M's parameter signature with an additional
>        final parameter of type AsyncHandler<R> where R is the return
> type of M, and
>    c) a return type of Future<?>
> then C is a JAX-WS callback method that isn't part of the SCA
> interface contract.
>
> It seems that we are not checking if R type is valid when checking
> Response<R> and AsyncHandler<R>. I had implemented the logic to test
> these in JAXWSAsyncInterfaceProcessor.
>
> Also, any reason why not to use a separate Interface visitor to handle
> this check, instead of adding this directly into the
> JavaInterfaceIntrospectorImpl ?
>
> On Fri, Oct 23, 2009 at 3:25 AM,  <an...@apache.org> wrote:
>> Author: antelder
>> Date: Fri Oct 23 10:25:33 2009
>> New Revision: 828990
>>
>> URL: http://svn.apache.org/viewvc?rev=828990&view=rev
>> Log:
>> Update JavaInterfaceIntrospectorImpl to not consider teh JAXWS Async API methods in the overloaded ops on remotable interfaces
>>
>> Modified:
>>    tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
>>
>> Modified: tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
>> URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java?rev=828990&r1=828989&r2=828990&view=diff
>> ==============================================================================
>> --- tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java (original)
>> +++ tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java Fri Oct 23 10:25:33 2009
>> @@ -31,8 +31,11 @@
>>  import java.util.List;
>>  import java.util.Map;
>>  import java.util.Set;
>> +import java.util.concurrent.Future;
>>
>>  import javax.xml.namespace.QName;
>> +import javax.xml.ws.AsyncHandler;
>> +import javax.xml.ws.Response;
>>
>>  import org.apache.tuscany.sca.interfacedef.DataType;
>>  import org.apache.tuscany.sca.interfacedef.InvalidAnnotationException;
>> @@ -187,7 +190,7 @@
>>             if (remotable && names.contains(name)) {
>>                 throw new OverloadedOperationException(method);
>>             }
>> -            if (remotable) {
>> +            if (remotable && !jaxwsAsyncMethod(method)) {
>>                 names.add(name);
>>             }
>>
>> @@ -254,4 +257,22 @@
>>         return operations;
>>     }
>>
>> +    private boolean jaxwsAsyncMethod(Method method) {
>> +        if (method.getName().endsWith("Async")) {
>> +            if (method.getName().endsWith("Async")) {
>> +                if (method.getReturnType().isAssignableFrom(Future.class)) {
>> +                    if (method.getParameterTypes().length > 0) {
>> +                        if (method.getParameterTypes()[method.getParameterTypes().length-1].isAssignableFrom(AsyncHandler.class)) {
>> +                            return true;
>> +                        }
>> +                    }
>> +                }
>> +                if (method.getReturnType().isAssignableFrom(Response.class)) {
>> +                    return true;
>> +                }
>> +            }
>> +        }
>> +        return false;
>> +    }
>> +
>>  }
>>
>>
>>
>
>
>
> --
> Luciano Resende
> http://people.apache.org/~lresende
> http://lresende.blogspot.com/
>