您的位置:首页 > 其它

OSGI与cxf结合发布rest接口

2016-05-01 17:23 1061 查看
简介:
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包

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: