On Sep 29, 2008, at 10:41 PM, Gili wrote:
>
> Hi Paul,
>
> I'm trying to update
> https://jersey.dev.java.net/servlets/ReadMsg?list=users&msgNo=1326
> against
> the latest version of Jersey (is 1.0 really out?)
>
No, the latest version is 1.0-ea-SNAPSHOT, very close to 1.0 :-)
1.0 will be out very soon. Most likely by the end of next week.
> I could use your help...
>
> What am I supposed to replace "Injectable<Named, Object>" with?
>
Do the following:
public class GuiceNamedInjectable extends InjectableProvider<Named,
Type> {
public Scope getScope() {
return Scope.Undefined;
}
public Injectable<Object> getInjectable(ComponentContext ic,
Named a, final Type c) {
return new Injectable<Object> {
public Object getValue(HttpContext context) {
return
GuiceComponentProvider.getInjector().getInstance(
Key.get(c, a));
}
}
}
}
Then modify the initiate method as follows:
@Override
protected void initiate(ResourceConfig config, WebApplication app)
{
config.getClasses().add(GuiceNamedInjectable.class);
// config.getSingletons().add(new GuiceNamedInjectable());
app.initiate(config, new GuiceComponentProvider());
}
The above is not tested but i think it is close enough that it should
work.
You can find the JavaDoc of ComponentProvider, InjectableProvider and
Injectable here:
http://download.java.net/maven/2/com/sun/jersey/jersey-core/1.0-ea-SNAPSHOT/jersey-core-1.0-ea-SNAPSHOT-javadoc.jar
I would be very happy to accept a Guice contribution to the Jersey
distribution :-)
Also, it might be interesting to see if we can make things abstract
from Servlet so that it works for other HTTP containers.
Hope this helps, if you have further problems then if you can send me
a zipped maven project with a test i might be able to debug the issues
for you,
Paul.
> Thanks,
> Gili
> --
> View this message in context: http://n2.nabble.com/Using-Guice-with-JAX-RS-tp1127230p1127377.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>