001/** 002 * Copyright 2005-2015 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.messaging.serviceconnectors; 017 018import javax.xml.namespace.QName; 019 020import org.kuali.rice.ksb.api.KsbApiServiceLocator; 021import org.kuali.rice.ksb.api.bus.Endpoint; 022import org.kuali.rice.ksb.api.bus.ServiceConfiguration; 023import org.kuali.rice.ksb.messaging.bam.BAMClientProxy; 024 025 026/** 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030public class BusLocalConnector extends AbstractServiceConnector { 031 032 public BusLocalConnector(final ServiceConfiguration serviceConfiguration) { 033 super(serviceConfiguration); 034 } 035 036 private Object getServiceProxy(Object service) { 037 return BAMClientProxy.wrap(service, getServiceConfiguration()); 038 } 039 040 public Object getService() { 041 QName serviceName = getServiceConfiguration().getServiceName(); 042 Endpoint localServiceEndpoint = KsbApiServiceLocator.getServiceBus().getLocalEndpoint(serviceName); 043 if (localServiceEndpoint == null) { 044 throw new IllegalStateException("Failed to locate a local service with the name: " + serviceName); 045 } 046 return getServiceProxy(KsbApiServiceLocator.getServiceBus().getLocalEndpoint(serviceName)); 047 } 048 049}