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