View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.sys.context;
20  
21  import java.util.ArrayList;
22  import java.util.Arrays;
23  import java.util.Collections;
24  import java.util.List;
25  
26  import org.kuali.rice.core.api.config.module.RunMode;
27  import org.kuali.rice.core.api.config.property.ConfigContext;
28  import org.kuali.rice.core.framework.config.module.ModuleConfigurer;
29  import org.kuali.rice.core.framework.config.module.WebModuleConfiguration;
30  import org.springframework.beans.factory.InitializingBean;
31  
32  public class KFSConfigurer extends ModuleConfigurer implements InitializingBean {
33      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KFSConfigurer.class);
34  
35      protected boolean testMode = false;
36  
37      public KFSConfigurer() {
38          super("KFS");
39          LOG.info( "KFSConfigurer instantiated" );
40          setValidRunModes(Arrays.asList(RunMode.LOCAL));
41      }
42  
43      @Override
44      protected void doAdditionalModuleStartLogic() throws Exception {
45          LOG.info( "*********************************************************" );
46          LOG.info( "KFS Starting Module" );
47          LOG.info( "*********************************************************" );
48          super.doAdditionalModuleStartLogic();
49      }
50  
51      @Override
52      protected void doAdditionalModuleStopLogic() throws Exception {
53          LOG.info( "*********************************************************" );
54          LOG.info( "KFS Stopping Module" );
55          LOG.info( "*********************************************************" );
56          super.doAdditionalModuleStopLogic();
57      }
58  
59      @Override
60      public List<String> getPrimarySpringFiles() {
61          String files = ConfigContext.getCurrentContextConfig().getProperty("spring.source.files");
62          if ( testMode ) {
63              files = files + "," + ConfigContext.getCurrentContextConfig().getProperty("spring.test.files");
64          }
65          if ( LOG.isInfoEnabled() ) {
66              LOG.info( "KFS Spring Files Requested.  Returning: " + files );
67          }
68          return files == null ? Collections.<String>emptyList() : parseFileList(files);
69      }
70  
71      protected List<String> parseFileList(String files) {
72          List<String> parsedFiles = new ArrayList<String>();
73          for (String file : Arrays.asList(files.split(","))) {
74              String trimmedFile = file.trim();
75              if (!trimmedFile.isEmpty()) {
76                  parsedFiles.add(trimmedFile);
77              }
78          }
79  
80          return parsedFiles;
81      }
82  
83      @Override
84      protected WebModuleConfiguration loadWebModule() {
85          return new KfsWebModuleConfiguration();
86      }
87  
88      @Override
89      public boolean hasWebInterface() {
90          return true;
91      }
92  
93      public boolean isTestMode() {
94          return testMode;
95      }
96  
97      public void setTestMode(boolean testMode) {
98          this.testMode = testMode;
99      }
100 }