a) If 'SomeDependency' is implemented as a Spring Bean then all u need is
@Autowired private SomeDependency dependency;
and have a bean declared in the Spring config file with id = 'dependency'.
OR
b) Use Context and Depenendency Injection
@Inject private SomeDependency dependency;
________________________________
From: Max Hajek <wickedoldlunatic_at_gmail.com>
To: users_at_jersey.dev.java.net
Sent: Thu, March 18, 2010 12:00:22 PM
Subject: [Jersey] Pass interfaces to a resource class
Hi,
this is probably a relatively stupid question, but bear with me, I'm new to JAX-RS and the general world of writing webservices with Java (although I've been doing completely different Java stuff for years). I've googled a lot, but not really found a clear explanation, so now I use this medium and annoy your ;>
How can I pass interfaces to resource classes?
E.g., if I got a class
@Path("/services")
public class Service {
private SomeDependency dependency;
@Path("/register")
@GET
@Produces("text/plain")
public String getSomething() {
return dependency.getSomething();
}
}
where SomeDependency is an interface
interface SomeDependency {
String getSomething();
}
How could I pass a concrete implementation of SomeDependency into Service instances constructed on the fly?
Many thanks,
Max