| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BasicEndpoint |
|
| 2.0;2 |
| 1 | /** | |
| 2 | * Copyright 2005-2011 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php | |
| 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 | package org.kuali.rice.ksb.api.bus.support; | |
| 17 | ||
| 18 | import org.kuali.rice.ksb.api.bus.Endpoint; | |
| 19 | import org.kuali.rice.ksb.api.bus.ServiceConfiguration; | |
| 20 | ||
| 21 | /** | |
| 22 | * A simple immutable implementation of an {@link Endpoint} which simply | |
| 23 | * wraps a {@link ServiceConfiguration} and it's associated service implementation. | |
| 24 | * | |
| 25 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 26 | * | |
| 27 | */ | |
| 28 | public final class BasicEndpoint implements Endpoint { | |
| 29 | ||
| 30 | private final ServiceConfiguration serviceConfiguration; | |
| 31 | private final Object service; | |
| 32 | ||
| 33 | 0 | private BasicEndpoint(ServiceConfiguration serviceConfiguration, Object service) { |
| 34 | 0 | if (serviceConfiguration == null) { |
| 35 | 0 | throw new IllegalArgumentException("serviceConfiguration must not be null"); |
| 36 | } | |
| 37 | 0 | if (service == null) { |
| 38 | 0 | throw new IllegalArgumentException("service must not be null"); |
| 39 | } | |
| 40 | 0 | this.serviceConfiguration = serviceConfiguration; |
| 41 | 0 | this.service = service; |
| 42 | 0 | } |
| 43 | ||
| 44 | /** | |
| 45 | * Constructs a new basic endpoint from the given service configuration and | |
| 46 | * service instance. | |
| 47 | * | |
| 48 | * @param serviceConfiguration the service configuration to include in this endpoint | |
| 49 | * @param service the service implementation instance to include in this endpoint | |
| 50 | * | |
| 51 | * @return the constructed {@code BasicEndpoint} which contains the given | |
| 52 | * configuration and service, will never return null | |
| 53 | * | |
| 54 | * @throws IllegalArgumentException if either serviceConfiguration or service are null | |
| 55 | */ | |
| 56 | public static BasicEndpoint newEndpoint(ServiceConfiguration serviceConfiguration, Object service) { | |
| 57 | 0 | return new BasicEndpoint(serviceConfiguration, service); |
| 58 | } | |
| 59 | ||
| 60 | @Override | |
| 61 | public ServiceConfiguration getServiceConfiguration() { | |
| 62 | 0 | return serviceConfiguration; |
| 63 | } | |
| 64 | ||
| 65 | @Override | |
| 66 | public Object getService() { | |
| 67 | 0 | return service; |
| 68 | } | |
| 69 | ||
| 70 | } |