01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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: package org.kuali.rice.kns.config;
17:
18: import javax.xml.namespace.QName;
19:
20: import org.kuali.rice.core.Core;
21: import org.kuali.rice.resourceloader.GlobalResourceLoader;
22: import org.kuali.rice.resourceloader.ResourceLoader;
23: import org.kuali.rice.resourceloader.SpringResourceLoader;
24:
25: /**
26: * Creates {@link ResourceLoader} for KNS services and puts the resource loader in the
27: * correct place in the {@link GlobalResourceLoader} resource loading mix.
28: *
29: * Returns the {@link ResourceLoader} ready to be started.
30: *
31: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
32: *
33: */
34: public class KNSResourceLoaderFactory {
35:
36: private static final String KNS_SPRING_RESOURCE_LOADER_LOCAL_NAME = "KNS_SPRING_RESOURCE_LOADER";
37:
38: private static void initialize() {
39: if (getSpringResourceLoaderName() == null) {
40: setSpringResourceLoaderName(new QName(Core
41: .getCurrentContextConfig().getMessageEntity(),
42: KNS_SPRING_RESOURCE_LOADER_LOCAL_NAME));
43: }
44: }
45:
46: public static ResourceLoader createRootKNSResourceLoader() {
47: initialize();
48: ResourceLoader resourceLoader = new SpringResourceLoader(
49: getSpringResourceLoaderName(), "KNSSpringBeans.xml");
50: GlobalResourceLoader.addResourceLoaderFirst(resourceLoader);
51: return resourceLoader;
52: }
53:
54: public static SpringResourceLoader getSpringResourceLoader() {
55: return (SpringResourceLoader) GlobalResourceLoader
56: .getResourceLoader(getSpringResourceLoaderName());
57: }
58:
59: public static QName getSpringResourceLoaderName() {
60: return (QName) Core.getCurrentContextConfig().getObject(
61: KNS_SPRING_RESOURCE_LOADER_LOCAL_NAME);
62: }
63:
64: public static void setSpringResourceLoaderName(
65: QName knsSpringResourceLoaderName) {
66: Core.getCurrentContextConfig().getObjects().put(
67: KNS_SPRING_RESOURCE_LOADER_LOCAL_NAME,
68: knsSpringResourceLoaderName);
69: }
70: }
|