1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.api.registry;
17
18 import java.io.Serializable;
19 import java.util.Collection;
20
21 import javax.xml.bind.annotation.XmlAccessType;
22 import javax.xml.bind.annotation.XmlAccessorType;
23 import javax.xml.bind.annotation.XmlAnyElement;
24 import javax.xml.bind.annotation.XmlElement;
25 import javax.xml.bind.annotation.XmlRootElement;
26 import javax.xml.bind.annotation.XmlType;
27
28 import org.kuali.rice.core.api.CoreConstants;
29 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
30 import org.kuali.rice.core.api.mo.ModelBuilder;
31 import org.w3c.dom.Element;
32
33
34
35
36
37
38
39
40
41
42 @XmlRootElement(name = ServiceEndpoint.Constants.ROOT_ELEMENT_NAME)
43 @XmlAccessorType(XmlAccessType.NONE)
44 @XmlType(name = ServiceEndpoint.Constants.TYPE_NAME, propOrder = {
45 ServiceEndpoint.Elements.INFO,
46 ServiceEndpoint.Elements.DESCRIPTOR,
47 CoreConstants.CommonElements.FUTURE_ELEMENTS
48 })
49 public final class ServiceEndpoint extends AbstractDataTransferObject implements ServiceEndpointContract {
50
51 private static final long serialVersionUID = -2295962329997871877L;
52
53 @XmlElement(name = Elements.INFO, required = false)
54 private final ServiceInfo info;
55
56 @XmlElement(name = Elements.DESCRIPTOR, required = false)
57 private final ServiceDescriptor descriptor;
58
59 @SuppressWarnings("unused")
60 @XmlAnyElement
61 private final Collection<Element> _futureElements = null;
62
63
64
65
66 private ServiceEndpoint() {
67 this.info = null;
68 this.descriptor = null;
69 }
70
71 private ServiceEndpoint(Builder builder) {
72 this.info = builder.getInfo().build();
73 this.descriptor = builder.getDescriptor().build();
74 }
75
76 @Override
77 public ServiceInfo getInfo() {
78 return this.info;
79 }
80
81 @Override
82 public ServiceDescriptor getDescriptor() {
83 return this.descriptor;
84 }
85
86
87
88
89 public final static class Builder implements Serializable, ModelBuilder, ServiceEndpointContract {
90
91 private static final long serialVersionUID = -1783718474634197837L;
92
93 private ServiceInfo.Builder info;
94 private ServiceDescriptor.Builder descriptor;
95
96 private Builder(ServiceInfo.Builder info, ServiceDescriptor.Builder descriptor) {
97 setInfo(info);
98 setDescriptor(descriptor);
99 }
100
101 public static Builder create(ServiceInfo.Builder info, ServiceDescriptor.Builder descriptor) {
102 return new Builder(info, descriptor);
103 }
104
105 public static Builder create(ServiceEndpointContract contract) {
106 if (contract == null) {
107 throw new IllegalArgumentException("contract was null");
108 }
109 Builder builder = create(ServiceInfo.Builder.create(contract.getInfo()), ServiceDescriptor.Builder.create(contract.getDescriptor()));
110 return builder;
111 }
112
113 public ServiceEndpoint build() {
114 return new ServiceEndpoint(this);
115 }
116
117 @Override
118 public ServiceInfo.Builder getInfo() {
119 return this.info;
120 }
121
122 @Override
123 public ServiceDescriptor.Builder getDescriptor() {
124 return this.descriptor;
125 }
126
127 public void setInfo(ServiceInfo.Builder info) {
128 if (info == null) {
129 throw new IllegalArgumentException("info was null");
130 }
131 this.info = info;
132 }
133
134 public void setDescriptor(ServiceDescriptor.Builder descriptor) {
135 if (descriptor == null) {
136 throw new IllegalArgumentException("descriptor was null");
137 }
138 this.descriptor = descriptor;
139 }
140
141 }
142
143
144
145
146
147 static class Constants {
148
149 final static String ROOT_ELEMENT_NAME = "serviceEndpoint";
150 final static String TYPE_NAME = "ServiceEndpointType";
151
152 }
153
154
155
156
157
158 static class Elements {
159
160 final static String INFO = "info";
161 final static String DESCRIPTOR = "descriptor";
162
163 }
164
165 }