1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
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 | |
} |