View Javadoc

1   /**
2    * Copyright 2004-2013 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.kpme.core.sys;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.Collections;
21  import java.util.List;
22  
23  import org.kuali.rice.core.api.config.module.RunMode;
24  import org.kuali.rice.core.api.config.property.ConfigContext;
25  import org.kuali.rice.core.framework.config.module.ModuleConfigurer;
26  
27  public class KpmeModuleConfigurer extends ModuleConfigurer {
28  
29      public KpmeModuleConfigurer() {
30          setValidRunModes(Arrays.asList(RunMode.LOCAL));
31      }
32  
33      public KpmeModuleConfigurer(String moduleName) {
34          setModuleName(moduleName);
35          setValidRunModes(Arrays.asList(RunMode.LOCAL));
36      }
37  
38      @Override
39      public List<String> getAdditionalSpringFiles() {
40          final String files = ConfigContext.getCurrentContextConfig().getProperty("kpme." + getModuleName() + ".additionalSpringFiles");
41          return files == null ? Collections.<String>emptyList() : parseFileList(files);
42      }
43  
44      @Override
45      public RunMode getRunMode() {
46          return RunMode.LOCAL;
47      }
48  
49      protected String getDefaultConfigPackagePath() {
50          return "classpath:org/kuali/kpme/" + getModuleName().toLowerCase() + "/config/";
51      }
52  
53      private List<String> parseFileList(String files) {
54          final List<String> parsedFiles = new ArrayList<String>();
55          for (String file : Arrays.asList(files.split(","))) {
56              final String trimmedFile = file.trim();
57              if (!trimmedFile.isEmpty()) {
58                  parsedFiles.add(trimmedFile);
59              }
60          }
61  
62          return parsedFiles;
63      }
64  }