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

Print this page


   1 /*
   2  * Copyright (c) 1997, 2010, 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  */
  25 
  26 package com.sun.xml.internal.ws.addressing;
  27 

  28 import com.sun.istack.internal.NotNull;
  29 import com.sun.xml.internal.ws.api.PropertySet;
  30 import com.sun.xml.internal.ws.api.SOAPVersion;
  31 import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
  32 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;

  33 import com.sun.xml.internal.ws.api.message.Header;
  34 import com.sun.xml.internal.ws.api.message.Message;
  35 import com.sun.xml.internal.ws.api.message.Packet;
  36 import com.sun.xml.internal.ws.developer.JAXWSProperties;
  37 
  38 import javax.xml.namespace.QName;
  39 import javax.xml.stream.XMLStreamException;
  40 

  41 /**
  42  * Provides access to the Addressing headers.
  43  *
  44  * @author Kohsuke Kawaguchi
  45  * @author Rama Pulavarthi
  46  * @since 2.1.3
  47  */
  48 public class WsaPropertyBag extends PropertySet {
  49 
  50     public static final String WSA_REPLYTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.ReplyToFromRequest";
  51     public static final String WSA_FAULTTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.FaultToFromRequest";
  52     public static final String WSA_MSGID_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.MessageIdFromRequest";
  53     public static final String WSA_TO = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.To";
  54 
  55     private final @NotNull AddressingVersion addressingVersion;
  56     private final @NotNull SOAPVersion soapVersion;
  57     /**
  58      * We can't store {@link Message} here as those may get replaced as
  59      * the packet travels through the pipeline.
  60      */
  61     private final @NotNull Packet packet;
  62 
  63     public WsaPropertyBag(AddressingVersion addressingVersion, SOAPVersion soapVersion, Packet packet) {
  64         this.addressingVersion = addressingVersion;
  65         this.soapVersion = soapVersion;
  66         this.packet = packet;
  67     }
  68 


 120         if (packet.getMessage() == null) {
 121           return null;
 122         }
 123         Header h = packet.getMessage().getHeaders().get(addressingVersion.actionTag, false);
 124         if(h==null) return null;
 125         return h.getStringContent();
 126     }
 127 
 128     /**
 129      * Gets the <tt>wsa:MessageID</tt> header content as String.
 130      *
 131      * @return
 132      *      null if the incoming SOAP message didn't have the header.
 133      */
 134     // WsaServerTube.REQUEST_MESSAGE_ID is exposed for backward compatibility with 2.1
 135     @Property({JAXWSProperties.ADDRESSING_MESSAGEID,WsaServerTube.REQUEST_MESSAGE_ID})
 136     public String getMessageID() {
 137         if (packet.getMessage() == null) {
 138           return null;
 139         }
 140         return packet.getMessage().getHeaders().getMessageID(addressingVersion,soapVersion);
 141     }
 142 
 143     private WSEndpointReference getEPR(QName tag) throws XMLStreamException {
 144         if (packet.getMessage() == null) {
 145           return null;
 146         }
 147         Header h = packet.getMessage().getHeaders().get(tag, false);
 148         if(h==null) return null;
 149         return h.readAsEPR(addressingVersion);
 150     }
 151 
 152     protected PropertyMap getPropertyMap() {
 153         return model;
 154     }
 155 
 156     private static final PropertyMap model;
 157     static {
 158         model = parse(WsaPropertyBag.class);
 159     }
 160 


   1 /*
   2  * Copyright (c) 1997, 2013, 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  */
  25 
  26 package com.sun.xml.internal.ws.addressing;
  27 
  28 import com.oracle.webservices.internal.api.message.BasePropertySet;
  29 import com.sun.istack.internal.NotNull;

  30 import com.sun.xml.internal.ws.api.SOAPVersion;
  31 import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
  32 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
  33 import com.sun.xml.internal.ws.api.message.AddressingUtils;
  34 import com.sun.xml.internal.ws.api.message.Header;
  35 import com.sun.xml.internal.ws.api.message.Message;
  36 import com.sun.xml.internal.ws.api.message.Packet;
  37 import com.sun.xml.internal.ws.developer.JAXWSProperties;
  38 
  39 import javax.xml.namespace.QName;
  40 import javax.xml.stream.XMLStreamException;
  41 
  42 
  43 /**
  44  * Provides access to the Addressing headers.
  45  *
  46  * @author Kohsuke Kawaguchi
  47  * @author Rama Pulavarthi
  48  * @since 2.1.3
  49  */
  50 public class WsaPropertyBag extends BasePropertySet {
  51 
  52     public static final String WSA_REPLYTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.ReplyToFromRequest";
  53     public static final String WSA_FAULTTO_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.FaultToFromRequest";
  54     public static final String WSA_MSGID_FROM_REQUEST = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.MessageIdFromRequest";
  55     public static final String WSA_TO = "com.sun.xml.internal.ws.addressing.WsaPropertyBag.To";
  56 
  57     private final @NotNull AddressingVersion addressingVersion;
  58     private final @NotNull SOAPVersion soapVersion;
  59     /**
  60      * We can't store {@link Message} here as those may get replaced as
  61      * the packet travels through the pipeline.
  62      */
  63     private final @NotNull Packet packet;
  64 
  65     public WsaPropertyBag(AddressingVersion addressingVersion, SOAPVersion soapVersion, Packet packet) {
  66         this.addressingVersion = addressingVersion;
  67         this.soapVersion = soapVersion;
  68         this.packet = packet;
  69     }
  70 


 122         if (packet.getMessage() == null) {
 123           return null;
 124         }
 125         Header h = packet.getMessage().getHeaders().get(addressingVersion.actionTag, false);
 126         if(h==null) return null;
 127         return h.getStringContent();
 128     }
 129 
 130     /**
 131      * Gets the <tt>wsa:MessageID</tt> header content as String.
 132      *
 133      * @return
 134      *      null if the incoming SOAP message didn't have the header.
 135      */
 136     // WsaServerTube.REQUEST_MESSAGE_ID is exposed for backward compatibility with 2.1
 137     @Property({JAXWSProperties.ADDRESSING_MESSAGEID,WsaServerTube.REQUEST_MESSAGE_ID})
 138     public String getMessageID() {
 139         if (packet.getMessage() == null) {
 140           return null;
 141         }
 142         return AddressingUtils.getMessageID(packet.getMessage().getHeaders(), addressingVersion,soapVersion);
 143     }
 144 
 145     private WSEndpointReference getEPR(QName tag) throws XMLStreamException {
 146         if (packet.getMessage() == null) {
 147           return null;
 148         }
 149         Header h = packet.getMessage().getHeaders().get(tag, false);
 150         if(h==null) return null;
 151         return h.readAsEPR(addressingVersion);
 152     }
 153 
 154     protected PropertyMap getPropertyMap() {
 155         return model;
 156     }
 157 
 158     private static final PropertyMap model;
 159     static {
 160         model = parse(WsaPropertyBag.class);
 161     }
 162