01 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/util/NameUpdater.java,v 1.5 2004/02/14 03:34:30 sebb Exp $ 02 /* 03 * Copyright 2003-2004 The Apache Software Foundation. 04 * 05 * Licensed under the Apache License, Version 2.0 (the "License"); 06 * you may not use this file except in compliance with the License. 07 * You may obtain a copy of the License at 08 * 09 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 /* 20 * Created on Jun 13, 2003 21 */ 22 package org.apache.jmeter.util; 23 24 import java.io.FileInputStream; 25 import java.util.Properties; 26 27 import org.apache.jorphan.logging.LoggingManager; 28 import org.apache.log.Logger; 29 30 /** 31 * @author ano ano 32 * @version $Revision: 1.5 $ 33 */ 34 public final class NameUpdater 35 { 36 private static Properties nameMap; 37 private static Logger log = LoggingManager.getLoggerForClass(); 38 39 static { 40 nameMap = new Properties(); 41 try 42 { 43 nameMap.load( 44 new FileInputStream( 45 JMeterUtils.getJMeterHome() 46 + JMeterUtils.getPropDefault( 47 "upgrade_properties", 48 "/bin/upgrade.properties"))); 49 } 50 catch (Exception e) 51 { 52 log.error("Bad upgrade file",e); 53 } 54 } 55 56 public static String getCurrentName(String className) 57 { Rate58 if (nameMap.containsKey(className)) 59 { 60 String newName= nameMap.getProperty(className); 61 log.info("Upgrading class "+className+" to "+newName); 62 return newName; 63 } 64 return className; 65 } 66 67 public static String getCurrentName(String propertyName, String className) 68 { 69 String key= className+"/"+propertyName; Rate70 if (nameMap.containsKey(key)) 71 { 72 String newName= nameMap.getProperty(key); 73 log.info("Upgrading property "+propertyName+" to "+newName); 74 return newName; 75 } 76 return propertyName; 77 } 78 79 public static String getCurrentName(String value, String propertyName, String className) 80 { 81 String key= className+"."+propertyName+"/"+value; Rate82 if (nameMap.containsKey(key)) 83 { 84 String newValue= nameMap.getProperty(key); 85 log.info("Upgrading value "+value+" to "+newValue); 86 return newValue; 87 } 88 return value; 89 } 90 91 /** 92 * Private constructor to prevent instantiation. 93 */ 94 private NameUpdater() 95 { 96 } 97 }