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.resourceloader;
17:
18: import javax.xml.namespace.QName;
19:
20: import org.kuali.rice.RiceConstants;
21: import org.kuali.rice.core.Core;
22: import org.kuali.rice.lifecycle.BaseLifecycle;
23:
24: public class RootResourceLoaderLifecycle extends BaseLifecycle {
25:
26: private ResourceLoader rootResourceLoader;
27:
28: public RootResourceLoaderLifecycle(ResourceLoader rootResourceLoader) {
29: this .rootResourceLoader = rootResourceLoader;
30: }
31:
32: @Override
33: public void start() throws Exception {
34: ResourceLoaderContainer container = new ResourceLoaderContainer(
35: new QName(
36: getMessageEntity(),
37: RiceConstants.ROOT_RESOURCE_LOADER_CONTAINER_NAME));
38: if (this .rootResourceLoader == null) {
39: this .rootResourceLoader = new BaseResourceLoader(new QName(
40: getMessageEntity(),
41: RiceConstants.DEFAULT_ROOT_RESOURCE_LOADER_NAME));
42: }
43: container.addResourceLoader(this .rootResourceLoader);
44: GlobalResourceLoader.addResourceLoaderFirst(container);
45: GlobalResourceLoader.start();
46: }
47:
48: @Override
49: public void stop() throws Exception {
50: super .stop();
51: }
52:
53: protected String getMessageEntity() {
54: return Core.getCurrentContextConfig().getMessageEntity();
55: }
56:
57: }
|