src/share/jaxws_classes/com/sun/xml/internal/ws/addressing/WsaPropertyBag.java

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
permissions
-rw-r--r--

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, 2013, 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.addressing;
ohair@286 27
alanb@368 28 import com.oracle.webservices.internal.api.message.BasePropertySet;
ohair@286 29 import com.sun.istack.internal.NotNull;
ohair@286 30 import com.sun.xml.internal.ws.api.SOAPVersion;
ohair@286 31 import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
ohair@286 32 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
alanb@368 33 import com.sun.xml.internal.ws.api.message.AddressingUtils;
ohair@286 34 import com.sun.xml.internal.ws.api.message.Header;
ohair@286 35 import com.sun.xml.internal.ws.api.message.Message;
ohair@286 36 import com.sun.xml.internal.ws.api.message.Packet;
ohair@286 37 import com.sun.xml.internal.ws.developer.JAXWSProperties;
ohair@286 38
ohair@286 39 import javax.xml.namespace.QName;
ohair@286 40 import javax.xml.stream.XMLStreamException;
ohair@286 41
alanb@368 42
ohair@286 43 /**
ohair@286 44 * Provides access to the Addressing headers.
ohair@286 45 *
ohair@286 46 * @author Kohsuke Kawaguchi
ohair@286 47 * @author Rama Pulavarthi
ohair@286 48 * @since 2.1.3
ohair@286 49 */
alanb@368 50 public class WsaPropertyBag extends BasePropertySet {
ohair@286 51
ohair@286 52 public static final String WSA_REPLYTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.ReplyToFromRequest";
ohair@286 53 public static final String WSA_FAULTTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.FaultToFromRequest";
ohair@286 54 public static final String WSA_MSGID_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.MessageIdFromRequest";
ohair@286 55 public static final String WSA_TO = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.To";
ohair@286 56
ohair@286 57 private final @NotNull AddressingVersion addressingVersion;
ohair@286 58 private final @NotNull SOAPVersion soapVersion;
ohair@286 59 /**
ohair@286 60 * We can't store {@link Message} here as those may get replaced as
ohair@286 61 * the packet travels through the pipeline.
ohair@286 62 */
ohair@286 63 private final @NotNull Packet packet;
ohair@286 64
ohair@286 65 public WsaPropertyBag(AddressingVersion addressingVersion, SOAPVersion soapVersion, Packet packet) {
ohair@286 66 this.addressingVersion = addressingVersion;
ohair@286 67 this.soapVersion = soapVersion;
ohair@286 68 this.packet = packet;
ohair@286 69 }
ohair@286 70
ohair@286 71 /**
ohair@286 72 * Gets the <tt>wsa:To</tt> header.
ohair@286 73 *
ohair@286 74 * @return
ohair@286 75 * null if the incoming SOAP message didn't have the header.
ohair@286 76 */
ohair@286 77 @Property(JAXWSProperties.ADDRESSING_TO)
ohair@286 78 public String getTo() throws XMLStreamException {
ohair@286 79 if (packet.getMessage() == null) {
ohair@286 80 return null;
ohair@286 81 }
ohair@286 82 Header h = packet.getMessage().getHeaders().get(addressingVersion.toTag, false);
ohair@286 83 if(h==null) return null;
ohair@286 84 return h.getStringContent();
ohair@286 85 }
ohair@286 86
ohair@286 87 /**
ohair@286 88 * Gets the <tt>wsa:To</tt> header.
ohair@286 89 *
ohair@286 90 * @return
ohair@286 91 * null if the incoming SOAP message didn't have the header.
ohair@286 92 */
ohair@286 93 @Property(WSA_TO)
ohair@286 94 public WSEndpointReference getToAsReference() throws XMLStreamException {
ohair@286 95 if (packet.getMessage() == null) {
ohair@286 96 return null;
ohair@286 97 }
ohair@286 98 Header h = packet.getMessage().getHeaders().get(addressingVersion.toTag, false);
ohair@286 99 if(h==null) return null;
ohair@286 100 return new WSEndpointReference(h.getStringContent(),addressingVersion);
ohair@286 101 }
ohair@286 102
ohair@286 103 /**
ohair@286 104 * Gets the <tt>wsa:From</tt> header.
ohair@286 105 *
ohair@286 106 * @return
ohair@286 107 * null if the incoming SOAP message didn't have the header.
ohair@286 108 */
ohair@286 109 @Property(JAXWSProperties.ADDRESSING_FROM)
ohair@286 110 public WSEndpointReference getFrom() throws XMLStreamException {
ohair@286 111 return getEPR(addressingVersion.fromTag);
ohair@286 112 }
ohair@286 113
ohair@286 114 /**
ohair@286 115 * Gets the <tt>wsa:Action</tt> header content as String.
ohair@286 116 *
ohair@286 117 * @return
ohair@286 118 * null if the incoming SOAP message didn't have the header.
ohair@286 119 */
ohair@286 120 @Property(JAXWSProperties.ADDRESSING_ACTION)
ohair@286 121 public String getAction() {
ohair@286 122 if (packet.getMessage() == null) {
ohair@286 123 return null;
ohair@286 124 }
ohair@286 125 Header h = packet.getMessage().getHeaders().get(addressingVersion.actionTag, false);
ohair@286 126 if(h==null) return null;
ohair@286 127 return h.getStringContent();
ohair@286 128 }
ohair@286 129
ohair@286 130 /**
ohair@286 131 * Gets the <tt>wsa:MessageID</tt> header content as String.
ohair@286 132 *
ohair@286 133 * @return
ohair@286 134 * null if the incoming SOAP message didn't have the header.
ohair@286 135 */
ohair@286 136 // WsaServerTube.REQUEST_MESSAGE_ID is exposed for backward compatibility with 2.1
ohair@286 137 @Property({JAXWSProperties.ADDRESSING_MESSAGEID,WsaServerTube.REQUEST_MESSAGE_ID})
ohair@286 138 public String getMessageID() {
ohair@286 139 if (packet.getMessage() == null) {
ohair@286 140 return null;
ohair@286 141 }
alanb@368 142 return AddressingUtils.getMessageID(packet.getMessage().getHeaders(), addressingVersion,soapVersion);
ohair@286 143 }
ohair@286 144
ohair@286 145 private WSEndpointReference getEPR(QName tag) throws XMLStreamException {
ohair@286 146 if (packet.getMessage() == null) {
ohair@286 147 return null;
ohair@286 148 }
ohair@286 149 Header h = packet.getMessage().getHeaders().get(tag, false);
ohair@286 150 if(h==null) return null;
ohair@286 151 return h.readAsEPR(addressingVersion);
ohair@286 152 }
ohair@286 153
ohair@286 154 protected PropertyMap getPropertyMap() {
ohair@286 155 return model;
ohair@286 156 }
ohair@286 157
ohair@286 158 private static final PropertyMap model;
ohair@286 159 static {
ohair@286 160 model = parse(WsaPropertyBag.class);
ohair@286 161 }
ohair@286 162
ohair@286 163 private WSEndpointReference _replyToFromRequest = null;
ohair@286 164
ohair@286 165 @Property(WSA_REPLYTO_FROM_REQUEST)
ohair@286 166 public WSEndpointReference getReplyToFromRequest() {
ohair@286 167 return _replyToFromRequest;
ohair@286 168 }
ohair@286 169
ohair@286 170 public void setReplyToFromRequest(WSEndpointReference ref) {
ohair@286 171 _replyToFromRequest = ref;
ohair@286 172 }
ohair@286 173
ohair@286 174 private WSEndpointReference _faultToFromRequest = null;
ohair@286 175
ohair@286 176 @Property(WSA_FAULTTO_FROM_REQUEST)
ohair@286 177 public WSEndpointReference getFaultToFromRequest() {
ohair@286 178 return _faultToFromRequest;
ohair@286 179 }
ohair@286 180
ohair@286 181 public void setFaultToFromRequest(WSEndpointReference ref) {
ohair@286 182 _faultToFromRequest = ref;
ohair@286 183 }
ohair@286 184
ohair@286 185 private String _msgIdFromRequest = null;
ohair@286 186
ohair@286 187 @Property(WSA_MSGID_FROM_REQUEST)
ohair@286 188 public String getMessageIdFromRequest() {
ohair@286 189 return _msgIdFromRequest;
ohair@286 190 }
ohair@286 191
ohair@286 192 public void setMessageIdFromRequest(String id) {
ohair@286 193 _msgIdFromRequest = id;
ohair@286 194 }
ohair@286 195 }

mercurial