On Thu, Apr 22, 2010 at 2:37 AM, Bill Barker <billwbar...@verizon.net> wrote: > > > "Christopher Schultz" <ch...@christopherschultz.net> wrote in message > news:4bcf5f41.6060...@christopherschultz.net... >> >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> André, >> >> On 4/21/2010 3:46 PM, André Warnier wrote: >>> >>> Mark Thomas wrote: >>>> >>>> On 21/04/2010 20:24, André Warnier wrote: >>>>> >>>>> Mark Thomas wrote: >>>>> ... >>>>> >>>>>> I'd just use JAD and decompile it. >>>>>> >>>>> Thanks. But although my intentions are not obnoxious nor illegal nor >>>>> anything of the kind, I would not want to even come under suspicion of >>>>> reverse-engineering. So is there something that just lists the >>>>> standard >>>>> calls/methods used in it ? >>>> >>>> No. You can see the methods it exposes, but not the methods it uses. >>>> Time to add some debug code to your wrapper to see what is being >>>> called? >>>> >>> Mmmm. :-( >>> How do I do that, assuming I do not know in advance which methods it >>> calls ? >>> Do I need to define all the methods of HttpServletRequest in my wrapper, >>> just to make them trace their call ? >>> Or does there exist some more dummy-user-friendly methodology ? >> >> It's pretty inaccessible for novice Java programmers, but you could use >> the "proxy" API which is jsut about the coolest thing available in Java >> IMO. >> >> This is how you do the wrapping of the request: >> >> import java.lang.reflect.Proxy; >> import java.lang.reflect.InvocationHandler; >> >> public class RequestMethodCallLogger >> implements InvocationHandler, Filter >> { >> public void doFilter(...) { >> HttpServletRequest wrappedRequest >> = Proxy.newProxyInstance(HttpServletRequest.class.getClassLoader(), >> new Class[] { HttpServletRequest.class }, >> this); >> >> chain.doFilter(wrappedRequest, response); >> } >> >> public Object invoke(Object proxy, Method method, Object[] args) >> { >> // Log to your favorite logger here >> >> return method.invoke(proxy, args); >> } >> } >> >> Basically, the Proxy class allows you to intercept the calls to >> interface methods. The implementation of the "invoke" method is just a >> pass-through to the "real" method after logging (an exercise left for >> the reader). >> >> This can be optimized a bit if you need to use it long-term, but the >> above is about as compact as it gets. >> > > If it does a forward or include done the line, this won't work with any > remotely recent version of Tomcat. These versions enforce the spec > requirement that the Request has to be a subclass of HttpServletWrapper > wrapping the original request, or the original request.
Good point - which really kills the proxy approach as a general-purpose solution in this context... >> I'd still recommend the use of jad, honestly. >> >> - -chris >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.10 (MingW32) >> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ >> >> iEYEARECAAYFAkvPX0EACgkQ9CaO5/Lv0PCKVQCdG5SMXiySnsFEowVF7/44KM8s >> b7kAoIAGSzxOIWmKt4+z6ATkqslTl5uW >> =ykwF >> -----END PGP SIGNATURE----- -- Kris Schneider --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org