Can I create a restful service with interface and implementation class?
If so, will all JAX-RS related imports go into the interface?
I am using jersey2.4 an
In the class ResourceConfig
, there is a constructor like this
ResourceConfig(Class>... classes)
The constructor create a new resource configuration initialized with a given set of resource/provider classes.
So you can extend ResourceConfig
to register the implementation class.
public class RestConfig extends ResourceConfig {
public RestConfig() {
// register the implementation class
super(MyServiceImpl.class);
}
}
Then, configure web.xml
.
Scivantage REST Service
org.glassfish.jersey.servlet.ServletContainer
javax.ws.rs.Application
foo.bar.RestConfig
1
But the simplest way is that register the implementation class in web.xml
.
Scivantage REST Service
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.classnames
foo.bar.impl.MyServiceImpl
1