Coverage Report - org.kuali.rice.ksb.messaging.KSBHttpInvokerServiceExporter
 
Classes in this File Line Coverage Branch Coverage Complexity
KSBHttpInvokerServiceExporter
0%
0/31
0%
0/10
1.75
 
 1  
 /*
 2  
  * Copyright 2007-2008 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;
 17  
 
 18  
 import java.util.Arrays;
 19  
 import java.util.List;
 20  
 
 21  
 import org.kuali.rice.core.resourceloader.ContextClassLoaderProxy;
 22  
 import org.kuali.rice.core.util.ClassLoaderUtils;
 23  
 import org.kuali.rice.ksb.messaging.bam.BAMServerProxy;
 24  
 import org.springframework.aop.framework.ProxyFactory;
 25  
 import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;
 26  
 import org.springframework.remoting.support.RemoteInvocationTraceInterceptor;
 27  
 
 28  
 
 29  0
 public class KSBHttpInvokerServiceExporter extends HttpInvokerServiceExporter {
 30  
         
 31  
         private List<Class> serviceInterfaces;
 32  
         private ServiceInfo serviceInfo;
 33  0
         private boolean registerTraceInterceptor = true;
 34  
         
 35  
         public ServiceInfo getServiceInfo() {
 36  0
                 return this.serviceInfo;
 37  
         }
 38  
 
 39  
         public void setServiceInfo(ServiceInfo serviceInfo) {
 40  0
                 this.serviceInfo = serviceInfo;
 41  0
         }
 42  
         
 43  
         /**
 44  
          * @see org.springframework.remoting.support.RemoteExporter#setRegisterTraceInterceptor(boolean)
 45  
          */
 46  
         @Override
 47  
         public void setRegisterTraceInterceptor(boolean registerTraceInterceptor) {
 48  
             // HttpInvokerServiceExporter.registerTraceInterceptor is no longer exposed, capture its value if set
 49  0
             this.registerTraceInterceptor = registerTraceInterceptor;
 50  0
             super.setRegisterTraceInterceptor(registerTraceInterceptor);
 51  0
         }
 52  
 
 53  
         protected Object getProxyForService() {
 54  0
                 checkService();
 55  0
                 checkServiceInterface();
 56  0
                 ProxyFactory proxyFactory = new ProxyFactory();
 57  0
                 for (Class serviceInterface : getServiceInterfaces()) {
 58  0
                         proxyFactory.addInterface(serviceInterface);
 59  
                 }
 60  0
                 if (registerTraceInterceptor == true) {
 61  0
                         proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName()));
 62  
                 }
 63  0
                 ClassLoader classLoader = serviceInfo.getServiceClassLoader();
 64  0
                 if (classLoader == null) {
 65  0
                     classLoader = ClassLoaderUtils.getDefaultClassLoader();
 66  
                 }
 67  0
                 Object service = ContextClassLoaderProxy.wrap(getService(), classLoader);
 68  0
                 service = BAMServerProxy.wrap(service, this.serviceInfo);
 69  0
                 proxyFactory.setTarget(service);
 70  0
                 return proxyFactory.getProxy(classLoader);
 71  
         }
 72  
 
 73  
         @Override
 74  
         protected void checkServiceInterface() throws IllegalArgumentException {
 75  0
                 if (this.serviceInterfaces == null) {
 76  0
                     this.serviceInterfaces = Arrays.asList(ContextClassLoaderProxy.getInterfacesToProxy(getService()));
 77  
                 }
 78  0
                 if (getServiceInterfaces().isEmpty()) {
 79  0
                         throw new IllegalArgumentException("At least one service interface should be defined.");
 80  
                 }
 81  0
         }
 82  
         
 83  
         public List<Class> getServiceInterfaces() {
 84  0
                 return this.serviceInterfaces;
 85  
         }
 86  
 
 87  
         public void setServiceInterfaces(List<Class> serviceInterfaces) {
 88  0
                 this.serviceInterfaces = serviceInterfaces;
 89  0
         }
 90  
         
 91  
         public Object getService() {
 92  0
                 return super.getService();
 93  
         }
 94  
         
 95  
 }