Coverage Report - org.kuali.rice.ksb.messaging.resourceloader.KSBResourceLoaderFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
KSBResourceLoaderFactory
0%
0/24
0%
0/6
1.5
 
 1  
 /**
 2  
  * Copyright 2005-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  
 package org.kuali.rice.ksb.messaging.resourceloader;
 17  
 
 18  
 import javax.xml.namespace.QName;
 19  
 
 20  
 import org.kuali.rice.core.api.config.CoreConfigHelper;
 21  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 22  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 23  
 import org.kuali.rice.core.api.resourceloader.ResourceLoader;
 24  
 import org.kuali.rice.core.framework.resourceloader.BaseResourceLoader;
 25  
 import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader;
 26  
 import org.kuali.rice.ksb.api.KsbApiServiceLocator;
 27  
 import org.kuali.rice.ksb.api.bus.ServiceBus;
 28  
 
 29  
 
 30  
 
 31  
 /**
 32  
  * Creates KSBs root resource loader with all the correct children attached ready for starting.
 33  
  * Uses config object to store QNames so everything is good with the current context classloader.
 34  
  *
 35  
  * Can grab any KSB specific resource loader from the resource loading stack.
 36  
  *
 37  
  *
 38  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 39  
  *
 40  
  */
 41  0
 public class KSBResourceLoaderFactory {
 42  
         
 43  
         private static final String KSB_ROOT_RESOURCE_LOACER_NAME = "KSB_ROOT_RESOURCE_LOADER";
 44  
         private static final String KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME = "KSB_REMOTE_RESOURCE_LOADER";
 45  
 
 46  
         private static void initialize() {
 47  0
                 String applicationId = CoreConfigHelper.getApplicationId();
 48  0
                 if (getRootResourceLoaderName() == null) {
 49  0
                         setRootResourceLoaderName(new QName(applicationId, KSB_ROOT_RESOURCE_LOACER_NAME));
 50  
                 }
 51  0
                 if (getRemoteResourceLoaderName() == null) {
 52  0
                         setRemoteResourceLoaderName(new QName(applicationId, KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME));
 53  
                 }
 54  0
         }
 55  
 
 56  
         public static ResourceLoader createRootKSBRemoteResourceLoader() {
 57  0
                 initialize();
 58  0
                 ResourceLoader rootResourceLoader = new BaseResourceLoader(getRootResourceLoaderName());
 59  0
                 ServiceBus serviceBus = KsbApiServiceLocator.getServiceBus();
 60  0
                 if (serviceBus == null) {
 61  0
                         throw new IllegalStateException("Failed to locate the ServiceBus");
 62  
                 }
 63  0
                 rootResourceLoader.addResourceLoader(new ServiceBusResourceLoader(getRemoteResourceLoaderName(), serviceBus));
 64  0
                 return rootResourceLoader;
 65  
         }
 66  
 
 67  
         public static ResourceLoader createThinClientKSBResourceLoader() {
 68  0
                 ResourceLoader resourceLoader = new SpringResourceLoader(new QName("", "KSB_THIN_CLIENT_RESOURCE_LOADER"), "classpath:org/kuali/rice/ksb/config/KSBThinClientSpringBeans.xml", null);
 69  0
                 GlobalResourceLoader.addResourceLoader(resourceLoader);
 70  0
                 return resourceLoader;
 71  
         }
 72  
 
 73  
         public static BaseResourceLoader getRootResourceLoader() {
 74  0
                 return (BaseResourceLoader)GlobalResourceLoader.getResourceLoader(getRootResourceLoaderName());
 75  
         }
 76  
 
 77  
         public static QName getRootResourceLoaderName() {
 78  0
                 return (QName)ConfigContext.getCurrentContextConfig().getObject(KSB_ROOT_RESOURCE_LOACER_NAME);
 79  
         }
 80  
 
 81  
         public static void setRootResourceLoaderName(QName name) {
 82  0
                 ConfigContext.getCurrentContextConfig().putObject(KSB_ROOT_RESOURCE_LOACER_NAME, name);
 83  0
         }
 84  
 
 85  
         public static QName getRemoteResourceLoaderName() {
 86  0
                 return (QName)ConfigContext.getCurrentContextConfig().getObject(KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME);
 87  
         }
 88  
 
 89  
         public static void setRemoteResourceLoaderName(QName remoteResourceLoaderName) {
 90  0
                 ConfigContext.getCurrentContextConfig().putObject(KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME, remoteResourceLoaderName);
 91  0
         }
 92  
 
 93  
 }