src/share/jaxws_classes/com/sun/xml/internal/ws/client/sei/StubAsyncHandler.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.xml.internal.ws.client.sei;
    28 import java.util.List;
    30 import javax.jws.soap.SOAPBinding.Style;
    32 import com.sun.xml.internal.ws.api.message.MessageContextFactory;
    33 import com.sun.xml.internal.ws.model.JavaMethodImpl;
    34 import com.sun.xml.internal.ws.model.ParameterImpl;
    35 import com.sun.xml.internal.ws.model.WrapperParameter;
    37 public class StubAsyncHandler extends StubHandler {
    39     private final Class asyncBeanClass;
    41         public StubAsyncHandler(JavaMethodImpl jm, JavaMethodImpl sync, MessageContextFactory mcf) {
    42         super(sync, mcf);
    44         List<ParameterImpl> rp = sync.getResponseParameters();
    45         int size = 0;
    46         for( ParameterImpl param : rp ) {
    47             if (param.isWrapperStyle()) {
    48                 WrapperParameter wrapParam = (WrapperParameter)param;
    49                 size += wrapParam.getWrapperChildren().size();
    50                 if (sync.getBinding().getStyle() == Style.DOCUMENT) {
    51                     // doc/asyncBeanClass - asyncBeanClass bean is in async signature
    52                     // Add 2 or more so that it is considered as async bean case
    53                     size += 2;
    54                 }
    55             } else {
    56                 ++size;
    57             }
    58         }
    60         Class tempWrap = null;
    61         if (size > 1) {
    62             rp = jm.getResponseParameters();
    63             for(ParameterImpl param : rp) {
    64                 if (param.isWrapperStyle()) {
    65                     WrapperParameter wrapParam = (WrapperParameter)param;
    66                     if (sync.getBinding().getStyle() == Style.DOCUMENT) {
    67                         // doc/asyncBeanClass style
    68                         tempWrap = (Class)wrapParam.getTypeInfo().type;
    69                         break;
    70                     }
    71                     for(ParameterImpl p : wrapParam.getWrapperChildren()) {
    72                         if (p.getIndex() == -1) {
    73                             tempWrap = (Class)p.getTypeInfo().type;
    74                             break;
    75                         }
    76                     }
    77                     if (tempWrap != null) {
    78                         break;
    79                     }
    80                 } else {
    81                     if (param.getIndex() == -1) {
    82                         tempWrap = (Class)param.getTypeInfo().type;
    83                         break;
    84                     }
    85                 }
    86             }
    87         }
    88         asyncBeanClass = tempWrap;
    90         switch(size) {
    91             case 0 :
    92                 responseBuilder = buildResponseBuilder(sync, ValueSetterFactory.NONE);
    93                 break;
    94             case 1 :
    95                 responseBuilder = buildResponseBuilder(sync, ValueSetterFactory.SINGLE);
    96                 break;
    97             default :
    98                 responseBuilder = buildResponseBuilder(sync, new ValueSetterFactory.AsyncBeanValueSetterFactory(asyncBeanClass));
    99         }
   101     }
   103         protected void initArgs(Object[] args) throws Exception {
   104         if (asyncBeanClass != null) {
   105             args[0] = asyncBeanClass.newInstance();
   106         }
   107         }
   109     ValueGetterFactory getValueGetterFactory() {
   110         return ValueGetterFactory.ASYNC;
   111     }
   112 }

mercurial