Java tutorial
/* * Copyright 2013-2014 the original author or authors. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.xdtech.core.config; import java.util.Properties; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; /** * * @author max.zheng * @create 2014-9-28?9:08:19 * @since 1.0 * @see */ public class PropertiesConfigurer extends PropertyPlaceholderConfigurer { private static Properties props = null; /** * ?applicationContext.xml??? */ @Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { super.processProperties(beanFactoryToProcess, props); PropertiesConfigurer.props = props; } /** * @Description: ?Spring?propertiesvalue * @Param: key ?key * @Return: value ? */ public static String getValue(String key) { return props.getProperty(key); } public static boolean sysIsInitDataToDb() { String isInitData = props.getProperty("system.isInitDataToDb"); return isInitData != null ? Boolean.valueOf(isInitData) : false; } public static void setAlreadyInitDataToDb() { props.setProperty("system.isInitDataToDb", "true"); } public static boolean sysIsInitDataToCache() { String isInitData = props.getProperty("system.isInitDataToCache"); return isInitData != null ? Boolean.valueOf(isInitData) : false; } }