001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.ws.addressing;
019:
020: import java.util.ArrayList;
021: import java.util.List;
022:
023: import javax.xml.namespace.QName;
024:
025: /**
026: * Abstraction of Message Addressing Properties.
027: */
028: public class AddressingPropertiesImpl implements AddressingProperties {
029: private EndpointReferenceType to;
030: private EndpointReferenceType from;
031: private AttributedURIType messageID;
032: private EndpointReferenceType replyTo;
033: private EndpointReferenceType faultTo;
034: private RelatesToType relatesTo;
035: private AttributedURIType action;
036: private String namespaceURI;
037: private QName duplicate;
038: private List<QName> mustUnderstand;
039:
040: /**
041: * Constructor, defaults to 2005/08 namespace.
042: */
043: public AddressingPropertiesImpl() {
044: this (Names.WSA_NAMESPACE_NAME);
045: }
046:
047: /**
048: * Constructor.
049: *
050: * @param uri the namespace URI
051: */
052: public AddressingPropertiesImpl(String uri) {
053: namespaceURI = uri;
054: }
055:
056: public EndpointReferenceType getToEndpointReference() {
057: return to;
058: }
059:
060: /**
061: * Accessor for the <b>To</b> property.
062: * @return To property
063: */
064: public AttributedURIType getTo() {
065: return null != to ? to.getAddress() : null;
066: }
067:
068: /**
069: * Mutator for the <b>To</b> property.
070: * @param iri new value for To property
071: */
072: public void setTo(EndpointReferenceType epr) {
073: to = epr;
074: }
075:
076: /**
077: * Accessor for the <b>From</b> property.
078: * @return current value of From property
079: */
080: public EndpointReferenceType getFrom() {
081: return from;
082: }
083:
084: /**
085: * Mutator for the <b>From</b> property.
086: * @param epr new value for From property
087: */
088: public void setFrom(EndpointReferenceType epr) {
089: from = epr;
090: }
091:
092: /**
093: * Accessor for the <b>MessageID</b> property.
094: * @return current value of MessageID property
095: */
096: public AttributedURIType getMessageID() {
097: return messageID;
098: }
099:
100: /**
101: * Mutator for the <b>MessageID</b> property.
102: * @param iri new value for MessageTo property
103: */
104: public void setMessageID(AttributedURIType iri) {
105: messageID = iri;
106: }
107:
108: /**
109: * Accessor for the <b>ReplyTo</b> property.
110: * @return current value of ReplyTo property
111: */
112: public EndpointReferenceType getReplyTo() {
113: return replyTo;
114: }
115:
116: /**
117: * Mutator for the <b>ReplyTo</b> property.
118: * @param ref new value for ReplyTo property
119: */
120: public void setReplyTo(EndpointReferenceType ref) {
121: replyTo = ref;
122: }
123:
124: /**
125: * Accessor for the <b>FaultTo</b> property.
126: * @return current value of FaultTo property
127: */
128: public EndpointReferenceType getFaultTo() {
129: return faultTo;
130: }
131:
132: /**
133: * Mutator for the <b>FaultTo</b> property.
134: * @param ref new value for FaultTo property
135: */
136: public void setFaultTo(EndpointReferenceType ref) {
137: faultTo = ref;
138: }
139:
140: /**
141: * Accessor for the <b>RelatesTo</b> property.
142: * @return current value of RelatesTo property
143: */
144: public RelatesToType getRelatesTo() {
145: return relatesTo;
146: }
147:
148: /**
149: * Mutator for the <b>RelatesTo</b> property.
150: * @param rel new value for RelatesTo property
151: */
152: public void setRelatesTo(RelatesToType rel) {
153: relatesTo = rel;
154: }
155:
156: /**
157: * Accessor for the <b>Action</b> property.
158: * @return current value of Action property
159: */
160: public AttributedURIType getAction() {
161: return action;
162: }
163:
164: /**
165: * Mutator for the <b>Action</b> property.
166: * @param iri new value for Action property
167: */
168: public void setAction(AttributedURIType iri) {
169: action = iri;
170: }
171:
172: /**
173: * @return WS-Addressing namespace URI
174: */
175: public String getNamespaceURI() {
176: return namespaceURI;
177: }
178:
179: /**
180: * Used to specify a different WS-Addressing namespace URI,
181: * so as to cause MAPs to be exposed (i.e. encoded in externalized
182: * message with a different WS-Addressing version).
183: *
184: * @return WS-Addressing namespace URI
185: */
186: public void exposeAs(String uri) {
187: namespaceURI = uri;
188: }
189:
190: public void setDuplicate(QName dup) {
191: duplicate = dup;
192: }
193:
194: public QName getDuplicate() {
195: return duplicate;
196: }
197:
198: public List<QName> getMustUnderstand() {
199: if (mustUnderstand == null) {
200: mustUnderstand = new ArrayList<QName>();
201: }
202: return mustUnderstand;
203: }
204:
205: public String toString() {
206: StringBuffer buf = new StringBuffer();
207: buf.append("[");
208: if (null != messageID) {
209: if (buf.length() > 1) {
210: buf.append(", ");
211: }
212: buf.append("MessageId: ");
213: buf.append(messageID.getValue());
214: }
215: if (null != action) {
216: if (buf.length() > 1) {
217: buf.append(", ");
218: }
219: buf.append("Action: ");
220: buf.append(action.getValue());
221: }
222: if (null != to) {
223: if (buf.length() > 1) {
224: buf.append(", ");
225: }
226: buf.append("To: ");
227: buf.append(to.getAddress().getValue());
228: }
229: if (null != replyTo) {
230: AttributedURIType address = replyTo.getAddress();
231: if (null != address) {
232: if (buf.length() > 1) {
233: buf.append(", ");
234: }
235: buf.append("ReplyTo: ");
236: buf.append(address.getValue());
237: }
238: }
239: if (null != faultTo) {
240: AttributedURIType address = faultTo.getAddress();
241: if (null != address) {
242: if (buf.length() > 1) {
243: buf.append(", ");
244: }
245: buf.append("FaultTo: ");
246: buf.append(address.getValue());
247: }
248: }
249: if (null != relatesTo) {
250: if (buf.length() > 1) {
251: buf.append(", ");
252: }
253: buf.append("RelatesTo: ");
254: buf.append(relatesTo.getValue());
255: }
256: buf.append("]");
257: return buf.toString();
258:
259: }
260: }
|