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包
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包
相关文章推荐
- java的HashSet和TreeSet在add()用法的区别。
- 跨服务器Session共享的四种方法
- 【Stanford机器学习笔记】6-Neural Networks: Representation
- 整合Kafka到Spark Streaming——代码示例和挑战
- android打开系统程序
- 集群session共享机制
- hdu 4708 Rotation Lock Puzzle
- 用配置文件存储连接数据库的字符串
- 听云-服务器监控,window+tomcat配置
- Unreal Engine 4 —— 可交互绳索的构建
- Unreal Engine 4 —— 可交互绳索的构建
- Java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory 解决方案
- RxJava-操作符 初步学习
- 【17】-冒泡排序详解
- 【17】-冒泡排序详解
- 【17】-冒泡排序详解
- 包装类转化、正则表达式
- 如何用Notepad++运行Python脚本
- 编译Apache问题
- 20145211 《Java程序设计》实验报告四: Android开发基础