Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BasicEndpoint |
|
| 2.0;2 |
1 | package org.kuali.rice.ksb.api.bus.support; | |
2 | ||
3 | import org.kuali.rice.ksb.api.bus.Endpoint; | |
4 | import org.kuali.rice.ksb.api.bus.ServiceConfiguration; | |
5 | ||
6 | /** | |
7 | * A simple immutable implementation of an {@link Endpoint} which simply | |
8 | * wraps a {@link ServiceConfiguration} and it's associated service implementation. | |
9 | * | |
10 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
11 | * | |
12 | */ | |
13 | public final class BasicEndpoint implements Endpoint { | |
14 | ||
15 | private final ServiceConfiguration serviceConfiguration; | |
16 | private final Object service; | |
17 | ||
18 | 0 | private BasicEndpoint(ServiceConfiguration serviceConfiguration, Object service) { |
19 | 0 | if (serviceConfiguration == null) { |
20 | 0 | throw new IllegalArgumentException("serviceConfiguration must not be null"); |
21 | } | |
22 | 0 | if (service == null) { |
23 | 0 | throw new IllegalArgumentException("service must not be null"); |
24 | } | |
25 | 0 | this.serviceConfiguration = serviceConfiguration; |
26 | 0 | this.service = service; |
27 | 0 | } |
28 | ||
29 | /** | |
30 | * Constructs a new basic endpoint from the given service configuration and | |
31 | * service instance. | |
32 | * | |
33 | * @param serviceConfiguration the service configuration to include in this endpoint | |
34 | * @param service the service implementation instance to include in this endpoint | |
35 | * | |
36 | * @return the constructed {@code BasicEndpoint} which contains the given | |
37 | * configuration and service, will never return null | |
38 | * | |
39 | * @throws IllegalArgumentException if either serviceConfiguration or service are null | |
40 | */ | |
41 | public static BasicEndpoint newEndpoint(ServiceConfiguration serviceConfiguration, Object service) { | |
42 | 0 | return new BasicEndpoint(serviceConfiguration, service); |
43 | } | |
44 | ||
45 | @Override | |
46 | public ServiceConfiguration getServiceConfiguration() { | |
47 | 0 | return serviceConfiguration; |
48 | } | |
49 | ||
50 | @Override | |
51 | public Object getService() { | |
52 | 0 | return service; |
53 | } | |
54 | ||
55 | } |