Coverage Report - org.kuali.rice.ksb.messaging.serviceconnectors.AbstractServiceConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractServiceConnector
0%
0/16
0%
0/2
1.286
 
 1  
 /*
 2  
  * Copyright 2007 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.messaging.serviceconnectors;
 17  
 
 18  
 import java.net.URL;
 19  
 
 20  
 import org.kuali.rice.core.api.security.credentials.CredentialsSource;
 21  
 import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
 22  
 import org.kuali.rice.ksb.messaging.BusClientFailureProxy;
 23  
 import org.kuali.rice.ksb.messaging.bam.BAMClientProxy;
 24  
 import org.springframework.util.Assert;
 25  
 
 26  
 
 27  
 /**
 28  
  * Abstract implementation of the ServiceConnector that holds the ServiceInfo
 29  
  * and the CredentialsSource as well as providing convenience proxy methods.
 30  
  * 
 31  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 32  
  * @since 0.9
 33  
  * 
 34  
  */
 35  
 public abstract class AbstractServiceConnector implements ServiceConnector {
 36  
 
 37  
         /**
 38  
          * Maintains the information about the service.  This should never be null.
 39  
          */
 40  
         private ServiceConfiguration serviceConfiguration;
 41  
         private URL alternateEndpointUrl;
 42  
 
 43  
         /**
 44  
          * Maintains the credentials needed by the service.  This may be null.
 45  
          */
 46  
         private CredentialsSource credentialsSource;
 47  
 
 48  
         public AbstractServiceConnector(final ServiceConfiguration serviceConfiguration) {
 49  0
                 this(serviceConfiguration, null);
 50  0
         }
 51  
         
 52  0
         public AbstractServiceConnector(final ServiceConfiguration serviceConfiguration, URL alternateEndpointUrl) {
 53  0
                 Assert.notNull(serviceConfiguration, "serviceConfiguration cannot be null");
 54  0
                 this.serviceConfiguration = serviceConfiguration;
 55  0
                 this.alternateEndpointUrl = alternateEndpointUrl;
 56  0
         }
 57  
         
 58  
         public URL getActualEndpointUrl() {
 59  0
                 if (alternateEndpointUrl != null) {
 60  0
             return alternateEndpointUrl;
 61  
         }
 62  0
         return getServiceConfiguration().getEndpointUrl();
 63  
         }
 64  
 
 65  
         public ServiceConfiguration getServiceConfiguration() {
 66  0
                 return this.serviceConfiguration;
 67  
         }
 68  
 
 69  
         public void setCredentialsSource(final CredentialsSource credentialsSource) {
 70  0
                 this.credentialsSource = credentialsSource;
 71  0
         }
 72  
 
 73  
         protected CredentialsSource getCredentialsSource() {
 74  0
                 return this.credentialsSource;
 75  
         }
 76  
 
 77  
         protected Object getServiceProxyWithFailureMode(final Object service,
 78  
                         final ServiceConfiguration serviceConfiguration) {
 79  0
                 Object bamWrappedClientProxy = BAMClientProxy.wrap(service, serviceConfiguration);
 80  0
                 return BusClientFailureProxy.wrap(bamWrappedClientProxy, serviceConfiguration);
 81  
         }
 82  
 }