001 /** 002 * Copyright 2010-2012 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.Properties; 019 020 import org.kuali.common.util.Assert; 021 import org.springframework.beans.factory.FactoryBean; 022 import org.springframework.beans.factory.InitializingBean; 023 024 /** 025 * Copy all of the mappings from <code>source</code> to <code>target</code>. The <code>source</code> mappings replace any existing <code>target</code> mappings 026 */ 027 public class PutAllPropertiesFactoryBean implements FactoryBean<Properties>, InitializingBean { 028 029 Properties source; 030 Properties target; 031 032 @Override 033 public void afterPropertiesSet() throws Exception { 034 Assert.notNull(source, "source is null"); 035 Assert.notNull(target, "target is null"); 036 target.putAll(source); 037 } 038 039 @Override 040 public Properties getObject() throws Exception { 041 return target; 042 } 043 044 @Override 045 public Class<Properties> getObjectType() { 046 return Properties.class; 047 } 048 049 @Override 050 public boolean isSingleton() { 051 return false; 052 } 053 054 public Properties getSource() { 055 return source; 056 } 057 058 public void setSource(Properties source) { 059 this.source = source; 060 } 061 062 public Properties getTarget() { 063 return target; 064 } 065 066 public void setTarget(Properties target) { 067 this.target = target; 068 } 069 070 }