001 /** 002 * Copyright 2005-2014 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 */ 016 package org.kuali.rice.ksb.messaging.serviceconnectors; 017 018 import java.net.URL; 019 020 import org.kuali.rice.ksb.api.bus.support.RestServiceConfiguration; 021 022 023 /** 024 * Connector (provider of client proxys) for RESTful services. 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 * @since 0.9 027 */ 028 public class RESTConnector extends AbstractServiceConnector { 029 030 public RESTConnector(final RestServiceConfiguration serviceConfiguration, final URL alternateEndpointUrl) { 031 super(serviceConfiguration, alternateEndpointUrl); 032 } 033 034 @Override 035 public RestServiceConfiguration getServiceConfiguration() { 036 return (RestServiceConfiguration)super.getServiceConfiguration(); 037 } 038 039 /** 040 * @return a resource facade that wraps the CXF client proxies for these resources 041 * @see org.kuali.rice.ksb.messaging.serviceconnectors.ServiceConnector#getService() 042 */ 043 public Object getService() { 044 ResourceFacadeImpl resourceFacade = new ResourceFacadeImpl(getServiceConfiguration(), getActualEndpointUrl()); 045 resourceFacade.setCredentialsSource(getCredentialsSource()); 046 047 if (resourceFacade.isSingleResourceService()) 048 return resourceFacade.getResource((String)null); 049 050 return resourceFacade; 051 } 052 053 }