Clover Coverage Report - Kuali Student Standalone 1.2-M2-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
9   68   5   3
2   33   0.56   3
3     1.67  
1    
 
  KSBClientProxy       Line # 37 9 0% 5 14 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.rice.ksb.messaging;
17   
18    import java.lang.reflect.InvocationHandler;
19    import java.lang.reflect.InvocationTargetException;
20    import java.lang.reflect.Method;
21    import java.lang.reflect.Proxy;
22   
23    import javax.xml.namespace.QName;
24   
25    import org.apache.log4j.Logger;
26    import org.kuali.rice.core.resourceloader.GlobalResourceLoader;
27    import org.kuali.rice.core.util.ExceptionUtils;
28   
29    /**
30    * This class creates a proxy for services deployed on KSB. A
31    * reference to the service is obtained only upon the first method
32    * invocation.
33    *
34    * @author Kuali Rice Team (rice.collab@kuali.org)
35    *
36    */
 
37    public class KSBClientProxy implements InvocationHandler {
38   
39    private static final Logger LOG = Logger.getLogger(KSBClientProxy.class);
40   
41    QName serviceName;
42    Object service;
43   
 
44  0 toggle @SuppressWarnings("unchecked")
45    public static <T> T newInstance(String serviceQName, Class<T> interfaceClass) throws InstantiationException, IllegalAccessException {
46  0 return (T)Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[] { interfaceClass }, new KSBClientProxy(serviceQName));
47    }
48   
 
49  0 toggle public KSBClientProxy(String serviceQName){
50  0 this.serviceName = QName.valueOf(serviceQName);
51    }
52   
 
53  0 toggle public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
54  0 if (this.service == null){
55  0 LOG.info("Getting service using GRL for: " + serviceName);
56  0 service = GlobalResourceLoader.getService(serviceName);
57  0 LOG.info("Obtained service using GRL for: " + serviceName);
58    }
59   
60  0 try {
61  0 return method.invoke(service, args);
62    } catch (InvocationTargetException e) {
63  0 throw ExceptionUtils.unwrapActualCause(e);
64    }
65   
66    }
67   
68    }