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 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.ResourceLoader; |
23 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
24 | |
import org.kuali.rice.core.framework.resourceloader.BaseResourceLoader; |
25 | |
import org.kuali.rice.core.impl.resourceloader.SpringResourceLoader; |
26 | |
import org.kuali.rice.ksb.messaging.RemoteResourceServiceLocator; |
27 | |
import org.kuali.rice.ksb.messaging.RemoteResourceServiceLocatorImpl; |
28 | |
|
29 | |
import javax.xml.namespace.QName; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | 0 | public class KSBResourceLoaderFactory { |
44 | |
|
45 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger |
46 | |
.getLogger(KSBResourceLoaderFactory.class); |
47 | |
|
48 | |
private static final String KSB_ROOT_RESOURCE_LOACER_NAME = "KSB_ROOT_RESOURCE_LOADER"; |
49 | |
private static final String KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME = "KSB_REMOTE_RESOURCE_LOADER"; |
50 | |
|
51 | |
private static void initialize() { |
52 | 0 | Config config = ConfigContext.getCurrentContextConfig(); |
53 | 0 | if (config.getServiceNamespace() == null) { |
54 | 0 | throw new ConfigurationException("No service namespace available at this time"); |
55 | |
} |
56 | 0 | if (getRootResourceLoaderName() == null) { |
57 | 0 | setRootResourceLoaderName(new QName(ConfigContext.getCurrentContextConfig().getServiceNamespace(), KSB_ROOT_RESOURCE_LOACER_NAME)); |
58 | |
} |
59 | 0 | if (getRemoteResourceLoaderName() == null) { |
60 | 0 | setRemoteResourceLoaderName(new QName(ConfigContext.getCurrentContextConfig().getServiceNamespace(), KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME)); |
61 | |
} |
62 | 0 | } |
63 | |
|
64 | |
public static ResourceLoader createRootKSBRemoteResourceLoader() { |
65 | 0 | initialize(); |
66 | 0 | ResourceLoader rootResourceLoader = new BaseResourceLoader(getRootResourceLoaderName()); |
67 | 0 | rootResourceLoader.addResourceLoader(new RemoteResourceServiceLocatorImpl(getRemoteResourceLoaderName())); |
68 | 0 | return rootResourceLoader; |
69 | |
} |
70 | |
|
71 | |
public static ResourceLoader createThinClientKSBResourceLoader() { |
72 | 0 | ResourceLoader resourceLoader = new SpringResourceLoader(new QName("", "KSB_THIN_CLIENT_RESOURCE_LOADER"), "classpath:org/kuali/rice/ksb/config/KSBThinClientSpringBeans.xml", null); |
73 | 0 | GlobalResourceLoader.addResourceLoader(resourceLoader); |
74 | 0 | return resourceLoader; |
75 | |
} |
76 | |
|
77 | |
public static BaseResourceLoader getRootResourceLoader() { |
78 | 0 | return (BaseResourceLoader)GlobalResourceLoader.getResourceLoader(getRootResourceLoaderName()); |
79 | |
} |
80 | |
|
81 | |
public static RemoteResourceServiceLocator getRemoteResourceLocator() { |
82 | 0 | return (RemoteResourceServiceLocator)GlobalResourceLoader.getResourceLoader(getRemoteResourceLoaderName()); |
83 | |
} |
84 | |
|
85 | |
public static QName getRootResourceLoaderName() { |
86 | 0 | return (QName)ConfigContext.getCurrentContextConfig().getObject(KSB_ROOT_RESOURCE_LOACER_NAME); |
87 | |
} |
88 | |
|
89 | |
public static void setRootResourceLoaderName(QName name) { |
90 | 0 | ConfigContext.getCurrentContextConfig().putObject(KSB_ROOT_RESOURCE_LOACER_NAME, name); |
91 | 0 | } |
92 | |
|
93 | |
public static QName getRemoteResourceLoaderName() { |
94 | 0 | return (QName)ConfigContext.getCurrentContextConfig().getObject(KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME); |
95 | |
} |
96 | |
|
97 | |
public static void setRemoteResourceLoaderName(QName remoteResourceLoaderName) { |
98 | 0 | ConfigContext.getCurrentContextConfig().putObject(KSB_REMOTE_RESOURCE_LOADER_LOCAL_NAME, remoteResourceLoaderName); |
99 | 0 | } |
100 | |
|
101 | |
} |