View Javadoc

1   /**
2    * Copyright 2005-2013 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  	private BasicEndpoint(ServiceConfiguration serviceConfiguration, Object service) {
34  		if (serviceConfiguration == null) {
35  			throw new IllegalArgumentException("serviceConfiguration must not be null");
36  		}
37  		if (service == null) {
38  			throw new IllegalArgumentException("service must not be null");
39  		}
40  		this.serviceConfiguration = serviceConfiguration;
41  		this.service = service;
42  	}
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  		return new BasicEndpoint(serviceConfiguration, service);
58  	}
59  	
60  	@Override
61  	public ServiceConfiguration getServiceConfiguration() {
62  		return serviceConfiguration;
63  	}
64  
65  	@Override
66  	public Object getService() {
67  		return service;
68  	}
69  
70  }