Java tutorial
/** * Copyright (C) 2013 Seajas, the Netherlands. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3, as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.seajas.search.utilities.spring; import java.util.Map; import org.springframework.beans.factory.InitializingBean; import org.springframework.util.StringUtils; /** * Spring bean which initializes a given set of system properties. * * @author Jasper van Veghel <jasper@seajas.com> */ public class SystemPropertyInitializingBean implements InitializingBean { /** * Properties to be set. */ private Map<String, String> systemProperties; /** * Initialize the actual properties. */ @Override public void afterPropertiesSet() throws Exception { for (Map.Entry<String, String> systemProperty : systemProperties.entrySet()) if (StringUtils.hasText(systemProperty.getValue())) System.setProperty(systemProperty.getKey(), systemProperty.getValue()); } /** * Set the systemProperties. * * @param systemProperties */ public void setSystemProperties(final Map<String, String> systemProperties) { this.systemProperties = systemProperties; } }