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.PropertyUtils;
21  import org.kuali.common.util.service.DefaultPropertyService;
22  import org.kuali.common.util.service.PropertyService;
23  import org.springframework.beans.factory.FactoryBean;
24  
25  /**
26   * @deprecated
27   */
28  @Deprecated
29  public class PropertyFactoryBean extends org.kuali.common.util.property.DefaultPropertyLoadContext implements FactoryBean<Properties> {
30  
31  	protected static Properties instance;
32  	boolean singleton = false;
33  	PropertyService service = new DefaultPropertyService();
34  	boolean show;
35  
36  	@Override
37  	public Properties getObject() throws Exception {
38  		if (isSingleton()) {
39  			return getInstance();
40  		} else {
41  			Properties properties = service.load(this);
42  			if (show) {
43  				PropertyUtils.info(properties);
44  			}
45  			return properties;
46  		}
47  	}
48  
49  	protected synchronized Properties getInstance() {
50  		if (instance == null) {
51  			instance = service.load(this);
52  		}
53  		if (show) {
54  			PropertyUtils.info(instance);
55  		}
56  		return instance;
57  	}
58  
59  	@Override
60  	public Class<Properties> getObjectType() {
61  		return Properties.class;
62  	}
63  
64  	@Override
65  	public boolean isSingleton() {
66  		return this.singleton;
67  	}
68  
69  	public void setSingleton(boolean singleton) {
70  		this.singleton = singleton;
71  	}
72  
73  	public PropertyService getService() {
74  		return service;
75  	}
76  
77  	public void setService(PropertyService service) {
78  		this.service = service;
79  	}
80  
81  	public boolean isShow() {
82  		return show;
83  	}
84  
85  	public void setShow(boolean show) {
86  		this.show = show;
87  	}
88  }