001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.ksb.api.bus.support;
017
018import org.kuali.rice.ksb.api.bus.Endpoint;
019import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
020
021/**
022 * A simple immutable implementation of an {@link Endpoint} which simply
023 * wraps a {@link ServiceConfiguration} and it's associated service implementation.
024 * 
025 * @author Kuali Rice Team (rice.collab@kuali.org)
026 * 
027 */
028public final class BasicEndpoint implements Endpoint {
029
030        private final ServiceConfiguration serviceConfiguration;
031        private final Object service;
032        
033        private BasicEndpoint(ServiceConfiguration serviceConfiguration, Object service) {
034                if (serviceConfiguration == null) {
035                        throw new IllegalArgumentException("serviceConfiguration must not be null");
036                }
037                if (service == null) {
038                        throw new IllegalArgumentException("service must not be null");
039                }
040                this.serviceConfiguration = serviceConfiguration;
041                this.service = service;
042        }
043        
044        /**
045         * Constructs a new basic endpoint from the given service configuration and
046         * service instance.
047         * 
048         * @param serviceConfiguration the service configuration to include in this endpoint
049         * @param service the service implementation instance to include in this endpoint
050         * 
051         * @return the constructed {@code BasicEndpoint} which contains the given
052         * configuration and service, will never return null
053         * 
054         * @throws IllegalArgumentException if either serviceConfiguration or service are null
055         */
056        public static BasicEndpoint newEndpoint(ServiceConfiguration serviceConfiguration, Object service) {
057                return new BasicEndpoint(serviceConfiguration, service);
058        }
059        
060        @Override
061        public ServiceConfiguration getServiceConfiguration() {
062                return serviceConfiguration;
063        }
064
065        @Override
066        public Object getService() {
067                return service;
068        }
069
070}