users@jersey.java.net

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

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 13 Dec 2007 11:04:17 +0100

Jeff Gortatowsky wrote:
> 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.
>

Agreed, that is where i think logging really is useful.


> 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.
>

Interesting, kind of like an intermediate solution between adaption of
UrlRule and UrlRules and direct logging.

I am happy to consider any patches and discuss code around this :-)


> BTW: a combo of Jakub's example and Pauls sage advice got me on track
> and productive.

Great!


> 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.
>

Yes, perhaps one way to solve this issue is to support the returning of
a Java class:

    @Path("sub-resource")
    Class geSubResourceClass() {
       return MyClass.class;
    }

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109