Tue, 09 Apr 2013 14:51:13 +0100
8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com
ohair@286 | 1 | /* |
alanb@368 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
ohair@286 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@286 | 4 | * |
ohair@286 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohair@286 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@286 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohair@286 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@286 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohair@286 | 10 | * |
ohair@286 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@286 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@286 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@286 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohair@286 | 15 | * accompanied this code). |
ohair@286 | 16 | * |
ohair@286 | 17 | * You should have received a copy of the GNU General Public License version |
ohair@286 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohair@286 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@286 | 20 | * |
ohair@286 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@286 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@286 | 23 | * questions. |
ohair@286 | 24 | */ |
ohair@286 | 25 | |
ohair@286 | 26 | package com.sun.xml.internal.ws.api.pipe; |
ohair@286 | 27 | |
ohair@286 | 28 | import com.sun.istack.internal.NotNull; |
ohair@286 | 29 | import com.sun.istack.internal.Nullable; |
ohair@286 | 30 | import com.sun.xml.internal.ws.addressing.W3CWsaServerTube; |
ohair@286 | 31 | import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionWsaServerTube; |
ohair@286 | 32 | import com.sun.xml.internal.ws.api.addressing.AddressingVersion; |
ohair@286 | 33 | import com.sun.xml.internal.ws.api.model.SEIModel; |
ohair@286 | 34 | import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
ohair@286 | 35 | import com.sun.xml.internal.ws.api.pipe.helper.PipeAdapter; |
ohair@286 | 36 | import com.sun.xml.internal.ws.api.server.ServerPipelineHook; |
ohair@286 | 37 | import com.sun.xml.internal.ws.api.server.WSEndpoint; |
ohair@286 | 38 | import com.sun.xml.internal.ws.binding.BindingImpl; |
ohair@286 | 39 | import com.sun.xml.internal.ws.developer.SchemaValidationFeature; |
ohair@286 | 40 | import com.sun.xml.internal.ws.handler.HandlerTube; |
ohair@286 | 41 | import com.sun.xml.internal.ws.handler.ServerLogicalHandlerTube; |
ohair@286 | 42 | import com.sun.xml.internal.ws.handler.ServerMessageHandlerTube; |
ohair@286 | 43 | import com.sun.xml.internal.ws.handler.ServerSOAPHandlerTube; |
ohair@286 | 44 | import com.sun.xml.internal.ws.protocol.soap.ServerMUTube; |
ohair@286 | 45 | import com.sun.xml.internal.ws.server.ServerSchemaValidationTube; |
ohair@286 | 46 | import com.sun.xml.internal.ws.util.pipe.DumpTube; |
ohair@286 | 47 | |
ohair@286 | 48 | import javax.xml.ws.soap.SOAPBinding; |
ohair@286 | 49 | import java.io.PrintStream; |
ohair@286 | 50 | |
ohair@286 | 51 | /** |
ohair@286 | 52 | * Factory for well-known server {@link Tube} implementations |
ohair@286 | 53 | * that the {@link TubelineAssembler} needs to use |
ohair@286 | 54 | * to satisfy JAX-WS requirements. |
ohair@286 | 55 | * |
ohair@286 | 56 | * @author Jitendra Kotamraju |
ohair@286 | 57 | */ |
ohair@286 | 58 | public class ServerTubeAssemblerContext { |
ohair@286 | 59 | |
ohair@286 | 60 | private final SEIModel seiModel; |
ohair@286 | 61 | private final WSDLPort wsdlModel; |
ohair@286 | 62 | private final WSEndpoint endpoint; |
ohair@286 | 63 | private final BindingImpl binding; |
ohair@286 | 64 | private final Tube terminal; |
ohair@286 | 65 | private final boolean isSynchronous; |
ohair@286 | 66 | private @NotNull Codec codec; |
ohair@286 | 67 | |
ohair@286 | 68 | public ServerTubeAssemblerContext(@Nullable SEIModel seiModel, |
ohair@286 | 69 | @Nullable WSDLPort wsdlModel, @NotNull WSEndpoint endpoint, |
ohair@286 | 70 | @NotNull Tube terminal, boolean isSynchronous) { |
ohair@286 | 71 | this.seiModel = seiModel; |
ohair@286 | 72 | this.wsdlModel = wsdlModel; |
ohair@286 | 73 | this.endpoint = endpoint; |
ohair@286 | 74 | this.terminal = terminal; |
ohair@286 | 75 | // WSBinding is actually BindingImpl |
ohair@286 | 76 | this.binding = (BindingImpl)endpoint.getBinding(); |
ohair@286 | 77 | this.isSynchronous = isSynchronous; |
ohair@286 | 78 | this.codec = this.binding.createCodec(); |
ohair@286 | 79 | } |
ohair@286 | 80 | |
ohair@286 | 81 | /** |
ohair@286 | 82 | * The created pipeline will use seiModel to get java concepts for the endpoint |
ohair@286 | 83 | * |
ohair@286 | 84 | * @return Null if the service doesn't have SEI model e.g. Provider endpoints, |
ohair@286 | 85 | * and otherwise non-null. |
ohair@286 | 86 | */ |
ohair@286 | 87 | public @Nullable SEIModel getSEIModel() { |
ohair@286 | 88 | return seiModel; |
ohair@286 | 89 | } |
ohair@286 | 90 | |
ohair@286 | 91 | /** |
ohair@286 | 92 | * The created pipeline will be used to serve this port. |
ohair@286 | 93 | * |
ohair@286 | 94 | * @return Null if the service isn't associated with any port definition in WSDL, |
ohair@286 | 95 | * and otherwise non-null. |
ohair@286 | 96 | */ |
ohair@286 | 97 | public @Nullable WSDLPort getWsdlModel() { |
ohair@286 | 98 | return wsdlModel; |
ohair@286 | 99 | } |
ohair@286 | 100 | |
ohair@286 | 101 | /** |
ohair@286 | 102 | * |
ohair@286 | 103 | * The created pipeline is used to serve this {@link com.sun.xml.internal.ws.api.server.WSEndpoint}. |
ohair@286 | 104 | * Specifically, its {@link com.sun.xml.internal.ws.api.WSBinding} should be of interest to many |
ohair@286 | 105 | * {@link com.sun.xml.internal.ws.api.pipe.Pipe}s. |
ohair@286 | 106 | * @return Always non-null. |
ohair@286 | 107 | */ |
ohair@286 | 108 | public @NotNull WSEndpoint<?> getEndpoint() { |
ohair@286 | 109 | return endpoint; |
ohair@286 | 110 | } |
ohair@286 | 111 | |
ohair@286 | 112 | /** |
ohair@286 | 113 | * The last {@link com.sun.xml.internal.ws.api.pipe.Pipe} in the pipeline. The assembler is expected to put |
ohair@286 | 114 | * additional {@link com.sun.xml.internal.ws.api.pipe.Pipe}s in front of it. |
ohair@286 | 115 | * |
ohair@286 | 116 | * <p> |
ohair@286 | 117 | * (Just to give you the idea how this is used, normally the terminal pipe |
ohair@286 | 118 | * is the one that invokes the user application or {@link javax.xml.ws.Provider}.) |
ohair@286 | 119 | * |
ohair@286 | 120 | * @return always non-null terminal pipe |
ohair@286 | 121 | */ |
ohair@286 | 122 | public @NotNull Tube getTerminalTube() { |
ohair@286 | 123 | return terminal; |
ohair@286 | 124 | } |
ohair@286 | 125 | |
ohair@286 | 126 | /** |
ohair@286 | 127 | * If this server pipeline is known to be used for serving synchronous transport, |
ohair@286 | 128 | * then this method returns true. This can be potentially use as an optimization |
ohair@286 | 129 | * hint, since often synchronous versions are cheaper to execute than asycnhronous |
ohair@286 | 130 | * versions. |
ohair@286 | 131 | */ |
ohair@286 | 132 | public boolean isSynchronous() { |
ohair@286 | 133 | return isSynchronous; |
ohair@286 | 134 | } |
ohair@286 | 135 | |
ohair@286 | 136 | /** |
ohair@286 | 137 | * Creates a {@link Tube} that performs SOAP mustUnderstand processing. |
ohair@286 | 138 | * This pipe should be before HandlerPipes. |
ohair@286 | 139 | */ |
ohair@286 | 140 | public @NotNull Tube createServerMUTube(@NotNull Tube next) { |
ohair@286 | 141 | if (binding instanceof SOAPBinding) |
ohair@286 | 142 | return new ServerMUTube(this,next); |
ohair@286 | 143 | else |
ohair@286 | 144 | return next; |
ohair@286 | 145 | } |
ohair@286 | 146 | |
ohair@286 | 147 | /** |
ohair@286 | 148 | * Creates a {@link Tube} that invokes protocol and logical handlers. |
ohair@286 | 149 | */ |
ohair@286 | 150 | public @NotNull Tube createHandlerTube(@NotNull Tube next) { |
ohair@286 | 151 | if (!binding.getHandlerChain().isEmpty()) { |
ohair@286 | 152 | HandlerTube cousin = new ServerLogicalHandlerTube(binding, seiModel, wsdlModel, next); |
ohair@286 | 153 | next = cousin; |
ohair@286 | 154 | if (binding instanceof SOAPBinding) { |
ohair@286 | 155 | //Add SOAPHandlerTube |
ohair@286 | 156 | next = cousin = new ServerSOAPHandlerTube(binding, next, cousin); |
ohair@286 | 157 | |
ohair@286 | 158 | //Add MessageHandlerTube |
ohair@286 | 159 | next = new ServerMessageHandlerTube(seiModel, binding, next, cousin); |
ohair@286 | 160 | } |
ohair@286 | 161 | } |
ohair@286 | 162 | return next; |
ohair@286 | 163 | } |
ohair@286 | 164 | |
ohair@286 | 165 | /** |
ohair@286 | 166 | * Creates a {@link Tube} that does the monitoring of the invocation for a |
ohair@286 | 167 | * container |
ohair@286 | 168 | */ |
ohair@286 | 169 | public @NotNull Tube createMonitoringTube(@NotNull Tube next) { |
ohair@286 | 170 | ServerPipelineHook hook = endpoint.getContainer().getSPI(ServerPipelineHook.class); |
ohair@286 | 171 | if (hook != null) { |
ohair@286 | 172 | ServerPipeAssemblerContext ctxt = new ServerPipeAssemblerContext(seiModel, wsdlModel, endpoint, terminal, isSynchronous); |
ohair@286 | 173 | return PipeAdapter.adapt(hook.createMonitoringPipe(ctxt, PipeAdapter.adapt(next))); |
ohair@286 | 174 | } |
ohair@286 | 175 | return next; |
ohair@286 | 176 | } |
ohair@286 | 177 | |
ohair@286 | 178 | /** |
ohair@286 | 179 | * Creates a {@link Tube} that adds container specific security |
ohair@286 | 180 | */ |
ohair@286 | 181 | public @NotNull Tube createSecurityTube(@NotNull Tube next) { |
ohair@286 | 182 | ServerPipelineHook hook = endpoint.getContainer().getSPI(ServerPipelineHook.class); |
ohair@286 | 183 | if (hook != null) { |
ohair@286 | 184 | ServerPipeAssemblerContext ctxt = new ServerPipeAssemblerContext(seiModel, wsdlModel, endpoint, terminal, isSynchronous); |
ohair@286 | 185 | return PipeAdapter.adapt(hook.createSecurityPipe(ctxt, PipeAdapter.adapt(next))); |
ohair@286 | 186 | } |
ohair@286 | 187 | return next; |
ohair@286 | 188 | } |
ohair@286 | 189 | |
ohair@286 | 190 | /** |
ohair@286 | 191 | * creates a {@link Tube} that dumps messages that pass through. |
ohair@286 | 192 | */ |
ohair@286 | 193 | public Tube createDumpTube(String name, PrintStream out, Tube next) { |
ohair@286 | 194 | return new DumpTube(name, out, next); |
ohair@286 | 195 | } |
ohair@286 | 196 | |
ohair@286 | 197 | /** |
ohair@286 | 198 | * creates a {@link Tube} that validates messages against schema |
ohair@286 | 199 | */ |
ohair@286 | 200 | public Tube createValidationTube(Tube next) { |
ohair@286 | 201 | if (binding instanceof SOAPBinding && binding.isFeatureEnabled(SchemaValidationFeature.class) && wsdlModel!=null) |
ohair@286 | 202 | return new ServerSchemaValidationTube(endpoint, binding, seiModel, wsdlModel, next); |
ohair@286 | 203 | else |
ohair@286 | 204 | return next; |
ohair@286 | 205 | } |
ohair@286 | 206 | |
ohair@286 | 207 | /** |
ohair@286 | 208 | * Creates WS-Addressing pipe |
ohair@286 | 209 | */ |
ohair@286 | 210 | public Tube createWsaTube(Tube next) { |
ohair@286 | 211 | if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding)) { |
ohair@286 | 212 | if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) { |
ohair@286 | 213 | return new MemberSubmissionWsaServerTube(endpoint, wsdlModel, binding, next); |
ohair@286 | 214 | } else { |
ohair@286 | 215 | return new W3CWsaServerTube(endpoint, wsdlModel, binding, next); |
ohair@286 | 216 | } |
ohair@286 | 217 | } else |
ohair@286 | 218 | return next; |
ohair@286 | 219 | } |
ohair@286 | 220 | |
ohair@286 | 221 | /** |
ohair@286 | 222 | * Gets the {@link Codec} that is set by {@link #setCodec} or the default codec |
ohair@286 | 223 | * based on the binding. The codec is a full codec that is responsible for |
ohair@286 | 224 | * encoding/decoding entire protocol message(for e.g: it is responsible to |
ohair@286 | 225 | * encode/decode entire MIME messages in SOAP binding) |
ohair@286 | 226 | * |
ohair@286 | 227 | * @return codec to be used for web service requests |
alanb@368 | 228 | * @see Codecs |
ohair@286 | 229 | */ |
ohair@286 | 230 | public @NotNull Codec getCodec() { |
ohair@286 | 231 | return codec; |
ohair@286 | 232 | } |
ohair@286 | 233 | |
ohair@286 | 234 | /** |
ohair@286 | 235 | * Interception point to change {@link Codec} during {@link Tube}line assembly. The |
ohair@286 | 236 | * new codec will be used by jax-ws server runtime for encoding/decoding web service |
ohair@286 | 237 | * request/response messages. {@link WSEndpoint#createCodec()} will return a copy |
ohair@286 | 238 | * of this new codec and will be used in the server runtime. |
ohair@286 | 239 | * |
ohair@286 | 240 | * <p> |
ohair@286 | 241 | * The codec is a full codec that is responsible for |
ohair@286 | 242 | * encoding/decoding entire protocol message(for e.g: it is responsible to |
ohair@286 | 243 | * encode/decode entire MIME messages in SOAP binding) |
ohair@286 | 244 | * |
ohair@286 | 245 | * <p> |
ohair@286 | 246 | * the codec should correctly implement {@link Codec#copy} since it is used while |
ohair@286 | 247 | * serving requests concurrently. |
ohair@286 | 248 | * |
ohair@286 | 249 | * @param codec codec to be used for web service requests |
alanb@368 | 250 | * @see Codecs |
ohair@286 | 251 | */ |
ohair@286 | 252 | public void setCodec(@NotNull Codec codec) { |
ohair@286 | 253 | this.codec = codec; |
ohair@286 | 254 | } |
ohair@286 | 255 | |
ohair@286 | 256 | } |