users@jersey.java.net

[Jersey] wiring in a jersey service with spring

From: phil swenson <phil.swenson_at_gmail.com>
Date: Mon, 28 Oct 2013 17:19:59 -0600

Hi, I'm writing my first jersey service.

I start up the Jersey Servlet like this:

private void registerRestServices(HTTPContext context) {
        Config config = new Config("rest",
"org.glassfish.jersey.servlet.ServletContainer");
        config.addInitParameter(ServerProperties.PROVIDER_PACKAGES,
"com.myco.service.rest");
        String servletURL = "/rest/*";
        context.addConfig(servletURL, config);
    }

Then I have a rest class like this:
@Path("/ProcessModel")
public class ProcessModelService {

    @Autowired
    private com.myco.service.process.GlueModelService glueModelService;

    public void
setGlueModelService(com.myco.service.process.GlueModelService
glueModelService){
        this.glueModelService = glueModelService;
    }



    @GET
    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_XML})
    public String processModels() {
        ProcessModel[] allProcessModels =
glueProcessModelService.getAllProcessModels();
        return allProcessModels;

    }
}

The jersey servlet starts fine. But I can't figure out how to use spring
wiring to inject any spring managed objects to my new jersey rest service
(in this case I'm trying to inject "glueModelService"

Could someone give me a hint on this?

I don't really understand how the jersey services get instantiated...

thanks,
phil