001 /**
002 * Copyright 2010-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.common.util.spring;
017
018 import java.util.List;
019 import java.util.Properties;
020
021 import org.kuali.common.util.Assert;
022 import org.kuali.common.util.ProjectContext;
023 import org.springframework.beans.factory.FactoryBean;
024 import org.springframework.core.env.PropertySource;
025
026 public class GetPropertySourceFactoryBean implements FactoryBean<PropertySource<?>> {
027
028 ProjectContext project;
029 List<ProjectContext> others;
030 Properties properties;
031
032 @Override
033 public PropertySource<?> getObject() {
034 Assert.notNull(project, "project is null");
035 return SpringUtils.getGlobalPropertySource(project, others, properties);
036 }
037
038 @Override
039 public Class<PropertySource<?>> getObjectType() {
040 return null;
041 }
042
043 @Override
044 public boolean isSingleton() {
045 return false;
046 }
047
048 public ProjectContext getProject() {
049 return project;
050 }
051
052 public void setProject(ProjectContext project) {
053 this.project = project;
054 }
055
056 public List<ProjectContext> getOthers() {
057 return others;
058 }
059
060 public void setOthers(List<ProjectContext> others) {
061 this.others = others;
062 }
063
064 public Properties getProperties() {
065 return properties;
066 }
067
068 public void setProperties(Properties properties) {
069 this.properties = properties;
070 }
071
072 }