简介:
http://cxf.apache.org/distributed-osgi.html
single bundle介绍:
http://cxf.apache.org/dosgi-single-bundle-distribution.html
需要jar包
cxf-dosgi-ri-singlebundle-distribution-1.3.jar
下载地址 http://cxf.apache.org/dosgi-releases.html
例子:
http://www.bubuko.com/infodetail-1252224.html
http://eclipsesource.com/blogs/2014/02/04/step-by-step-how-to-bring-jax-rs-and-osgi-together/
---其他内容,自行脑补
Activator.java
public void start(BundleContext bundleContext) throws Exception {
System.out.println("start--oDemo");
Activator.context = bundleContext;
JAXRSServerFactoryBean restServer = new JAXRSServerFactoryBean();
restServer.setResourceClasses(HelloWorldServiceImpl.class);
restServer.setAddress("http://localhost:9999/");
restServer.create();
System.out.println("created==========");
}
HelloWorldServiceImpl.JAVA
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/json")
public class HelloWorldServiceImpl {
@GET
@Path("/a")
@Produces({ "application/json"})
public String sayHello() {
System.out.println("hello");
return "{ssss:4444}";
}
}
jar包