|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
     | 
  |  17 |     | 
   package org.kuali.rice.ksb.messaging.resourceloader;  | 
  |  18 |     | 
     | 
  |  19 |     | 
   import javax.xml.namespace.QName;  | 
  |  20 |     | 
     | 
  |  21 |     | 
   import org.kuali.rice.core.api.config.CoreConfigHelper;  | 
  |  22 |     | 
   import org.kuali.rice.core.api.config.property.ConfigContext;  | 
  |  23 |     | 
   import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;  | 
  |  24 |     | 
   import org.kuali.rice.core.api.resourceloader.ResourceLoader;  | 
  |  25 |     | 
   import org.kuali.rice.core.framework.resourceloader.BaseResourceLoader;  | 
  |  26 |     | 
   import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader;  | 
  |  27 |     | 
   import org.kuali.rice.ksb.api.KsbApiServiceLocator;  | 
  |  28 |     | 
   import org.kuali.rice.ksb.api.bus.ServiceBus;  | 
  |  29 |     | 
     | 
  |  30 |     | 
     | 
  |  31 |     | 
     | 
  |  32 |     | 
     | 
  |  33 |     | 
     | 
  |  34 |     | 
     | 
  |  35 |     | 
     | 
  |  36 |     | 
     | 
  |  37 |     | 
     | 
  |  38 |     | 
     | 
  |  39 |     | 
     | 
  |  40 |     | 
     | 
  |  41 |     | 
     | 
  |  42 |    0 |    public class KSBResourceLoaderFactory { | 
  |  43 |     | 
             | 
  |  44 |     | 
           private static final String KSB_ROOT_RESOURCE_LOACER_NAME = "KSB_ROOT_RESOURCE_LOADER";  | 
  |  45 |     | 
           private static final String KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME = "KSB_REMOTE_RESOURCE_LOADER";  | 
  |  46 |     | 
     | 
  |  47 |     | 
           private static void initialize() { | 
  |  48 |    0 |                    String applicationId = CoreConfigHelper.getApplicationId();  | 
  |  49 |    0 |                    if (getRootResourceLoaderName() == null) { | 
  |  50 |    0 |                            setRootResourceLoaderName(new QName(applicationId, KSB_ROOT_RESOURCE_LOACER_NAME));  | 
  |  51 |     | 
                   }  | 
  |  52 |    0 |                    if (getRemoteResourceLoaderName() == null) { | 
  |  53 |    0 |                            setRemoteResourceLoaderName(new QName(applicationId, KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME));  | 
  |  54 |     | 
                   }  | 
  |  55 |    0 |            }  | 
  |  56 |     | 
     | 
  |  57 |     | 
           public static ResourceLoader createRootKSBRemoteResourceLoader() { | 
  |  58 |    0 |                    initialize();  | 
  |  59 |    0 |                    ResourceLoader rootResourceLoader = new BaseResourceLoader(getRootResourceLoaderName());  | 
  |  60 |    0 |                    ServiceBus serviceBus = KsbApiServiceLocator.getServiceBus();  | 
  |  61 |    0 |                    if (serviceBus == null) { | 
  |  62 |    0 |                            throw new IllegalStateException("Failed to locate the ServiceBus"); | 
  |  63 |     | 
                   }  | 
  |  64 |    0 |                    rootResourceLoader.addResourceLoader(new ServiceBusResourceLoader(getRemoteResourceLoaderName(), serviceBus));  | 
  |  65 |    0 |                    return rootResourceLoader;  | 
  |  66 |     | 
           }  | 
  |  67 |     | 
     | 
  |  68 |     | 
           public static ResourceLoader createThinClientKSBResourceLoader() { | 
  |  69 |    0 |                    ResourceLoader resourceLoader = new SpringResourceLoader(new QName("", "KSB_THIN_CLIENT_RESOURCE_LOADER"), "classpath:org/kuali/rice/ksb/config/KSBThinClientSpringBeans.xml", null); | 
  |  70 |    0 |                    GlobalResourceLoader.addResourceLoader(resourceLoader);  | 
  |  71 |    0 |                    return resourceLoader;  | 
  |  72 |     | 
           }  | 
  |  73 |     | 
     | 
  |  74 |     | 
           public static BaseResourceLoader getRootResourceLoader() { | 
  |  75 |    0 |                    return (BaseResourceLoader)GlobalResourceLoader.getResourceLoader(getRootResourceLoaderName());  | 
  |  76 |     | 
           }  | 
  |  77 |     | 
     | 
  |  78 |     | 
           public static QName getRootResourceLoaderName() { | 
  |  79 |    0 |                    return (QName)ConfigContext.getCurrentContextConfig().getObject(KSB_ROOT_RESOURCE_LOACER_NAME);  | 
  |  80 |     | 
           }  | 
  |  81 |     | 
     | 
  |  82 |     | 
           public static void setRootResourceLoaderName(QName name) { | 
  |  83 |    0 |                    ConfigContext.getCurrentContextConfig().putObject(KSB_ROOT_RESOURCE_LOACER_NAME, name);  | 
  |  84 |    0 |            }  | 
  |  85 |     | 
     | 
  |  86 |     | 
           public static QName getRemoteResourceLoaderName() { | 
  |  87 |    0 |                    return (QName)ConfigContext.getCurrentContextConfig().getObject(KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME);  | 
  |  88 |     | 
           }  | 
  |  89 |     | 
     | 
  |  90 |     | 
           public static void setRemoteResourceLoaderName(QName remoteResourceLoaderName) { | 
  |  91 |    0 |                    ConfigContext.getCurrentContextConfig().putObject(KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME, remoteResourceLoaderName);  | 
  |  92 |    0 |            }  | 
  |  93 |     | 
     | 
  |  94 |     | 
   }  |