Skip to main content

How do I get a @InstanceResolverAnnotation to be used in Glassfish 3.1.2?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
dankaplan
Offline
Joined: 2014-06-04

I'm trying to follow this blog post here: http://developian.blogspot.in/2008/11/google-guice-and-jax-ws.html (the library source can be seen here: https://java.net/projects/jax-ws-commons/sources/svn/show/trunk/guice/sr... )

This is mostly working, but the key missing part is that the GuiceManagedInstanceResolver doesn't ever get used. It's an AbstractMultiInstanceResolver and it's referred to in an annotation like this:

import com.google.inject.Module;
import com.sun.xml.ws.api.server.InstanceResolverAnnotation;

import javax.xml.ws.spi.WebServiceFeatureAnnotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/*
From http://developian.blogspot.in/2008/11/google-guice-and-jax-ws.html and https://java.net/projects/jax-ws-commons/sources/svn/show/trunk/guice/sr...

I would have used https://jax-ws-commons.java.net/guice/ but apparently it doesn't work with guice 3.0
*/
@Retention(RUNTIME)
@Target(TYPE)
@Documented
@WebServiceFeatureAnnotation(id = GuiceManagedFeature.ID, bean = GuiceManagedFeature.class)
@InstanceResolverAnnotation(GuiceManagedInstanceResolver.class)
public @interface GuiceManaged {
public Class<? extends Module>[] module();
}

If I put that annotation on a @WebService, the GuiceManagedFeature gets used, but the GuiceManagedInstanceResolver never gets called. This source code is ~5 years old so I figure maybe something has changed where @InstanceResolverAnnotation isn't considered anymore? Should I use an annotation other than @InstanceResolverAnnotation? Has it been replaced with a different annotation? Is there a different way to do this now?