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.Properties;
019
020import org.kuali.common.util.PropertyUtils;
021import org.kuali.common.util.service.DefaultPropertyService;
022import org.kuali.common.util.service.PropertyService;
023import org.springframework.beans.factory.FactoryBean;
024
025/**
026 * @deprecated
027 */
028@Deprecated
029public class PropertyFactoryBean extends org.kuali.common.util.property.DefaultPropertyLoadContext implements FactoryBean<Properties> {
030
031        protected static Properties instance;
032        boolean singleton = false;
033        PropertyService service = new DefaultPropertyService();
034        boolean show;
035
036        @Override
037        public Properties getObject() throws Exception {
038                if (isSingleton()) {
039                        return getInstance();
040                } else {
041                        Properties properties = service.load(this);
042                        if (show) {
043                                PropertyUtils.info(properties);
044                        }
045                        return properties;
046                }
047        }
048
049        protected synchronized Properties getInstance() {
050                if (instance == null) {
051                        instance = service.load(this);
052                }
053                if (show) {
054                        PropertyUtils.info(instance);
055                }
056                return instance;
057        }
058
059        @Override
060        public Class<Properties> getObjectType() {
061                return Properties.class;
062        }
063
064        @Override
065        public boolean isSingleton() {
066                return this.singleton;
067        }
068
069        public void setSingleton(boolean singleton) {
070                this.singleton = singleton;
071        }
072
073        public PropertyService getService() {
074                return service;
075        }
076
077        public void setService(PropertyService service) {
078                this.service = service;
079        }
080
081        public boolean isShow() {
082                return show;
083        }
084
085        public void setShow(boolean show) {
086                this.show = show;
087        }
088}