From a9b7bfae73900501605d13390ffefcda57fe4732 Mon Sep 17 00:00:00 2001 From: kascade Date: Sat, 15 Nov 2008 02:03:13 +0000 Subject: [PATCH] add timer proxy git-svn-id: https://svn2.assembla.com/svn/romraider/trunk@181 38686702-15cf-42e4-a595-3071df8bf5ea --- log4j.properties | 3 +-- .../io/connection/ConnectionManagerFactory.java | 9 +++++++++ .../romraider/io/j2534/api/J2534ConnectionManager.java | 8 ++++---- src/com/romraider/util/proxy/TimerWrapper.java | 3 +-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/log4j.properties b/log4j.properties index d5004a0b..47514496 100644 --- a/log4j.properties +++ b/log4j.properties @@ -1,4 +1,4 @@ -log4j.rootLogger=warn, stdout, file +log4j.rootLogger=info, stdout, file log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout @@ -9,4 +9,3 @@ log4j.appender.file.File=romraider.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%-5r %-5p [%t] - %m%n -log4j.logger.com.romraider.util.proxy.TimeWrapper=trace diff --git a/src/com/romraider/io/connection/ConnectionManagerFactory.java b/src/com/romraider/io/connection/ConnectionManagerFactory.java index 5252106a..6e5e8ba5 100644 --- a/src/com/romraider/io/connection/ConnectionManagerFactory.java +++ b/src/com/romraider/io/connection/ConnectionManagerFactory.java @@ -2,16 +2,25 @@ package com.romraider.io.connection; import com.romraider.io.j2534.api.J2534ConnectionManager; import com.romraider.io.serial.connection.SerialConnectionManager; +import static com.romraider.util.proxy.Proxifier.proxy; +import com.romraider.util.proxy.TimerWrapper; import org.apache.log4j.Logger; import static org.apache.log4j.Logger.getLogger; public final class ConnectionManagerFactory { private static final Logger LOGGER = getLogger(ConnectionManagerFactory.class); + private static final boolean ENABLE_TIMER = false; private ConnectionManagerFactory() { } public static ConnectionManager getManager(String portName, ConnectionProperties connectionProperties) { + ConnectionManager manager = manager(portName, connectionProperties); + if (ENABLE_TIMER) return proxy(manager, TimerWrapper.class); + return manager; + } + + private static ConnectionManager manager(String portName, ConnectionProperties connectionProperties) { try { return new J2534ConnectionManager(connectionProperties); } catch (Throwable t) { diff --git a/src/com/romraider/io/j2534/api/J2534ConnectionManager.java b/src/com/romraider/io/j2534/api/J2534ConnectionManager.java index ab684c61..86fd8149 100644 --- a/src/com/romraider/io/j2534/api/J2534ConnectionManager.java +++ b/src/com/romraider/io/j2534/api/J2534ConnectionManager.java @@ -23,22 +23,22 @@ package com.romraider.io.j2534.api; import com.romraider.io.connection.ConnectionManager; import com.romraider.io.connection.ConnectionProperties; -import com.romraider.io.j2534.op20.J2534OpenPort20; +import com.romraider.io.j2534.op20.Old_J2534OpenPort20; import static com.romraider.io.j2534.op20.OpenPort20.CONFIG_P1_MAX; import static com.romraider.io.j2534.op20.OpenPort20.CONFIG_P3_MIN; import static com.romraider.io.j2534.op20.OpenPort20.CONFIG_P4_MIN; import static com.romraider.io.j2534.op20.OpenPort20.FLAG_ISO9141_NO_CHECKSUM; import static com.romraider.io.j2534.op20.OpenPort20.PROTOCOL_ISO9141; import static com.romraider.util.ParamChecker.checkNotNull; -import static com.romraider.util.proxy.Proxifier.proxy; -import com.romraider.util.proxy.TimerWrapper; import org.apache.log4j.Logger; import static org.apache.log4j.Logger.getLogger; public final class J2534ConnectionManager implements ConnectionManager { private static final Logger LOGGER = getLogger(J2534ConnectionManager.class); + private final J2534 api = new Old_J2534OpenPort20(PROTOCOL_ISO9141); +// private final J2534 api = new J2534OpenPort20(PROTOCOL_ISO9141); // private final J2534 api = proxy(new Old_J2534OpenPort20(PROTOCOL_ISO9141), TimerWrapper.class); - private final J2534 api = proxy(new J2534OpenPort20(PROTOCOL_ISO9141), TimerWrapper.class); + // private final J2534 api = proxy(new J2534OpenPort20(PROTOCOL_ISO9141), TimerWrapper.class); private int channelId; private int deviceId; private int msgId; diff --git a/src/com/romraider/util/proxy/TimerWrapper.java b/src/com/romraider/util/proxy/TimerWrapper.java index 9e29d992..663f7a1e 100644 --- a/src/com/romraider/util/proxy/TimerWrapper.java +++ b/src/com/romraider/util/proxy/TimerWrapper.java @@ -26,9 +26,8 @@ public final class TimerWrapper implements Wrapper { } private void log(Method method, long time) { - if (!LOGGER.isTraceEnabled()) return; String c = delegate.getClass().getSimpleName(); String m = method.getName(); - LOGGER.trace("[TIMER] - " + c + "." + m + ": " + time + "ms"); + LOGGER.error("[TIMER] - " + c + "." + m + ": " + time + "ms"); } }