1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/assembler/DefaultClientTubelineAssemblyContext.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,161 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +/* 1.30 + * To change this template, choose Tools | Templates 1.31 + * and open the template in the editor. 1.32 + */ 1.33 +package com.sun.xml.internal.ws.assembler; 1.34 + 1.35 +import com.sun.istack.internal.NotNull; 1.36 +import com.sun.istack.internal.Nullable; 1.37 +import com.sun.xml.internal.ws.api.EndpointAddress; 1.38 +import com.sun.xml.internal.ws.api.WSBinding; 1.39 +import com.sun.xml.internal.ws.api.WSService; 1.40 +import com.sun.xml.internal.ws.api.client.WSPortInfo; 1.41 +import com.sun.xml.internal.ws.api.model.SEIModel; 1.42 +import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; 1.43 +import com.sun.xml.internal.ws.api.pipe.ClientTubeAssemblerContext; 1.44 +import com.sun.xml.internal.ws.api.pipe.Codec; 1.45 +import com.sun.xml.internal.ws.api.server.Container; 1.46 +import com.sun.xml.internal.ws.assembler.dev.ClientTubelineAssemblyContext; 1.47 +import com.sun.xml.internal.ws.policy.PolicyMap; 1.48 + 1.49 +/** 1.50 + * The context is a wrapper around the existing JAX-WS {@link ClientTubeAssemblerContext} with additional features 1.51 + * 1.52 + * @author Marek Potociar (marek.potociar at sun.com) 1.53 + */ 1.54 +class DefaultClientTubelineAssemblyContext extends TubelineAssemblyContextImpl implements ClientTubelineAssemblyContext { 1.55 + 1.56 + private final @NotNull ClientTubeAssemblerContext wrappedContext; 1.57 + private final PolicyMap policyMap; 1.58 + private final WSPortInfo portInfo; // TODO: is this really needed? 1.59 + private final WSDLPort wsdlPort; 1.60 + // TODO: replace the PipeConfiguration 1.61 + 1.62 + public DefaultClientTubelineAssemblyContext(@NotNull ClientTubeAssemblerContext context) { 1.63 + this.wrappedContext = context; 1.64 + this.wsdlPort = context.getWsdlModel(); 1.65 + this.portInfo = context.getPortInfo(); 1.66 + this.policyMap = context.getPortInfo().getPolicyMap(); 1.67 + } 1.68 + 1.69 + public PolicyMap getPolicyMap() { 1.70 + return policyMap; 1.71 + } 1.72 + 1.73 + public boolean isPolicyAvailable() { 1.74 + return policyMap != null && !policyMap.isEmpty(); 1.75 + } 1.76 + 1.77 + /** 1.78 + * The created pipeline will be used to serve this port. 1.79 + * Null if the service isn't associated with any port definition in WSDL, 1.80 + * and otherwise non-null. 1.81 + * 1.82 + * Replaces {@link com.sun.xml.internal.ws.api.pipe.ClientTubeAssemblerContext#getWsdlModel()} 1.83 + */ 1.84 + public WSDLPort getWsdlPort() { 1.85 + return wsdlPort; 1.86 + } 1.87 + 1.88 + public WSPortInfo getPortInfo() { 1.89 + return portInfo; 1.90 + } 1.91 + 1.92 + /** 1.93 + * The endpoint address. Always non-null. This parameter is taken separately 1.94 + * from {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPort} (even though there's {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPort#getAddress()}) 1.95 + * because sometimes WSDL is not available. 1.96 + */ 1.97 + public @NotNull EndpointAddress getAddress() { 1.98 + return wrappedContext.getAddress(); 1.99 + } 1.100 + 1.101 + /** 1.102 + * The pipeline is created for this {@link com.sun.xml.internal.ws.api.WSService}. 1.103 + * Always non-null. (To be precise, the newly created pipeline 1.104 + * is owned by a proxy or a dispatch created from this {@link com.sun.xml.internal.ws.api.WSService}.) 1.105 + */ 1.106 + public @NotNull WSService getService() { 1.107 + return wrappedContext.getService(); 1.108 + } 1.109 + 1.110 + /** 1.111 + * The binding of the new pipeline to be created. 1.112 + */ 1.113 + public @NotNull WSBinding getBinding() { 1.114 + return wrappedContext.getBinding(); 1.115 + } 1.116 + 1.117 + /** 1.118 + * The created pipeline will use seiModel to get java concepts for the endpoint 1.119 + * 1.120 + * @return Null if the service doesn't have SEI model e.g. Dispatch, 1.121 + * and otherwise non-null. 1.122 + */ 1.123 + public @Nullable SEIModel getSEIModel() { 1.124 + return wrappedContext.getSEIModel(); 1.125 + } 1.126 + 1.127 + /** 1.128 + * Returns the Container in which the client is running 1.129 + * 1.130 + * @return Container in which client is running 1.131 + */ 1.132 + public Container getContainer() { 1.133 + return wrappedContext.getContainer(); 1.134 + } 1.135 + 1.136 + /** 1.137 + * Gets the {@link Codec} that is set by {@link #setCodec} or the default codec 1.138 + * based on the binding. 1.139 + * 1.140 + * @return codec to be used for web service requests 1.141 + */ 1.142 + public @NotNull Codec getCodec() { 1.143 + return wrappedContext.getCodec(); 1.144 + } 1.145 + 1.146 + /** 1.147 + * Interception point to change {@link Codec} during {@link com.sun.xml.internal.ws.api.pipe.Tube}line assembly. The 1.148 + * new codec will be used by jax-ws client runtime for encoding/decoding web service 1.149 + * request/response messages. The new codec should be used by the transport tubes. 1.150 + * 1.151 + * <p> 1.152 + * the codec should correctly implement {@link Codec#copy} since it is used while 1.153 + * serving requests concurrently. 1.154 + * 1.155 + * @param codec codec to be used for web service requests 1.156 + */ 1.157 + public void setCodec(@NotNull Codec codec) { 1.158 + wrappedContext.setCodec(codec); 1.159 + } 1.160 + 1.161 + public ClientTubeAssemblerContext getWrappedContext() { 1.162 + return wrappedContext; 1.163 + } 1.164 +}