View Javadoc

1   /*
2    * Copyright 2007 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  /**
25   * Represents a set of Message Addressing Properties, as defined in the WS-Addressing specification.
26   * <p/>
27   * In earlier versions of the spec, these properties were called Message Information Headers.
28   *
29   * @author Arjen Poutsma
30   * @see <a href="http://www.w3.org/TR/ws-addr-core/#msgaddrprops">Message Addressing Properties</a>
31   * @since 1.5.0
32   */
33  public final class MessageAddressingProperties implements Serializable {
34  
35      private static final long serialVersionUID = -6980663311446506672L;
36  
37      private final URI to;
38  
39      private final EndpointReference from;
40  
41      private final EndpointReference replyTo;
42  
43      private final EndpointReference faultTo;
44  
45      private final URI action;
46  
47      private final URI messageId;
48  
49      private final URI relatesTo;
50  
51      private final List referenceProperties;
52  
53      private final List referenceParameters;
54  
55      /**
56       * Constructs a new {@link MessageAddressingProperties} with the given parameters.
57       *
58       * @param to        the value of the destination property
59       * @param from      the value of the source endpoint property
60       * @param replyTo   the value of the reply endpoint property
61       * @param faultTo   the value of the fault endpoint property
62       * @param action    the value of the action property
63       * @param messageId the value of the message id property
64       */
65      public MessageAddressingProperties(URI to,
66                                         EndpointReference from,
67                                         EndpointReference replyTo,
68                                         EndpointReference faultTo,
69                                         URI action,
70                                         URI messageId) {
71          this.to = to;
72          this.from = from;
73          this.replyTo = replyTo;
74          this.faultTo = faultTo;
75          this.action = action;
76          this.messageId = messageId;
77          this.relatesTo = null;
78          this.referenceProperties = Collections.EMPTY_LIST;
79          this.referenceParameters = Collections.EMPTY_LIST;
80      }
81  
82      /**
83       * Constructs a new {@link MessageAddressingProperties} that forms a reply to the given EPR.
84       *
85       * @param epr       the endpoint reference to create a reply for
86       * @param action    the value of the action property
87       * @param messageId the value of the message id property
88       * @param relatesTo the value of the relates to property
89       */
90      private MessageAddressingProperties(EndpointReference epr, URI action, URI messageId, URI relatesTo) {
91          this.to = epr.getAddress();
92          this.action = action;
93          this.messageId = messageId;
94          this.relatesTo = relatesTo;
95          this.referenceParameters = epr.getReferenceParameters();
96          this.referenceProperties = epr.getReferenceProperties();
97          this.from = null;
98          this.replyTo = null;
99          this.faultTo = null;
100     }
101 
102     /** Returns the value of the destination property. */
103     public URI getTo() {
104         return to;
105     }
106 
107     /** Returns the value of the source endpoint property. */
108     public EndpointReference getFrom() {
109         return from;
110     }
111 
112     /** Returns the value of the reply endpoint property. */
113     public EndpointReference getReplyTo() {
114         return replyTo;
115     }
116 
117     /** Returns the value of the fault endpoint property. */
118     public EndpointReference getFaultTo() {
119         return faultTo;
120     }
121 
122     /** Returns the value of the action property. */
123     public URI getAction() {
124         return action;
125     }
126 
127     /** Returns the value of the message id property. */
128     public URI getMessageId() {
129         return messageId;
130     }
131 
132     /** Returns the value of the relationship property. */
133     public URI getRelatesTo() {
134         return relatesTo;
135     }
136 
137     /** Returns the endpoint properties. Returns an empty list of none are set. */
138     public List getReferenceProperties() {
139         return Collections.unmodifiableList(referenceProperties);
140     }
141 
142     /** Returns the endpoint parameters. Returns an empty list of none are set. */
143     public List getReferenceParameters() {
144         return Collections.unmodifiableList(referenceParameters);
145     }
146 
147     /**
148      * Creates a {@link MessageAddressingProperties} that can be used for creating a reply to the given {@link
149      * EndpointReference}. The {@link #getTo() destination} property will be populated with the {@link
150      * EndpointReference#getAddress() address} of the given EPR, and the {@link #getRelatesTo() relationship} property
151      * will be set to the {@link #getMessageId() message id} property of this instance. the action is specified, the
152      *
153      * @param epr    the endpoint reference to create a reply to
154      * @param action the action
155      */
156     public MessageAddressingProperties getReplyProperties(EndpointReference epr, URI action, URI messageId) {
157         return new MessageAddressingProperties(epr, action, messageId, this.messageId);
158     }
159 }