1 /*
2 * Copyright 2005-2010 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.springframework.ws.soap.addressing.core;
18
19 import java.io.Serializable;
20 import java.net.URI;
21 import java.util.Collections;
22 import java.util.List;
23
24 import org.w3c.dom.Node;
25
26 /**
27 * Represents a set of Message Addressing Properties, as defined in the WS-Addressing specification.
28 * <p/>
29 * In earlier versions of the spec, these properties were called Message Information Headers.
30 *
31 * @author Arjen Poutsma
32 * @see <a href="http://www.w3.org/TR/ws-addr-core/#msgaddrprops">Message Addressing Properties</a>
33 * @since 1.5.0
34 */
35 public final class MessageAddressingProperties implements Serializable {
36
37 private static final long serialVersionUID = -6980663311446506672L;
38
39 private final URI to;
40
41 private final EndpointReference from;
42
43 private final EndpointReference replyTo;
44
45 private final EndpointReference faultTo;
46
47 private final URI action;
48
49 private final URI messageId;
50
51 private final URI relatesTo;
52
53 private final List<Node> referenceProperties;
54
55 private final List<Node> referenceParameters;
56
57 /**
58 * Constructs a new {@link MessageAddressingProperties} with the given parameters.
59 *
60 * @param to the value of the destination property
61 * @param from the value of the source endpoint property
62 * @param replyTo the value of the reply endpoint property
63 * @param faultTo the value of the fault endpoint property
64 * @param action the value of the action property
65 * @param messageId the value of the message id property
66 */
67 public MessageAddressingProperties(URI to,
68 EndpointReference from,
69 EndpointReference replyTo,
70 EndpointReference faultTo,
71 URI action,
72 URI messageId) {
73 this.to = to;
74 this.from = from;
75 this.replyTo = replyTo;
76 this.faultTo = faultTo;
77 this.action = action;
78 this.messageId = messageId;
79 this.relatesTo = null;
80 this.referenceProperties = Collections.emptyList();
81 this.referenceParameters = Collections.emptyList();
82 }
83
84 /**
85 * Constructs a new {@link MessageAddressingProperties} that forms a reply to the given EPR.
86 *
87 * @param epr the endpoint reference to create a reply for
88 * @param action the value of the action property
89 * @param messageId the value of the message id property
90 * @param relatesTo the value of the relates to property
91 */
92 private MessageAddressingProperties(EndpointReference epr, URI action, URI messageId, URI relatesTo) {
93 this.to = epr.getAddress();
94 this.action = action;
95 this.messageId = messageId;
96 this.relatesTo = relatesTo;
97 this.referenceParameters = epr.getReferenceParameters();
98 this.referenceProperties = epr.getReferenceProperties();
99 this.from = null;
100 this.replyTo = null;
101 this.faultTo = null;
102 }
103
104 /** Returns the value of the destination property. */
105 public URI getTo() {
106 return to;
107 }
108
109 /** Returns the value of the source endpoint property. */
110 public EndpointReference getFrom() {
111 return from;
112 }
113
114 /** Returns the value of the reply endpoint property. */
115 public EndpointReference getReplyTo() {
116 return replyTo;
117 }
118
119 /** Returns the value of the fault endpoint property. */
120 public EndpointReference getFaultTo() {
121 return faultTo;
122 }
123
124 /** Returns the value of the action property. */
125 public URI getAction() {
126 return action;
127 }
128
129 /** Returns the value of the message id property. */
130 public URI getMessageId() {
131 return messageId;
132 }
133
134 /** Returns the value of the relationship property. */
135 public URI getRelatesTo() {
136 return relatesTo;
137 }
138
139 /** Returns the endpoint properties. Returns an empty list of none are set. */
140 public List<Node> getReferenceProperties() {
141 return Collections.unmodifiableList(referenceProperties);
142 }
143
144 /** Returns the endpoint parameters. Returns an empty list of none are set. */
145 public List<Node> getReferenceParameters() {
146 return Collections.unmodifiableList(referenceParameters);
147 }
148
149 /**
150 * Creates a {@link MessageAddressingProperties} that can be used for creating a reply to the given {@link
151 * EndpointReference}. The {@link #getTo() destination} property will be populated with the {@link
152 * EndpointReference#getAddress() address} of the given EPR, and the {@link #getRelatesTo() relationship} property
153 * will be set to the {@link #getMessageId() message id} property of this instance. the action is specified, the
154 *
155 * @param epr the endpoint reference to create a reply to
156 * @param action the action
157 */
158 public MessageAddressingProperties getReplyProperties(EndpointReference epr, URI action, URI messageId) {
159 return new MessageAddressingProperties(epr, action, messageId, this.messageId);
160 }
161 }