users@jersey.java.net

Re: [Jersey] Problems with Paths and FreeMarkerTemplateProcessor

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 11 Jun 2009 10:37:27 +0200

On Jun 11, 2009, at 10:02 AM, Jonathan Cook - FM&T wrote:

> Hi Paul,
> Thanks for the comments. I'd seen Chris's blog entry as well. I
> eventually got it working after stepping through the Freemarker
> source. It was a
> little bit weird as the path in my unit test was working but when I
> put the same path into my FreemarkerTemplateProcessor it didn't work
> but after
> changing this path everything was ok so a bit of a red herring in
> the end.
> One other quick question, you might remember, we're using Jetty with
> Jersey so I have this line of code:
> servletHolder
> .setInitParameter("com.sun.ws.rest.config.property.packages",
>
> "com.bbc.newsi.feeds.sport.webservice.football.resources");
>
>
You can do one of two things:

1) include the package name where your freemarker template processor
resides:

servletHolder
.setInitParameter("com.sun.ws.rest.config.property.packages",

          
"com.bbc.newsi.feeds.sport.webservice.football.resources;<freemarker
package>");

i.e. more than one package can be declared using ";" to separate the
package names.

2) Create a META-INF/services/
com.sun.jersey.spi.template.TemplateProcessor, and add
      the fully qualified class name of your TemplateProcessor
implementation to that file.


> But I didn't want to put my FreemarkerTemplateProcessor in that
> resources package, it would live outside of football. Is it possible
> to register
>
> the providers some other way or specify multiple packages. I didn't
> really want to use the the * notation as we have other resources not
> specific to
>
> football that I don't want to register with this instance if that
> makes sense.
>
> Maybe when I've finished what I'm working on it might be useful to
> add this as an example?

Yes, i would be very happy to accept such a contribution :-)


> I'd be quite keen to contribute and have recently been
> contributing to apache camel as well. You might be intersted to know
> as well I did some work which generates graphical sports statistics
> dynamically
> on the fly using Jersey as well.

Cool! any links?

Paul.