| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.core.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 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | 0 | public class RiceResourceLoaderFactory { |
| 33 | |
|
| 34 | |
private static final String RICE_ROOT_RESOURCE_LOADER_NAME = "RICE_ROOT_RESOURCE_LOADER"; |
| 35 | |
private static final String RICE_SPRING_RESOURCE_LOADER_NAME = "RICE_SPRING_RESOURCE_LOADER_NAME"; |
| 36 | |
|
| 37 | |
private static void initialize() { |
| 38 | 0 | Config config = ConfigContext.getCurrentContextConfig(); |
| 39 | 0 | if (config.getServiceNamespace() == null) { |
| 40 | 0 | throw new ConfigurationException("No service namespace available at this time"); |
| 41 | |
} |
| 42 | 0 | if (getRootResourceLoaderName() == null) { |
| 43 | 0 | setRootResourceLoaderName(new QName(ConfigContext.getCurrentContextConfig().getServiceNamespace(), RICE_ROOT_RESOURCE_LOADER_NAME)); |
| 44 | |
} |
| 45 | 0 | if (getSpringResourceLoaderName() == null) { |
| 46 | 0 | setSpringResourceLoaderName(new QName(ConfigContext.getCurrentContextConfig().getServiceNamespace(), RICE_SPRING_RESOURCE_LOADER_NAME)); |
| 47 | |
} |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
public static ResourceLoader createRootRiceResourceLoader(String springFileLocations) { |
| 51 | 0 | initialize(); |
| 52 | 0 | ResourceLoader rootResourceLoader = |
| 53 | |
new BaseResourceLoader((QName)ConfigContext.getCurrentContextConfig().getObject(RICE_ROOT_RESOURCE_LOADER_NAME), |
| 54 | |
new SimpleServiceLocator()); |
| 55 | 0 | ResourceLoader springResourceLoader = |
| 56 | |
new SpringResourceLoader((QName)ConfigContext.getCurrentContextConfig().getObject(RICE_SPRING_RESOURCE_LOADER_NAME), |
| 57 | |
springFileLocations.split(SpringLoader.SPRING_SEPARATOR_CHARACTER)); |
| 58 | 0 | rootResourceLoader.addResourceLoaderFirst(springResourceLoader); |
| 59 | 0 | return rootResourceLoader; |
| 60 | |
} |
| 61 | |
|
| 62 | |
public static BaseResourceLoader getRootResourceLoader() { |
| 63 | 0 | return (BaseResourceLoader)GlobalResourceLoader.getResourceLoader(getRootResourceLoaderName()); |
| 64 | |
} |
| 65 | |
|
| 66 | |
public static SpringResourceLoader getSpringResourceLoader() { |
| 67 | 0 | return (SpringResourceLoader)GlobalResourceLoader.getResourceLoader(getSpringResourceLoaderName()); |
| 68 | |
} |
| 69 | |
|
| 70 | |
public static QName getRootResourceLoaderName() { |
| 71 | 0 | return (QName)ConfigContext.getCurrentContextConfig().getObject(RICE_ROOT_RESOURCE_LOADER_NAME); |
| 72 | |
} |
| 73 | |
|
| 74 | |
public static void setRootResourceLoaderName(QName name) { |
| 75 | 0 | ConfigContext.getCurrentContextConfig().putObject(RICE_ROOT_RESOURCE_LOADER_NAME, name); |
| 76 | 0 | } |
| 77 | |
|
| 78 | |
public static QName getSpringResourceLoaderName() { |
| 79 | 0 | return (QName)ConfigContext.getCurrentContextConfig().getObject(RICE_SPRING_RESOURCE_LOADER_NAME); |
| 80 | |
} |
| 81 | |
|
| 82 | |
public static void setSpringResourceLoaderName(QName ksbRsourceLoaderName) { |
| 83 | 0 | ConfigContext.getCurrentContextConfig().putObject(RICE_SPRING_RESOURCE_LOADER_NAME, ksbRsourceLoaderName); |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
} |