- 浏览: 1123489 次
- 性别:
- 来自: 火星郊区
博客专栏
-
OSGi
浏览量:0
文章分类
- 全部博客 (695)
- 项目管理 (48)
- OSGi (122)
- java (79)
- Vaadin (5)
- RAP (47)
- mysql (40)
- Maven (22)
- SVN (8)
- 孔雀鱼 (10)
- hibernate (9)
- spring (10)
- css (3)
- 年审 (6)
- ant (1)
- jdbc (3)
- FusionCharts (2)
- struts (4)
- 决策分析 (2)
- 生活 (10)
- 架构设计 (5)
- 破解 (2)
- 狼文化 (4)
- JVM (14)
- J2EE (1)
- 应用服务器 (1)
- 我的链接 (5)
- 数学 (2)
- 报表 (1)
- 百科 (6)
- Flex (7)
- log4j (2)
- PHP (1)
- 系统 (2)
- Web前端 (7)
- linux (6)
- Office (1)
- 安全管理 (5)
- python (2)
- dom4j (1)
- 工作流 (3)
- 养生保健 (4)
- Eclipse (8)
- 监控开发 (1)
- 设计 (3)
- CAS (1)
- ZK (41)
- BluePrint (3)
- 工具 (1)
- SWT (7)
- google (2)
- NIO (1)
- 企业文化 (2)
- Windoes (0)
- RCP (7)
- JavaScript (10)
- UML (1)
- 产品经理 (2)
- Velocity (10)
- C (1)
- 单元测试 (1)
- 设计模式 (2)
- 系统分析师 (2)
- 架构 (4)
- 面试 (2)
- 代码走查 (1)
- MongoDB (1)
- 企业流程优化 (1)
- 模式 (1)
- EJB (1)
- Jetty (1)
- Git (13)
- IPV6 (1)
- JQuery (8)
- SSH (1)
- mybatis (10)
- SiteMesh (2)
- JSTL (1)
- veloctiy (1)
- Spring MVC (1)
- struts2 (3)
- Servlet (1)
- 权限管理 (1)
- Java Mina (1)
- java 系统信息 (6)
- OSGi 基础 (3)
- html (1)
- spring--security (6)
- HTML5 (1)
- java爬虫搜索 (1)
- mvc (3)
最新评论
-
Tom.X:
http://osgia.com/
将web容器置于OSGi框架下进行web应用的开发 -
chenyuguxing:
你好, 为什么我的bundle export到felix工程中 ...
在Apache Felix中运行bundle -
string2020:
<niceManifest>true</ni ...
Bundle Plugin for Maven -
jsonmong:
OSGI,是未来的主流,目前已相当成熟。应用OSGI比较好的, ...
基于OSGi的声明式服务 -
zyhui98:
貌似是翻译过来的,有很少人在linux上做开发吧
如何成为“10倍效率”开发者
一般情况下,服务对象在注册后,任何其它的Bundle在请求该服务时,OSGi容器都是返回同一个对象。如果我们需要为每一个 Bundle消费者返回不同的服务对象,或者,在真正需要该服务对象时才创建。对于这些情况,我们可以创建一个实现ServiceFactory接口的 类,把该类的对象注册为服务(不是注册实际的服务对象),这样,当Bundle请求该服务时,ServiceFactory实现类将接管该请求,为每个 Bundle新建一个实际的服务对象。以下是服务工厂的使用范例源码:
1、服务接口及其实现类
- public class HelloServiceImpl implements HelloService {
- public String sayHello(String name) {
- return "Hello " + name;
- }
- }
2、服务工厂类
- public class HelloServiceFactory implements ServiceFactory {
- //当请求服务时,OSGi容器会调用该方法返回服务对象。
- //当服务对象不为null时,OSGi框架会缓存这个对象,即对于同一个消费者,将返回同一个服务对象。
- public Object getService(Bundle bundle, ServiceRegistration serviceRegistration) {
- System.out.println("创建HelloService对象:" + bundle.getSymbolicName());
- HelloService helloService = new HelloServiceImpl();
- return helloService;
- }
- //当Bundle释放服务时,OSGi容器会调用该方法
- public void ungetService(Bundle bundle, ServiceRegistration serviceRegistration, Object service) {
- System.out.println("释放HelloService对象:" + bundle.getSymbolicName());
- }
- }
3、Bundle激活器类
- public class Activator implements BundleActivator {
- ServiceRegistration serviceRegistration;
- public void start(BundleContext context) throws Exception {
- //注册服务
- HelloServiceFactory helloServiceFactory = new HelloServiceFactory();
- serviceRegistration = context.registerService(HelloService.class .getName(), helloServiceFactory, null );
- //获取服务(通过服务工厂取得)
- ServiceReference serviceReference = context.getServiceReference(HelloService.class .getName());
- HelloService selloService = (HelloService)context.getService(serviceReference);
- System.out.println("1: " + selloService.sayHello( "cjm" ));
- //第二次取得的服务对象与之前取得的是同一个对象
- serviceReference = context.getServiceReference(HelloService.class .getName());
- selloService = (HelloService)context.getService(serviceReference);
- System.out.println("2: " + selloService.sayHello( "cjm" ));
- }
- public void stop(BundleContext context) throws Exception {
- serviceRegistration.unregister();
- }
- }
发表评论
-
关于Felix Log Service
2012-12-07 16:44 1515OSGi服务纲要规范中定义了服务于OSGi平台的通用日志服 ... -
Maven 3 Felix 4 Eclipse 的搭建与部署(部分转载自别人文章)
2012-10-18 10:24 19914.1.开发环境搭建 4.2开发工具 Maven 3 F ... -
【绝对路径】OSGi环境中获取Plugin/Bundle中文件资源的绝对路径
2012-10-08 10:53 2374摘要:在进行Eclipse RCP开发的过程中,需要使用一 ... -
OpenCore:基于OSGi开发纯插件体系结构的WEB应用程序
2012-09-21 17:46 1376随着OSGi/Equinox逐渐成为Java EE服务端的基础 ... -
OSGi技术在Java Web开发中的应用
2012-09-20 11:26 1366随着 Java SE 对模块化功能原生支持的一再推迟(据最 ... -
OSGI典型的应用案例
2012-09-20 11:26 1570OSGI典型的应用案例主要有两个:分别是Eclipse和BMW ... -
OSGi特点
2012-09-20 11:26 12091、JRE版本无关性。虽然Java一直被人们认为是“Write ... -
OSGI与JMX 的关系
2012-09-19 17:09 1018不过重点是: JMX 本来设计的用途就只为了管理,我们不 ... -
在equinox环境开发web应用的"利器" -- registerResources()方法 详解
2012-09-19 17:07 1192registerResources()方法详解 1、简介 ... -
在equinox环境开发web应用的"利器" -- 序
2012-09-19 17:05 1325在equinox环境中开发web应用必须要借助一些工具包提供的 ... -
equinox环境下web应用资源的部署
2012-09-19 17:04 1266osgi的equinox实现环境下,web服务器和web应用都 ... -
OSGi产生的背景--在繁荣的混乱之中走出困惑
2012-09-19 16:58 1118软件的复杂性正在以惊 ... -
将web容器置于OSGi框架下进行web应用的开发
2012-09-16 14:26 3486将web容器置于OSGi框架下,其实就是将web容器做成OSG ... -
在Eclipse中开发OSGi Bundle
2012-09-16 14:26 1291Eclipse为开发OSGI Bundle提供了良好的支持,它 ... -
【第一代服务注册形式】 - 将一个Bundle注册为服务
2012-09-14 10:09 11081、创建业务接口类及其实现类 Java代码 ... -
Declarative Services规范简介及应用
2012-09-14 10:08 1372Declarative Services 是一 ... -
用FileInstall管理Bundle的动态安装、启动、卸载
2012-09-14 10:07 12971、文件目录如下: F:\study_osgi ... -
服务跟踪(ServiceTracker)
2012-09-14 09:58 1127当多个Bundle使用同一 ... -
OSGi容器中Bundle之间Synchronous Communication
2012-09-11 17:07 1499OSGi Core定义了一个服务层,提供了一个Bundl ... -
OSGI 中嵌入 Http 服务器的运行环境
2012-07-31 13:44 3016Eclipse 4.2 OSGI 依赖的Bundle: or ...
相关推荐
nexus-2.12.0-01-bundle
adt-bundle-windows-x86-20140624
adt-bundle-windows-x86-20140624
VMware-Horizon-Extras-Bundle-5.1.0-13920927
hudi-hadoop-mr-bundle-0.11.0.jar 配合文档
gatling-charts-highcharts-bundle-3.3.1-bundle,很好用的测试工具,有一定的学习成本。
下面俩个版本都能正常使用: 编译器版本号:adt-bundle-windows-x86_64-20130717 编译器版本号:adt-bundle-windows-x86_64-20130917 汉化方法: 拷贝中文包中的文件到编译器同名目录下
adt-bundle-windows-x86_64_20140101.zip下载,百度云盘分享链接下载
Android开发环境adt-bundle-windows-x86_64-20140624
postgis-bundle-pg15x64-setup-3.3.2-2.exe是一个安装程序,用于在64位操作系统上安装PostGIS和PostgreSQL扩展。PostGIS是一个开源的空间数据库扩展,它允许用户在PostgreSQL数据库中存储和查询地理空间数据。该扩展...
swiper-bundle.min.js
nexus-2.12.0-01-bundle
adt-bundle-windows-x86_64-20190307, 支持android4.4、android5.1 android6.0 android7.1 android8.1 androidP
Gatling主要用于测量基于HTTP的服务器,比如Web应用程序,RESTful服务等。 1 优点: 1.gatling和其他压力工具相比有个好处是放在同一内网环境下linux服务器上,这样避免其他压力使用办公机使用共有网络,网络情况对...
sqlite-netFx40-setup-bundle-x86-2010-1.0.113.0.exe
官网下载的OSS版:nexus-2.15.1-02-bundle.zip 用于搭建mavne私服 Nexus Repository OSS Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artifact),但这通常不是一个好的做法...
2013版adt-bundle
adt-bundle-windows-x86,adt-bundle-windows-x86,adt-bundle-windows-x86 adt-bundle-windows-x86,adt-bundle-windows-x86,adt-bundle-windows-x86 adt-bundle-windows-x86,adt-bundle-windows-x86,adt-bundle-...
nexus-2.12.0-01-bundle-.zip
官网下载的professional版:nexus-professional-2.15.1-02-bundle.zip 专业版 1.Nexus 简介 Nexus是Maven仓库管理器,也可以叫Maven的私服。Nexus是一个强大的Maven仓库管理器,它极大地简化了自己内部仓库的维护和...