001/** 002 * Copyright 2010-2014 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 */ 016package org.kuali.common.util.spring; 017 018import java.util.List; 019import java.util.Properties; 020 021import org.kuali.common.util.PropertyUtils; 022import org.springframework.beans.factory.FactoryBean; 023import org.springframework.util.Assert; 024 025public class PropertiesCombinerFactoryBean implements FactoryBean<Properties> { 026 027 List<Properties> listOfProperties; 028 boolean show; 029 030 @Override 031 public Properties getObject() throws Exception { 032 Assert.notNull(listOfProperties, "listOfProperties is null"); 033 Properties properties = PropertyUtils.combine(listOfProperties); 034 if (show) { 035 PropertyUtils.info(properties); 036 } 037 return properties; 038 } 039 040 @Override 041 public Class<Properties> getObjectType() { 042 return Properties.class; 043 } 044 045 @Override 046 public boolean isSingleton() { 047 return false; 048 } 049 050 public List<Properties> getListOfProperties() { 051 return listOfProperties; 052 } 053 054 public void setListOfProperties(List<Properties> listOfProperties) { 055 this.listOfProperties = listOfProperties; 056 } 057 058 public boolean isShow() { 059 return show; 060 } 061 062 public void setShow(boolean show) { 063 this.show = show; 064 } 065 066}