View Javadoc
1   /**
2    * Copyright 2010-2014 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.common.util.spring;
17  
18  import java.util.Properties;
19  
20  import org.kuali.common.util.Assert;
21  import org.springframework.beans.factory.FactoryBean;
22  import org.springframework.beans.factory.InitializingBean;
23  
24  /**
25   * Copy properties from <code>source</code> to <code>target</code>. Properties from <code>source</code> override properties from <code>target</code>
26   */
27  public class AddToPropertiesFactoryBean implements FactoryBean<Properties>, InitializingBean {
28  
29  	Properties source;
30  	Properties target;
31  
32  	@Override
33  	public void afterPropertiesSet() throws Exception {
34  		Assert.notNull(source, "source is null");
35  		Assert.notNull(target, "target is null");
36  		target.putAll(source);
37  	}
38  
39  	@Override
40  	public Properties getObject() throws Exception {
41  		return target;
42  	}
43  
44  	@Override
45  	public Class<Properties> getObjectType() {
46  		return Properties.class;
47  	}
48  
49  	@Override
50  	public boolean isSingleton() {
51  		return false;
52  	}
53  
54  	public Properties getSource() {
55  		return source;
56  	}
57  
58  	public void setSource(Properties source) {
59  		this.source = source;
60  	}
61  
62  	public Properties getTarget() {
63  		return target;
64  	}
65  
66  	public void setTarget(Properties target) {
67  		this.target = target;
68  	}
69  
70  }