src/share/jaxws_classes/com/sun/xml/internal/ws/server/provider/SyncProviderInvokerTube.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) 1997, 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.server.provider;
    28 import com.sun.istack.internal.NotNull;
    29 import com.sun.xml.internal.ws.api.WSBinding;
    30 import com.sun.xml.internal.ws.api.message.Packet;
    31 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
    32 import com.sun.xml.internal.ws.api.pipe.NextAction;
    33 import com.sun.xml.internal.ws.api.pipe.ThrowableContainerPropertySet;
    34 import com.sun.xml.internal.ws.api.server.Invoker;
    36 import javax.xml.ws.Provider;
    37 import java.util.logging.Level;
    38 import java.util.logging.Logger;
    40 /**
    41  * This tube is used to invoke the {@link Provider} endpoints.
    42  *
    43  * @author Jitendra Kotamraju
    44  */
    45 public // TODO needed by factory
    46 class SyncProviderInvokerTube<T> extends ProviderInvokerTube<T> {
    48     private static final Logger LOGGER = Logger.getLogger(
    49         com.sun.xml.internal.ws.util.Constants.LoggingDomain + ".server.SyncProviderInvokerTube");
    51     public SyncProviderInvokerTube(Invoker invoker, ProviderArgumentsBuilder<T> argsBuilder) {
    52         super(invoker, argsBuilder);
    53     }
    55     /*
    56     * This binds the parameter for Provider endpoints and invokes the
    57     * invoke() method of {@linke Provider} endpoint. The return value from
    58     * invoke() is used to create a new {@link Message} that traverses
    59     * through the Pipeline to transport.
    60     */
    61     public NextAction processRequest(Packet request) {
    62         WSDLPort port = getEndpoint().getPort();
    63         WSBinding binding = getEndpoint().getBinding();
    64         T param = argsBuilder.getParameter(request);
    66         LOGGER.fine("Invoking Provider Endpoint");
    68         T returnValue;
    69         try {
    70             returnValue = getInvoker(request).invokeProvider(request, param);
    71         } catch(Exception e) {
    72             LOGGER.log(Level.SEVERE, e.getMessage(), e);
    73             Packet response = argsBuilder.getResponse(request,e,port,binding);
    74             return doReturnWith(response);
    75         }
    76         if (returnValue == null) {
    77             // Oneway. Send response code immediately for transports(like HTTP)
    78             // Don't do this above, since close() may generate some exceptions
    79             if (request.transportBackChannel != null) {
    80                 request.transportBackChannel.close();
    81             }
    82         }
    83         Packet response = argsBuilder.getResponse(request,returnValue,port,binding);
    85         // Only used by Provider<Packet>
    86         // Implementation may pass Packet containing throwable; use both
    87         ThrowableContainerPropertySet tc = response.getSatellite(ThrowableContainerPropertySet.class);
    88         Throwable t = (tc != null) ? tc.getThrowable() : null;
    90         return t != null ? doThrow(response, t) : doReturnWith(response);
    91     }
    93     public @NotNull NextAction processResponse(@NotNull Packet response) {
    94         return doReturnWith(response);
    95     }
    97     public @NotNull NextAction processException(@NotNull Throwable t) {
    98         return doThrow(t);
    99     }
   101 }

mercurial