Coverage Report - org.kuali.rice.ksb.messaging.serviceproxies.SynchronousServiceCallProxy
 
Classes in this File Line Coverage Branch Coverage Complexity
SynchronousServiceCallProxy
0%
0/10
0%
0/6
3.333
 
 1  
 /*
 2  
  * Copyright 2006-2011 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  
 
 17  
 package org.kuali.rice.ksb.messaging.serviceproxies;
 18  
 
 19  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 20  
 import org.kuali.rice.core.api.exception.RiceRuntimeException;
 21  
 import org.kuali.rice.core.api.util.ClassLoaderUtils;
 22  
 import org.kuali.rice.core.impl.resourceloader.ContextClassLoaderProxy;
 23  
 import org.kuali.rice.ksb.api.bus.Endpoint;
 24  
 import org.kuali.rice.ksb.api.messaging.AsynchronousCallback;
 25  
 import org.kuali.rice.ksb.messaging.MessageServiceInvoker;
 26  
 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
 27  
 import org.kuali.rice.ksb.util.KSBConstants;
 28  
 
 29  
 import java.io.Serializable;
 30  
 import java.lang.reflect.Proxy;
 31  
 import java.util.List;
 32  
 
 33  
 
 34  
 /**
 35  
  * Used to Call a service synchronously but through the messaging code within workflow. Used to when switching generally
 36  
  * asynchronously called services to synchronously called services. Generally for testing purposes.
 37  
  * 
 38  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 39  
  * 
 40  
  */
 41  
 public class SynchronousServiceCallProxy extends AsynchronousServiceCallProxy {
 42  
 
 43  
     private SynchronousServiceCallProxy(List<Endpoint> endpoints, AsynchronousCallback callback,
 44  
             Serializable context, String value1, String value2) {
 45  0
         super(endpoints, callback, context, value1, value2);
 46  0
     }
 47  
 
 48  
     public static Object createInstance(List<Endpoint> endpoints, AsynchronousCallback callback,
 49  
             Serializable context, String value1, String value2) {
 50  0
         if (endpoints == null || endpoints.isEmpty()) {
 51  0
             throw new RuntimeException("Cannot create service proxy, no service(s) passed in.");
 52  
         }
 53  
         try {
 54  0
         return Proxy.newProxyInstance(ClassLoaderUtils.getDefaultClassLoader(), ContextClassLoaderProxy
 55  
                 .getInterfacesToProxy(endpoints.get(0).getService()), new SynchronousServiceCallProxy(
 56  
                                 endpoints, callback, context, value1, value2));
 57  0
         } catch (Exception e) {
 58  0
             throw new RiceRuntimeException(e);
 59  
     }
 60  
     }
 61  
 
 62  
     @Override
 63  
     protected void executeMessage(PersistedMessageBO message) {
 64  0
         if (!Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGING_OFF))) {
 65  0
             new MessageServiceInvoker(message).run();
 66  
         }
 67  0
     }
 68  
 }