Sun, 15 Dec 2013 23:35:45 +0100
8025152: Enhance activation set up
8028388: 9 jaxws tests failed in nightly build with java.lang.ClassCastException
Summary: fix also reviewed by Bill Shannon, Alexander Fomin
Reviewed-by: dfuchs, hawtin, mgrebac
Contributed-by: bill.shannon@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.developer; |
ohair@286 | 27 | |
ohair@286 | 28 | import com.sun.istack.internal.NotNull; |
ohair@286 | 29 | import com.sun.xml.internal.ws.addressing.v200408.MemberSubmissionAddressingConstants; |
ohair@286 | 30 | import com.sun.xml.internal.ws.wsdl.parser.WSDLConstants; |
ohair@286 | 31 | import org.w3c.dom.Element; |
ohair@286 | 32 | |
ohair@286 | 33 | import javax.xml.bind.JAXBContext; |
ohair@286 | 34 | import javax.xml.bind.JAXBException; |
ohair@286 | 35 | import javax.xml.bind.Marshaller; |
ohair@286 | 36 | import javax.xml.bind.Unmarshaller; |
ohair@286 | 37 | import javax.xml.bind.annotation.XmlAnyAttribute; |
ohair@286 | 38 | import javax.xml.bind.annotation.XmlAnyElement; |
ohair@286 | 39 | import javax.xml.bind.annotation.XmlAttribute; |
ohair@286 | 40 | import javax.xml.bind.annotation.XmlElement; |
ohair@286 | 41 | import javax.xml.bind.annotation.XmlRootElement; |
ohair@286 | 42 | import javax.xml.bind.annotation.XmlType; |
ohair@286 | 43 | import javax.xml.bind.annotation.XmlValue; |
ohair@286 | 44 | import javax.xml.namespace.QName; |
ohair@286 | 45 | import javax.xml.transform.Result; |
ohair@286 | 46 | import javax.xml.transform.Source; |
ohair@286 | 47 | import javax.xml.transform.dom.DOMSource; |
ohair@286 | 48 | import javax.xml.ws.EndpointReference; |
ohair@286 | 49 | import javax.xml.ws.WebServiceException; |
ohair@286 | 50 | import java.util.List; |
ohair@286 | 51 | import java.util.Map; |
ohair@286 | 52 | |
ohair@286 | 53 | /** |
ohair@286 | 54 | * Data model for Member Submission WS-Addressing specification. This is modeled after the |
ohair@286 | 55 | * member submission schema at: |
ohair@286 | 56 | * |
ohair@286 | 57 | * http://schemas.xmlsoap.org/ws/2004/08/addressing/ |
ohair@286 | 58 | * |
ohair@286 | 59 | * @author Kathy Walsh |
ohair@286 | 60 | * @author Vivek Pandey |
ohair@286 | 61 | */ |
ohair@286 | 62 | |
ohair@286 | 63 | @XmlRootElement(name = "EndpointReference", namespace = MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 64 | @XmlType(name = "EndpointReferenceType", namespace = MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 65 | public final class MemberSubmissionEndpointReference extends EndpointReference implements MemberSubmissionAddressingConstants { |
ohair@286 | 66 | |
ohair@286 | 67 | private final static JAXBContext msjc = MemberSubmissionEndpointReference.getMSJaxbContext(); |
ohair@286 | 68 | |
ohair@286 | 69 | public MemberSubmissionEndpointReference() { |
ohair@286 | 70 | } |
ohair@286 | 71 | |
ohair@286 | 72 | /** |
ohair@286 | 73 | * construct an EPR from infoset representation |
ohair@286 | 74 | * |
ohair@286 | 75 | * @param source A source object containing valid XmlInfoset |
ohair@286 | 76 | * instance consistent with the Member Submission WS-Addressing |
ohair@286 | 77 | * @throws javax.xml.ws.WebServiceException |
ohair@286 | 78 | * if the source does not contain a valid W3C WS-Addressing |
ohair@286 | 79 | * EndpointReference. |
ohair@286 | 80 | * @throws WebServiceException if the <code>null</code> <code>source</code> value is given |
ohair@286 | 81 | */ |
ohair@286 | 82 | public MemberSubmissionEndpointReference(@NotNull Source source) { |
ohair@286 | 83 | |
alanb@368 | 84 | if (source == null) { |
ohair@286 | 85 | throw new WebServiceException("Source parameter can not be null on constructor"); |
alanb@368 | 86 | } |
ohair@286 | 87 | |
ohair@286 | 88 | try { |
ohair@286 | 89 | Unmarshaller unmarshaller = MemberSubmissionEndpointReference.msjc.createUnmarshaller(); |
ohair@286 | 90 | MemberSubmissionEndpointReference epr = unmarshaller.unmarshal(source,MemberSubmissionEndpointReference.class).getValue(); |
ohair@286 | 91 | |
ohair@286 | 92 | this.addr = epr.addr; |
ohair@286 | 93 | this.referenceProperties = epr.referenceProperties; |
ohair@286 | 94 | this.referenceParameters = epr.referenceParameters; |
ohair@286 | 95 | this.portTypeName = epr.portTypeName; |
ohair@286 | 96 | this.serviceName = epr.serviceName; |
ohair@286 | 97 | this.attributes = epr.attributes; |
ohair@286 | 98 | this.elements = epr.elements; |
ohair@286 | 99 | } catch (JAXBException e) { |
ohair@286 | 100 | throw new WebServiceException("Error unmarshalling MemberSubmissionEndpointReference ", e); |
ohair@286 | 101 | } catch (ClassCastException e) { |
ohair@286 | 102 | throw new WebServiceException("Source did not contain MemberSubmissionEndpointReference", e); |
ohair@286 | 103 | } |
ohair@286 | 104 | } |
ohair@286 | 105 | |
alanb@368 | 106 | @Override |
ohair@286 | 107 | public void writeTo(Result result) { |
ohair@286 | 108 | try { |
ohair@286 | 109 | Marshaller marshaller = MemberSubmissionEndpointReference.msjc.createMarshaller(); |
ohair@286 | 110 | //marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); |
ohair@286 | 111 | marshaller.marshal(this, result); |
ohair@286 | 112 | } catch (JAXBException e) { |
ohair@286 | 113 | throw new WebServiceException("Error marshalling W3CEndpointReference. ", e); |
ohair@286 | 114 | } |
ohair@286 | 115 | } |
ohair@286 | 116 | |
ohair@286 | 117 | /** |
ohair@286 | 118 | * Constructs a Source containing the wsdl from the MemberSubmissionEndpointReference |
ohair@286 | 119 | * |
ohair@286 | 120 | * @return Source A source object containing the wsdl in the MemeberSubmissionEndpointReference, if present. |
ohair@286 | 121 | */ |
ohair@286 | 122 | public Source toWSDLSource() { |
ohair@286 | 123 | Element wsdlElement = null; |
ohair@286 | 124 | |
ohair@286 | 125 | for (Element elem : elements) { |
ohair@286 | 126 | if (elem.getNamespaceURI().equals(WSDLConstants.NS_WSDL) && |
ohair@286 | 127 | elem.getLocalName().equals(WSDLConstants.QNAME_DEFINITIONS.getLocalPart())) { |
ohair@286 | 128 | wsdlElement = elem; |
ohair@286 | 129 | } |
ohair@286 | 130 | } |
ohair@286 | 131 | |
ohair@286 | 132 | return new DOMSource(wsdlElement); |
ohair@286 | 133 | } |
ohair@286 | 134 | |
ohair@286 | 135 | |
ohair@286 | 136 | private static JAXBContext getMSJaxbContext() { |
ohair@286 | 137 | try { |
ohair@286 | 138 | return JAXBContext.newInstance(MemberSubmissionEndpointReference.class); |
ohair@286 | 139 | } catch (JAXBException e) { |
ohair@286 | 140 | throw new WebServiceException("Error creating JAXBContext for MemberSubmissionEndpointReference. ", e); |
ohair@286 | 141 | } |
ohair@286 | 142 | } |
ohair@286 | 143 | |
ohair@286 | 144 | @XmlElement(name = "Address", namespace = MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 145 | public Address addr; |
ohair@286 | 146 | |
ohair@286 | 147 | @XmlElement(name = "ReferenceProperties", namespace = MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 148 | public Elements referenceProperties; |
ohair@286 | 149 | |
ohair@286 | 150 | @XmlElement(name = "ReferenceParameters", namespace = MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 151 | public Elements referenceParameters; |
ohair@286 | 152 | |
ohair@286 | 153 | @XmlElement(name = "PortType", namespace = MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 154 | public AttributedQName portTypeName; |
ohair@286 | 155 | |
ohair@286 | 156 | @XmlElement(name = "ServiceName", namespace = MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 157 | public ServiceNameType serviceName; |
ohair@286 | 158 | |
ohair@286 | 159 | @XmlAnyAttribute |
ohair@286 | 160 | public Map<QName,String> attributes; |
ohair@286 | 161 | |
ohair@286 | 162 | @XmlAnyElement |
ohair@286 | 163 | public List<Element> elements; |
ohair@286 | 164 | |
alanb@368 | 165 | @XmlType(name="address", namespace=MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 166 | public static class Address { |
ohair@286 | 167 | public Address() { |
ohair@286 | 168 | } |
ohair@286 | 169 | |
ohair@286 | 170 | @XmlValue |
ohair@286 | 171 | public String uri; |
ohair@286 | 172 | @XmlAnyAttribute |
ohair@286 | 173 | public Map<QName, String> attributes; |
ohair@286 | 174 | } |
ohair@286 | 175 | |
alanb@368 | 176 | @XmlType(name="elements", namespace=MemberSubmissionEndpointReference.MSNS) |
ohair@286 | 177 | public static class Elements { |
ohair@286 | 178 | public Elements() {} |
ohair@286 | 179 | |
ohair@286 | 180 | @XmlAnyElement |
ohair@286 | 181 | public List<Element> elements; |
ohair@286 | 182 | } |
ohair@286 | 183 | |
ohair@286 | 184 | |
ohair@286 | 185 | public static class AttributedQName { |
ohair@286 | 186 | public AttributedQName() { |
ohair@286 | 187 | } |
ohair@286 | 188 | |
ohair@286 | 189 | @XmlValue |
ohair@286 | 190 | public QName name; |
ohair@286 | 191 | @XmlAnyAttribute |
ohair@286 | 192 | public Map<QName, String> attributes; |
ohair@286 | 193 | } |
ohair@286 | 194 | |
ohair@286 | 195 | public static class ServiceNameType extends AttributedQName{ |
ohair@286 | 196 | public ServiceNameType() { |
ohair@286 | 197 | } |
ohair@286 | 198 | |
ohair@286 | 199 | @XmlAttribute(name="PortName") |
ohair@286 | 200 | public String portName; |
ohair@286 | 201 | } |
ohair@286 | 202 | |
ohair@286 | 203 | protected static final String MSNS = "http://schemas.xmlsoap.org/ws/2004/08/addressing"; |
ohair@286 | 204 | } |