View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
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.core.resourceloader;
17  
18  import javax.xml.namespace.QName;
19  
20  import org.kuali.rice.core.config.ConfigContext;
21  import org.kuali.rice.core.lifecycle.BaseLifecycle;
22  import org.kuali.rice.core.resourceloader.ResourceLoader;
23  import org.kuali.rice.core.util.RiceConstants;
24  
25  public class RootResourceLoaderLifecycle extends BaseLifecycle {
26  
27  	private ResourceLoader rootResourceLoader;
28  
29  	public RootResourceLoaderLifecycle(ResourceLoader rootResourceLoader) {
30  		this.rootResourceLoader = rootResourceLoader;
31  	}
32  
33  	@Override
34  	public void start() throws Exception {
35  		ResourceLoaderContainer container = new ResourceLoaderContainer(new QName(getServiceNamespace(), RiceConstants.ROOT_RESOURCE_LOADER_CONTAINER_NAME));
36  		if (this.rootResourceLoader == null) {
37  		    this.rootResourceLoader = new BaseResourceLoader(new QName(getServiceNamespace(), RiceConstants.DEFAULT_ROOT_RESOURCE_LOADER_NAME));
38  		}
39  		container.addResourceLoader(this.rootResourceLoader);
40  		GlobalResourceLoader.addResourceLoader(container);
41  		GlobalResourceLoader.start();
42  	}
43  
44  	@Override
45  	public void stop() throws Exception {
46  		super.stop();
47  	}
48  
49  	protected String getServiceNamespace() {
50  		return ConfigContext.getCurrentContextConfig().getServiceNamespace();
51  	}
52  
53  
54  
55  }