1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package javax.xml.ws.wsaddressing;
21
22 import org.w3c.dom.Element;
23
24 import javax.xml.namespace.QName;
25 import javax.xml.ws.spi.Provider;
26 import java.util.ArrayList;
27 import java.util.List;
28
29 public final class W3CEndpointReferenceBuilder {
30 private String address;
31 private QName serviceName;
32 private QName endpointName;
33 private String wsdlDocumentLocation;
34 private List<Element> referenceParameters;
35 private List<Element> metadataElements;
36
37 public W3CEndpointReferenceBuilder() {
38 }
39
40 public W3CEndpointReferenceBuilder address(String address) {
41 this.address = address;
42 return this;
43 }
44
45 public W3CEndpointReferenceBuilder serviceName(QName serviceName) {
46 this.serviceName = serviceName;
47 return this;
48 }
49
50 public W3CEndpointReferenceBuilder endpointName(QName endpointName) {
51
52 if (this.serviceName == null) {
53 throw new IllegalStateException("The endpoint qname cannot be set before the service qname.");
54 }
55
56 this.endpointName = endpointName;
57 return this;
58 }
59
60 public W3CEndpointReferenceBuilder wsdlDocumentLocation(String wsdlDocumentLocation) {
61 this.wsdlDocumentLocation = wsdlDocumentLocation;
62 return this;
63 }
64
65 public W3CEndpointReferenceBuilder referenceParameter(Element referenceParameter) {
66
67 if (referenceParameter == null) {
68 throw new IllegalArgumentException("A reference parameter cannot be null.");
69 }
70
71 if (this.referenceParameters == null) {
72 this.referenceParameters = new ArrayList<Element>();
73 }
74
75 this.referenceParameters.add(referenceParameter);
76 return this;
77 }
78
79 public W3CEndpointReferenceBuilder metadata(Element metadataElement) {
80
81 if (metadataElement == null) {
82 throw new IllegalArgumentException("A metadata element cannot be null.");
83 }
84
85 if (this.metadataElements == null) {
86 this.metadataElements = new ArrayList<Element>();
87 }
88
89 this.metadataElements.add(metadataElement);
90 return this;
91 }
92
93 public W3CEndpointReference build() {
94 return Provider.provider().createW3CEndpointReference(address,
95 serviceName,
96 endpointName,
97 metadataElements,
98 wsdlDocumentLocation,
99 referenceParameters);
100 }
101
102 @Override
103 public String toString() {
104
105 return super.toString();
106 }
107 }