users@jersey.java.net

[Jersey] How do I wire in my own collaborators?

From: Wojtek <kolesgit_at_10g.pl>
Date: Thu, 18 Aug 2011 22:56:21 +0200

Hi,

I have a method to start up my application:

public void start() throws IOException {
    final Map<String, String> initParams = new HashMap<String, String>();
    initParams.put("com.sun.jersey.config.property.packages", "com.example");
    threadSelector = GrizzlyWebContainerFactory.create(baseUri, initParams);
}

And I have a resource:

@Path("/notification")
public class NotificationResource {
    // HOW DO I INJECT THIS GUY?
    private MySampleCollabolator mySampleCollabolator;

    @POST
    public void create() {
        System.out.println("Hello world");
    }
}

What is the proper way of handling dependencies? I would like my resources to communicate with other objects, how do I wire them together?

Thanks!
Wojtek.