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