Is there some way to take SOAP web service classes creates with JAX-WS and inject them with, say, Guice 3.0 (guice-persist) transactions or even just plain ol’ dependency injection? The guiceyfruit package provided a @GuiceManaged annotation that made this possible with Guice 2.0, but guiceyfruit (from my testing) appears to be incompatible with Guice 3, and I don’t think the project is active any longer.
Perhaps because there is another way of doing this? Maybe a JSR standard way?
I came across this same issue a while back and I had a look at the Guicyfruit code and decided to extract what I needed. This resulted in three classes.
First we need an annotation that we can use to annotate our web service endpoint with.
GuiceManaged.java
Second we need the GuiceManagedFeature mentioned in the annotation above.
GuiceManagedFeature.java
And third we create the actual resolver.
GuiceManagedInstanceResolver.java
The above example uses SLF4J for logging but it’s of course up to you to use whatever you wish.