users@jersey.java.net

Re: [Jersey] Re: roll-your-own Guice

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 02 Jul 2009 08:00:22 +0200

Hi,

Strictly speaking i am on holiday, i definitely will not be able to
follow up with any for emails until return, because i will not have
email access.


Christian's article is fairly old (and in your previous email you were
referring to some old classes).

Make sure you are using Jersey 1.1.0-ea.

The last section of the following explains how to use Guice:

   https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.1.0-ea/jersey/dependencies.html

See also the JavaDoc:

   https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html


If you are not using maven then you require the 1.1.0-ea server and/or
client jars plus:

   http://download.java.net/maven/2/com/sun/jersey/contribs/jersey-guice/1.1.0-ea/jersey-guice-1.1.0-ea.jar

If you download Guice you require: aopalliance.jar, guice-2.0.jar and
guice-servlet.jar.

Note that we compile against Guice as distributed with GuiceyFruit.
But if you are using standard Guice 2.0 features then jars from Guice
should work.

Hope this helps,
Paul.

On Jul 2, 2009, at 6:10 AM, Christopher Piggott wrote:

> Perhaps I should explain what I am trying to do a little better.
>
> I extendi com.sun.jersey.spi.container.servlet.ServletContainer:
>
> public class MyServletContainer extends ServletContainer {
> @Override
> protected void configure(ServletConfig servletConfig,
> ResourceConfig rc,
> WebApplication wa) {
> super.configure(servletConfig, rc, wa);
> ...
> }
> }
>
> The guts of that method set up an InjectableProvider that is able to
> inject my own resources of various sorts. It works, but it is tedious
> to add new things that I want to inject...it's basically a large if
> ... else ... else block that identifies what is to be injected and
> returns an Injectable<Object> for each.
>
> What I'd like to do is replace this with a more generic injection
> framework. Guice looks lpretty good. What I don't understand is how
> to wire it into jersey's ServletContainer. I did my best to follow
> Christian Rivasseau's jersey-guice article, but the link to his source
> code is dead, and I wasn't clear where to find the ResourceProvider
> interface or how to hook it in so that Jersey uses it.
>
>
> The sense I get is that I have to write my own resourceConfigClass and
> splice it in as an init-param to the ServletContainer. Is this close?
>
> --Chris
>
>
>
> On Wed, Jul 1, 2009 at 10:58 PM, Christopher Piggott<cpiggott_at_gmail.com
> > wrote:
>> Hi,
>>
>> I'm trying to find all the jars I need to add guice to my jersey
>> based
>> application. Right now I'm having trouble finding, among other
>> things:
>>
>> com.sun.ws.rest.api.container.ContainerException;
>> com.sun.ws.rest.spi.resource.ResourceProvider;
>> com.sun.ws.rest.spi.resource.ResourceProviderContext;
>>
>> Something tells me this shouldn't be quite so dfficult.
>>
>> 1) Are there any more up-to-date examples?
>> 2) Most of the jersey "downloads" page has maven and non-maven links,
>> but not the guice side. Would somebody be willing to fix up that
>> document to include links to the jars for non-maven users?
>>
>> Thanks for any pointers.
>>
>> --Chris
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>