+ false
jar-with-dependencies
diff --git a/src/main/java/com/taobao/profile/Manager.java b/src/main/java/com/taobao/profile/Manager.java
index f5e61fc..83b8600 100644
--- a/src/main/java/com/taobao/profile/Manager.java
+++ b/src/main/java/com/taobao/profile/Manager.java
@@ -26,10 +26,6 @@
* @since 2012-1-9
*/
public class Manager {
- /**
- * 默认配置文件
- */
- private static final String DEFAULT_CONFIG = "profile";
/**
* 远程连接端口
@@ -121,7 +117,7 @@ private Manager() {}
* 初始化配置
*/
public void initialization() {
- profConfig = new ProfConfig(DEFAULT_CONFIG);
+ profConfig = new ProfConfig();
NEED_NANO_TIME = profConfig.isNeedNanoTime();
IGNORE_GETSET_METHOD = profConfig.isIgnoreGetSetMethod();
METHOD_LOG_PATH = profConfig.getMethodFilePath();
diff --git a/src/main/java/com/taobao/profile/config/ConfigureProperties.java b/src/main/java/com/taobao/profile/config/ConfigureProperties.java
new file mode 100644
index 0000000..7008c60
--- /dev/null
+++ b/src/main/java/com/taobao/profile/config/ConfigureProperties.java
@@ -0,0 +1,236 @@
+package com.taobao.profile.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.InvalidPropertiesFormatException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import com.taobao.profile.utils.Utilities;
+import com.taobao.profile.utils.VariableNotFoundException;
+
+/**
+ * 用于加载配置文件的properties类,与java默认的不同,在调用get方法返回value时,会对value
+ * 会检查是否存在变量(如:${user.home}),如果存在,会将变量替换成具体的值。
+ *
该类使用dectorator设计模式
+ *
+ *
示例文件内容(profile.properties):
+ *
+ * logFileName = tprofiler.log
+ * methodFileName = tmethod.log
+ * samplerFileName = tsampler.log
+ *
+ * startProfTime = 9:00:00
+ * endProfTime = 11:00:00
+ * eachProfUseTime = 5
+ * eachProfIntervalTime = 50
+ * samplerIntervalTime = 20
+ * port = 50000
+ * debugMode = false
+ * needNanoTime = false
+ * ignoreGetSetMethod = true
+ *
+ * logFilePath = ${user.home}/logs/${logFileName}
+ * methodFilePath = ${user.home}/logs/${methodFileName}
+ * samplerFilePath = ${user.home}/logs/${samplerFileName}
+ *
+ * excludeClassLoader = org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader
+ * includePackageStartsWith = com.taobao;com.taobao.common
+ * excludePackageStartsWith = com.taobao.sketch;org.apache.velocity;com.alibaba;com.taobao.forest.domain.dataobject
+ *
+ * 未例代码:
+ *
+ * Properties properties = new Properties();
+ * InputStream in = getClass().getClassLoader().getResourceAsStream("profile.properties");
+ * properties.load(in);
+ *
+ * Properties context = new Properties(System.getProperties());
+ * context.putAll(System.getProperties());
+ * context.putAll(properties);
+ * try{
+ * ConfigureProperties configureProperties = new ConfigureProperties(properties, context);
+ * String logFilePath = configureProperties.getProperty("logFilePath");
+ * Assert.assertEquals(logFilePath, System.getProperty("user.home") + "/logs/tprofiler.log");
+ * }finally{
+ * in.close();
+ * }
+ *
+ * @author manlge
+ * @since 2013-08-18
+ */
+public class ConfigureProperties extends Properties {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3868173073422671544L;
+
+ private Properties delegate;
+
+ private Properties context;
+
+
+ public ConfigureProperties(Properties delegate, Properties context) {
+ super();
+ this.delegate = delegate;
+ this.context = context;
+ }
+
+ public Object setProperty(String key, String value) {
+ return delegate.setProperty(key, value);
+ }
+
+ public void load(Reader reader) throws IOException {
+ delegate.load(reader);
+ }
+
+ public int size() {
+ return delegate.size();
+ }
+
+ public boolean isEmpty() {
+ return delegate.isEmpty();
+ }
+
+ public Enumeration