Coverage Report - org.kuali.rice.ksb.messaging.bam.BAMClientProxy
 
Classes in this File Line Coverage Branch Coverage Complexity
BAMClientProxy
0%
0/10
N/A
2
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.ksb.messaging.bam;
 18  
 
 19  
 import java.lang.reflect.Method;
 20  
 import java.lang.reflect.Proxy;
 21  
 
 22  
 import org.kuali.rice.core.proxy.BaseTargetedInvocationHandler;
 23  
 import org.kuali.rice.core.resourceloader.ContextClassLoaderProxy;
 24  
 import org.kuali.rice.core.util.ClassLoaderUtils;
 25  
 import org.kuali.rice.core.util.ExceptionUtils;
 26  
 import org.kuali.rice.ksb.messaging.ServiceInfo;
 27  
 import org.kuali.rice.ksb.messaging.bam.service.BAMService;
 28  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 29  
 
 30  
 
 31  
 /**
 32  
  * A client-side proxy for that records an entry in the BAM for invocations
 33  
  * on the proxied service.
 34  
  *
 35  
  * @see BAMService
 36  
  *
 37  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 38  
  */
 39  
 public class BAMClientProxy extends BaseTargetedInvocationHandler {
 40  
 
 41  
         private ServiceInfo serviceInfo;
 42  
         
 43  
         private BAMClientProxy(Object target, ServiceInfo serviceInfo) {
 44  0
                 super(target);
 45  0
                 this.serviceInfo = serviceInfo;
 46  0
         }
 47  
         
 48  
         public static Object wrap(Object target, ServiceInfo serviceInfo) {
 49  0
                 return Proxy.newProxyInstance(ClassLoaderUtils.getDefaultClassLoader(), ContextClassLoaderProxy.getInterfacesToProxyIncludeSpring(target), new BAMClientProxy(target, serviceInfo)); 
 50  
         }
 51  
         
 52  
         protected Object invokeInternal(Object proxyObject, Method method, Object[] arguments) throws Throwable {
 53  0
                 BAMTargetEntry bamTargetEntry = KSBServiceLocator.getBAMService().recordClientInvocation(this.serviceInfo, getTarget(), method, arguments);
 54  
                 try {
 55  0
                         return method.invoke(getTarget(), arguments);        
 56  0
                 } catch (Throwable throwable) {
 57  0
                         throwable = ExceptionUtils.unwrapActualCause(throwable);
 58  0
                         KSBServiceLocator.getBAMService().recordClientInvocationError(throwable, bamTargetEntry);
 59  0
                         throw throwable;
 60  
                 }
 61  
         }
 62  
 }