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