001: /*
002: * Copyright 2007 The Kuali Foundation
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.rice.kns.config;
017:
018: import java.util.LinkedList;
019: import java.util.List;
020:
021: import org.kuali.core.KualiModule;
022: import org.kuali.core.authorization.KualiModuleAuthorizerBase;
023: import org.kuali.core.web.servlet.dwr.GlobalResourceDelegatingSpringCreator;
024: import org.kuali.rice.config.Config;
025: import org.kuali.rice.config.ModuleConfigurer;
026: import org.kuali.rice.core.Core;
027: import org.kuali.rice.lifecycle.Lifecycle;
028: import org.springframework.beans.BeansException;
029: import org.springframework.beans.factory.BeanFactory;
030: import org.springframework.beans.factory.BeanFactoryAware;
031:
032: public class KNSConfigurer extends ModuleConfigurer implements
033: BeanFactoryAware {
034:
035: private List<String> databaseRepositoryFilePaths;
036:
037: private List<String> dataDictionaryPackages;
038:
039: private boolean suppressAutoModuleConfiguration;
040:
041: private BeanFactory beanFactory;
042:
043: @Override
044: public Config loadConfig(Config parentConfig) throws Exception {
045: return null;
046: }
047:
048: @Override
049: protected List<Lifecycle> loadLifecycles() throws Exception {
050: List<Lifecycle> lifecycles = new LinkedList<Lifecycle>();
051: GlobalResourceDelegatingSpringCreator.APPLICATION_BEAN_FACTORY = beanFactory;
052: lifecycles.add(new OJBConfigurer());
053: lifecycles.add(KNSResourceLoaderFactory
054: .createRootKNSResourceLoader());
055: if (!isSuppressAutoModuleConfiguration()) {
056: lifecycles.add(new Lifecycle() {
057: boolean started = false;
058:
059: public boolean isStarted() {
060: return this .started;
061: }
062:
063: public void start() throws Exception {
064: KualiModule kualiModule = new KualiModule();
065: kualiModule
066: .setDatabaseRepositoryFilePaths(getDatabaseRepositoryFilePaths());
067: kualiModule
068: .setDataDictionaryPackages(getDataDictionaryPackages());
069: kualiModule.setInitializeDataDictionary(true);
070: kualiModule
071: .setModuleAuthorizer(new KualiModuleAuthorizerBase());
072: kualiModule.setModuleCode(Core
073: .getCurrentContextConfig()
074: .getMessageEntity());
075: kualiModule.setModuleId(Core
076: .getCurrentContextConfig()
077: .getMessageEntity());
078: kualiModule.setModuleName(Core
079: .getCurrentContextConfig()
080: .getMessageEntity());
081: kualiModule.afterPropertiesSet();
082: this .started = true;
083: }
084:
085: public void stop() throws Exception {
086: this .started = false;
087: }
088: });
089: }
090: return lifecycles;
091: }
092:
093: public List<String> getDatabaseRepositoryFilePaths() {
094: return databaseRepositoryFilePaths;
095: }
096:
097: public void setDatabaseRepositoryFilePaths(
098: List<String> databaseRepositoryFilePaths) {
099: this .databaseRepositoryFilePaths = databaseRepositoryFilePaths;
100: }
101:
102: public List<String> getDataDictionaryPackages() {
103: return dataDictionaryPackages;
104: }
105:
106: public void setDataDictionaryPackages(
107: List<String> dataDictionaryPackages) {
108: this .dataDictionaryPackages = dataDictionaryPackages;
109: }
110:
111: public boolean isSuppressAutoModuleConfiguration() {
112: return suppressAutoModuleConfiguration;
113: }
114:
115: public void setSuppressAutoModuleConfiguration(
116: boolean suppressAutoModuleConfiguration) {
117: this .suppressAutoModuleConfiguration = suppressAutoModuleConfiguration;
118: }
119:
120: public void setBeanFactory(BeanFactory beanFactory)
121: throws BeansException {
122: this.beanFactory = beanFactory;
123: }
124: }
|