1 /*
2 * Copyright (c) 2005, 2015, 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
55 * pass/return endpoint references that represent the W3C WS-Addressing
56 * recommendation.
57 * <p>
58 * JAXB will use the JAXB annotations and bind this class to XML infoset
59 * that is consistent with that defined by WS-Addressing. See
60 * <a href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/">
61 * WS-Addressing</a>
62 * for more information on WS-Addressing EndpointReferences.
63 *
64 * @since 1.6, JAX-WS 2.1
65 */
66
67 // XmlRootElement allows this class to be marshalled on its own
68 @XmlRootElement(name="EndpointReference",namespace=W3CEndpointReference.NS)
69 @XmlType(name="EndpointReferenceType",namespace=W3CEndpointReference.NS)
70 public final class W3CEndpointReference extends EndpointReference {
71
72 private final JAXBContext w3cjc = getW3CJaxbContext();
73
74 // should be changed to package private, keeping original modifier to keep backwards compatibility
75 protected static final String NS = "http://www.w3.org/2005/08/addressing";
76
77 // default constructor forbidden ...
78 // should be private, keeping original modifier to keep backwards compatibility
79 protected W3CEndpointReference() {
80 }
81
82 /**
83 * Creates an EPR from infoset representation
84 *
85 * @param source A source object containing valid XmlInfoset
86 * instance consistent with the W3C WS-Addressing Core
87 * recommendation.
88 *
89 * @throws WebServiceException
90 * If the source does NOT contain a valid W3C WS-Addressing
91 * EndpointReference.
92 * @throws NullPointerException
93 * If the {@code null} {@code source} value is given
94 */
95 public W3CEndpointReference(Source source) {
96 try {
97 W3CEndpointReference epr = w3cjc.createUnmarshaller().unmarshal(source,W3CEndpointReference.class).getValue();
98 this.address = epr.address;
99 this.metadata = epr.metadata;
100 this.referenceParameters = epr.referenceParameters;
101 this.elements = epr.elements;
102 this.attributes = epr.attributes;
103 } catch (JAXBException e) {
104 throw new WebServiceException("Error unmarshalling W3CEndpointReference " ,e);
105 } catch (ClassCastException e) {
106 throw new WebServiceException("Source did not contain W3CEndpointReference", e);
107 }
108 }
109
110 /**
111 * {@inheritDoc}
112 */
113 public void writeTo(Result result){
114 try {
115 Marshaller marshaller = w3cjc.createMarshaller();
116 marshaller.marshal(this, result);
117 } catch (JAXBException e) {
118 throw new WebServiceException("Error marshalling W3CEndpointReference. ", e);
119 }
120 }
121
122 private static JAXBContext getW3CJaxbContext() {
123 try {
124 return JAXBContext.newInstance(W3CEndpointReference.class);
125 } catch (JAXBException e) {
126 throw new WebServiceException("Error creating JAXBContext for W3CEndpointReference. ", e);
127 }
128 }
129
130 // private but necessary properties for databinding
131 @XmlElement(name="Address",namespace=NS)
132 private Address address;
|
1 /*
2 * Copyright (c) 2005, 2017, 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
55 * pass/return endpoint references that represent the W3C WS-Addressing
56 * recommendation.
57 * <p>
58 * JAXB will use the JAXB annotations and bind this class to XML infoset
59 * that is consistent with that defined by WS-Addressing. See
60 * <a href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/">
61 * WS-Addressing</a>
62 * for more information on WS-Addressing EndpointReferences.
63 *
64 * @since 1.6, JAX-WS 2.1
65 */
66
67 // XmlRootElement allows this class to be marshalled on its own
68 @XmlRootElement(name="EndpointReference",namespace=W3CEndpointReference.NS)
69 @XmlType(name="EndpointReferenceType",namespace=W3CEndpointReference.NS)
70 public final class W3CEndpointReference extends EndpointReference {
71
72 private final JAXBContext w3cjc = getW3CJaxbContext();
73
74 // should be changed to package private, keeping original modifier to keep backwards compatibility
75
76 /**
77 * Addressing namespace.
78 */
79 protected static final String NS = "http://www.w3.org/2005/08/addressing";
80
81 // default constructor forbidden ...
82 // should be private, keeping original modifier to keep backwards compatibility
83
84 /**
85 * Default constructor.
86 */
87 protected W3CEndpointReference() {
88 }
89
90 /**
91 * Creates an EPR from infoset representation
92 *
93 * @param source A source object containing valid XmlInfoset
94 * instance consistent with the W3C WS-Addressing Core
95 * recommendation.
96 *
97 * @throws WebServiceException
98 * If the source does NOT contain a valid W3C WS-Addressing
99 * EndpointReference.
100 * @throws NullPointerException
101 * If the {@code null} {@code source} value is given
102 */
103 public W3CEndpointReference(Source source) {
104 try {
105 W3CEndpointReference epr = w3cjc.createUnmarshaller().unmarshal(source,W3CEndpointReference.class).getValue();
106 this.address = epr.address;
107 this.metadata = epr.metadata;
108 this.referenceParameters = epr.referenceParameters;
109 this.elements = epr.elements;
110 this.attributes = epr.attributes;
111 } catch (JAXBException e) {
112 throw new WebServiceException("Error unmarshalling W3CEndpointReference " ,e);
113 } catch (ClassCastException e) {
114 throw new WebServiceException("Source did not contain W3CEndpointReference", e);
115 }
116 }
117
118 /**
119 * {@inheritDoc}
120 */
121 @Override
122 public void writeTo(Result result){
123 try {
124 Marshaller marshaller = w3cjc.createMarshaller();
125 marshaller.marshal(this, result);
126 } catch (JAXBException e) {
127 throw new WebServiceException("Error marshalling W3CEndpointReference. ", e);
128 }
129 }
130
131 private static JAXBContext getW3CJaxbContext() {
132 try {
133 return JAXBContext.newInstance(W3CEndpointReference.class);
134 } catch (JAXBException e) {
135 throw new WebServiceException("Error creating JAXBContext for W3CEndpointReference. ", e);
136 }
137 }
138
139 // private but necessary properties for databinding
140 @XmlElement(name="Address",namespace=NS)
141 private Address address;
|