Review Board 1.5.4

Refactor Mapper logging for Java 5 and 6

Updated 2 years, 4 months ago

Derek Chen-Becker Reviewers
wip-dcb-issue-67
67 dchenbecker, dpp, marius, charles, heiko, joni, atsuhiko, jorge, naftoli, kris
None LiftWeb-archive
Refactor the Mapper Logging to use dynamic proxies for the logging statements so that we can properly implement the JDBC interfaces at runtime. This is needed so that we can support both JAva 5 and Java 6 without needing two source trees.
On my local test app.
Review request changed
Updated 2 years, 4 months ago (September 30th, 2009, 3:09 a.m.)
  • changed from to wip-dcb-issue-67

    • added 67
Added the issue and branch
Ship it!
Posted 2 years, 4 months ago (September 30th, 2009, 11:58 a.m.)
Looks good to me.  Once it's working, we might want to refactor it so there's always a call that passes a statement in and only puts a wrapper around it in debug mode.
  1. How do you mean? Right now the wrapper is only added if someone has explicitly added a log function. Otherwise, no wrapping occurs. Do you mean something different?
Posted 2 years, 4 months ago (September 30th, 2009, 6:15 p.m.)
Derek, why did you choose reflection? Last time I checked proxies (InvocationHandlers) tend to be quite slow comparing with actual method invocation. Even if reflection improved considerably I'd still stay away of it of there is a way using language composition to achieve the same thing.

Br's,
Marius
  1. I did read your post explaining about java 5 and 6 rationale :) ... but I wonder if there's another way.
  2. I would love for there to be another way. I looked at log4jdbc as a quick check and they actually use two source trees. The issue is that because this is a wrapper it has to be able to pass-through based on the interface. The interface methods at compile time are either going to be fixed at 1.5 or 1.6 compliance, and I can't figure out another way. This is a novel problem for me, so I'm open to suggestions on how else we might achieve this. 
  3. What if we keep the implementations separated and user in LiftRules or something sets the right implementation. So those 2 implementations will act as plugins. So in Boot user's will just have to use the righ implementation of our JDBC logging depending on what Java version they are using.
    
    Thoughts ?
  4. What is the benefit over DynamicProxy? Why should it not be automatic? And what if a project itself needs to be compiled for both 1.5 and 1.6?