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的点点滴滴 ...
随机推荐
- hdoj--5569--matrix(动态规划)
matrix Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Sub ...
- Case study: word play
For the exercises in this chapter we need a list of English words. There are lots of word lists avai ...
- realm怎样支持hashmap
realm不支持hashmap这种形式stackoverflow给出了解决方案http://stackoverflow.com/ques... class MyData extends RealmOb ...
- MySql语句中select可以嵌套么,字段的重命名可以用中文么
今天文档中看到的查询语句,SELECT后面又跟了一个SELECT嵌套,而且把字段重命名为中文,请问可以这样做么 MySql语句中select可以嵌套么,字段的重命名可以用中文么 >> my ...
- bootstrap如何自定义5列
废话少说,先上代码: <!DOCTYPE html><html> <head> <meta charset="utf-8"> < ...
- PostgreSQL Replication之第二章 理解PostgreSQL的事务日志(2)
2.2 XLOG和复制 在本章中,您已经了解到PostgreSQL的事务日志已经对数据库做了所有的更改.事务日志本身被打包为易用的16MB段. 使用这种更改集来复制数据的想法是不牵强的.事实上,这是在 ...
- mysql优化篇之表分区
当表的数据量达到一定数量时(如单个.myd文件都达到10G,myd 是mysql的数据文件),这时候读取起来必然效率很低. 1.从业务角度可以解决(分表) ...
- Perl模块利用CPAN在线安装自动化
需要解决2个问题: 1. 如何与CPAN交互:利用perl –MCPAN –e ‘install 模块’ 2. 如何安装指定的版本:作者/模块-版本.tar.gz How to install a ...
- P3168 [CQOI2015]任务查询系统(主席树)
题目描述 最近实验室正在为其管理的超级计算机编制一套任务管理系统,而你被安排完成其中的查询部分.超级计算机中的任务用三元组(Si,Ei,Pi)描述,(Si,Ei,Pi)表示任务从第Si秒开始,在第Ei ...
- 08-for循环