osgi实战学习之路:1. ant+bnd+felix搭建osgi之HelloWorld
开发环境分为三个部份
osgi_provider:
bundle开发环境,对外提供服务
osgi_consumer:
引用其他bundle
osgi_main:
执行測试
项目主要内容 :
common.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="common">
<!--
属性定义
-->
<dirname property="root.dir" file="${ant.file.common}" />
<property file="${root.dir}/common/build.properties" /> <path id="external.classpath" >
<fileset dir="${lib.dir}" includes="*.jar" />
</path>
<!-- dist -->
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpath="${bnd.jar}"/>
<target name="dist" depends="compile" >
<echo>dist...</echo>
<pathconvert pathsep="," dirsep="/" property="-classpath" refid="external.classpath"/>
<!-- 利用bnd工具生成 bundle-->
<bnd files="${root.dir}/common/bundle.properties" classpath="${build.classes.dir}"/>
<!-- 拷贝到client,main的lib中-->
<copy todir="${to_client_lib.dir}" >
<fileset dir="${build.dist.bundles.dir}" includes="*.jar" ></fileset>
</copy>
<copy todir="${to_main_lib.dir}" >
<fileset dir="${build.dist.bundles.dir}" includes="*.jar" ></fileset>
</copy>
</target>
<!-- clean-->
<target name="clean">
<echo>clean...</echo>
<delete dir="${build.dir}"/>
</target>
<!-- init-->
<target name="init" depends="clean">
<echo>init...</echo>
<mkdir dir="${build.dir}" />
<mkdir dir="${build.src.dir}" />
<mkdir dir="${build.classes.dir}" />
<mkdir dir="${build.dist.dir}" />
<mkdir dir="${build.dist.bundles.dir}" />
</target>
<!-- compile-->
<target name="compile" depends="init">
<echo>compile ...</echo>
<property name="compile.level" value="1.5" />
<!-- 编译-->
<javac srcdir="${src.dir}" destdir="${build.classes.dir}"
debug="on"
source="${compile.level}"
target="${compile.level}"
includeantruntime="false">
<classpath>
<path refid="external.classpath" />
<fileset dir="${build.dist.bundles.dir}" includes="*.jar" />
</classpath>
</javac>
<!-- 复制src-->
<copy todir="${build.src.dir}" includeEmptyDirs="false">
<fileset dir="${src.dir}" includes="**/*.*"/>
</copy>
</target> </project>
common\build.properties:
build.xml中属性配置
#-------------------------------------------------
#------------------------------------------------- src.dir=src
lib.dir=lib
build.dir=build
build.src.dir=${build.dir}/src
build.classes.dir=${build.dir}/classes
build.dist.dir=${build.dir}/dist
build.dist.bundles.dir=${build.dist.dir}/bundles
build.test.dir=${build.dir}/test
#copy bundle to osgi_consumer/lib
to_client_lib.dir=../osgi_consumer/lib
#copy bundle to osgi_main/lib
to_main_lib.dir=../osgi_main/lib
bnd.jar=${lib.dir}/bnd-0.0.384.jar Bundle-Name: ${ant.project.name}
Bundle-SymbolicName: ${module}
Bundle-Version: ${version}
Bundle-DocURL: http://code.google.com/p/osgi-in-action/
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 version: 1.0 -versionpolicy:"[$(version;\=\=;$(@)),$(version;+;$(@)))" Include-Resource:META-INF/LICENSE\=${root.dir}/LICENSE-ASL.txt,META-INF/NOTICE\=${root.dir}/NOTICE -output:\
${build.dist.bundles.dir}/${ant.project.name}-${version}.jar -removeheaders:\
Private-Package,Include-Resource
common\bundle.properties
bundle的描写叙述信息
module=com.demo.hello
custom=true Export-Package:${module};version\="2.0" Import-Package:org.osgi.framework;version\="[1.3,2.0)",${module};version\="[2.0,3.0)"
注意:
- 将lib下的包加入到build path中
- bundle的创建由bnd来运行
- osgi_provider会将创建的bundle拷贝到osgi_consumer,osgi_main
- osgi_consumer会将创建的bundle拷贝到osgi_main
源码下载
osgi实战学习之路:1. ant+bnd+felix搭建osgi之HelloWorld的更多相关文章
- osgi实战学习之路:2. maven+maven-bundle-plugin+karaf搭建osgi之HelloWorld
环境准备: jdk版本号 jdk:1.7 karaf: 版本号:apache-karaf-3.0.1 下载地址: http://pan.baidu.com/s/1qWM4Y1u http://kara ...
- osgi实战学习之路:4.Bundle
</pre></h1><h1 style="margin:0 0 0 40px; border:none; padding:0px"><p ...
- osgi实战学习之路:8. Service-3之ServiceTracker
通过ServiceTracker能够对查找的Service进行扩展 以下的demo引入装饰器模式对Service进行日志的扩展 demo: Provider student-manage/Activa ...
- osgi实战学习之路:5.生命周期及利用命令、装饰者模式实现基于socket交互Bundle命令demo
生命周期中关键3个类: BundleActivator 入口点,类似main方法 BundleContext Bundle上下文对象,在执行期间,为应用程序提供操作osgi框架的方法 Bundle 代 ...
- osgi实战学习之路:3. osgi分层概念及相互合作demo
源码下载 分层: modual: 主要作用于包级管理与共享代码 lifecycle: 主要作用于执行期间的模块管理与訪问osgi底层框架 service: 主要作用于多模块之间的相互通信 demo: ...
- osgi实战学习之路:6. Service-1
什么是Service? 它是注冊到osgi的一个java对象 Service注冊: 通过BundleContext::registerService(java.lang.String[] clazze ...
- C++学习之路——1.linux下环境搭建
学习之路,可说各有各的看法和方法.对于我来说,完全是兴趣一下子来了,脑壳发热吧.就想有个干净的环境,只想着与程序有关的东西练一练. 目前想学习C++,可是打开VC++6,再安了VS2010.VS201 ...
- [原创]java WEB学习笔记54:Struts2学习之路---概述,环境的搭建
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- springcloud学习之路: (一) 最简单的搭建springcloud的方法
参考资料: [JavaEE] 五分钟搭建SpringCloud环境, 进入微服务时代 感谢上篇博文大佬带领走进springcloud世界, 本博文主要目的为记录自己学习springcloud的点点滴滴 ...
随机推荐
- centos 服务器配置注意项
Mysql 出现Table‘xxx’is read only问题 Mysql数据库在由Mssql数据库导入数据文件后出现“ERROR 1036 (HY000): Table 'xxxx' is rea ...
- sicily 1003. hash
Description 请用HASH链式法来解决冲突,且规定链表在链表头插入新元素. 规定HASH函数为:h(x) = x % 11,即哈希数组下标为0-10. 给定两种操作: I 操作,插入一个新的 ...
- POJ 3122 Pie 二分答案
题意:给你n个派,每个派都是高为一的圆柱体,把它等分成f份,每份的最大体积是多少. 思路: 明显的二分答案题-- 注意π的取值- 3.14159265359 这样才能AC,,, //By Sirius ...
- jQuery新浪微博表情插件教程
1.引入css文件 <link rel="stylesheet" type="text/css" href="jquery.sinaEmotio ...
- 浅谈Sass与Less区别、优缺点
Sass是一种动态样式语言,Sass语法的缩排语法,比Css比多出很多功能,如变量,嵌套,运算,继承,颜色处理,函数等,易于阅读.Cass的安装需要安装Ruby环境,是服务器端处理的,Less是需要引 ...
- vue项目的一些最佳实践提炼和经验总结
项目组织结构 ajax数据请求的封装和api接口的模块化管理 第三方库按需加载 利用less的深度选择器优雅覆盖当前页面UI库组件的样式 webpack实时打包进度 vue组件中选项的顺序 路由的懒加 ...
- centeros 7配置mailx使用外部smtp服务器发送邮件
发送邮件的两种方式: 1.连接现成的smtp服务器去发送(此方法比较简单,直接利用现有的smtp服务器比如qq.新浪.网易等邮箱,只需要直接配置mail.rc文件即可实现) 2.自己搭建私有的smtp ...
- GenIcam标准(五)
2.8.10.Enumeration, EnumEntry Enumeration节点把一个名称(name)映射到一个索引值(index value),并实现Ienumeration接口.Enumer ...
- [Poi] Use Poi to Build an Index.js with Modern JavaScript Features
Poi can easily launch an index.js file simply by running the poi command. This will launch a dev-ser ...
- UVa 11849 - CD
题目:给你两个有序序列(每一个序列中元素不同),求两序列中都出现的元素个数. 分析:简单题. 合并排序合并过程. 设置两个指针.指向两序列当前元素.那个元素小指针向后移动.相同大则计数加一,同一时候后 ...