users@jersey.java.net

Re: Beginners questions on Uri's and templates etc.

From: Jeff Gortatowsky <indanapt_at_yahoo.com>
Date: Wed, 12 Dec 2007 19:34:01 -0800 (PST)

Since I accidentally started the logging discussion, I'll weigh in. I pollute my code all over the place with logging. Almost, I admit, to a fault. I trust its appreciated by others if and when they need it sometime in the future (if it's useful logging). Log4j is my pal. I prefer it to using a debugger. That said, I suppose if I was a better engineer, I would not NEED logging. :( Unit tests are my friends. But when you did not write the tests or the code, logging can be your best friend.

Anyway my 'idea' was perhaps allowing me to register a listener when I registered my resources. At various 'interesting' places in the matching of my URIs to resources, it might call me back with information about the process and what it is 'thinking'. That way there is a call to listeners that pollutes the Jersey code but the grunt work of creating stringbuilders, loggers, etc is on the listener who provides the listener implementation... no Jersey code need be included to do any of that and there is no added dependencies. Just an interface. Jersey could even register it's own 'do nothing' listener so the listener chain would never be null and no branching logic would be needed to check for null.

No listener registered? No callbacks. Very little performance hit except maybe for the 'do nothing' listener. Well it was just an idea. A hook.

BTW: a combo of Jakub's example and Pauls sage advice got me on track and productive. I also tried Jersey on Guice but found it less than useful as often as not I have to return a Resource class to Jersey so that it moves on to the subresource.
 
---------------------------------------
Jeffrey D. Gortatowsky
Fullerton, California
"Madam, there is no such thing as a tough child -- if you parboil them first for seven hours, they always come out tender. " - W.C. Fields
"What wretched scoundrel stole the cork from my lunch?" - W.C. Fields