Apache Karaf自定义feature
来源:互联网 发布:java base64 编码 编辑:程序博客网 时间:2024/06/13 02:40
系统环境
JDK :1.8.0_66 x64
Karaf:apache-karaf-4.0.2
maven:Apache Maven 3.3.3
karaf中的feature通常是几个bundle的集合,安装这个feature的时候,相应的bundle也都会被安装上去,用来管理bundle很方便
下面来介绍如何自己开发一个feature
这里来制作一个名字为:apache-commons-utils的feature,里面包含如下bundle
<bundle>mvn:commons-io/commons-io/2.4</bundle><bundle>mvn:commons-lang/commons-lang/2.6</bundle><bundle>mvn:commons-discovery/commons-discovery/0.5</bundle><bundle>mvn:commons-math/commons-math/1.2</bundle><bundle>mvn:commons-net/commons-net/3.3</bundle>再加上2个配置文件 http.cfg、jdbc.cfg (配置文件只是为了演示如何在安装feature的时候,也同时把配置文件安装上)
新建一个maven项目,groupId:com.lala,artifactId:demo-features,version:1.0.0
1:resources目录下,新建http.cfg、jdbc.cfg两个配置文件,内容随便
2:resources目录下,新建features.xml文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?><features name="karaf-cellar-4.0.0" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0"><feature name="apache-commons-utils" description="apache commons utils" version="1.0.0"> <!-- 这个配置文件将会安装到etc/目录下 --> <configfile finalname="/etc/demo-features.jdbc.cfg">mvn:com.lala/demo-features/1.0.0/cfg/jdbc</configfile> <!-- 这个配置文件将会安装到deploy/目录下 --> <configfile finalname="/deploy/demo-features.http.cfg" override="true">mvn:com.lala/demo-features/1.0.0/cfg/http</configfile> <bundle>mvn:commons-io/commons-io/2.4</bundle> <bundle>mvn:commons-lang/commons-lang/2.6</bundle> <bundle>mvn:commons-discovery/commons-discovery/0.5</bundle> <bundle>mvn:commons-math/commons-math/1.2</bundle> <bundle>mvn:commons-net/commons-net/3.3</bundle> </feature></features>
3:在pom.xml加上如下插件配置
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId><configuration><useDefaultDelimiters>false</useDefaultDelimiters><delimiters><delimiter>${*}</delimiter></delimiters></configuration><executions><execution><id>filter</id><phase>generate-resources</phase><goals><goal>resources</goal></goals></execution></executions></plugin><plugin><groupId>org.codehaus.mojo</groupId><artifactId>build-helper-maven-plugin</artifactId><version>1.9.1</version><executions><execution><id>attach-artifact</id><phase>package</phase><goals><goal>attach-artifact</goal></goals><configuration><artifacts><artifact><file>target/classes/features.xml</file><type>xml</type><classifier>features</classifier></artifact><artifact><file>target/classes/jdbc.cfg</file><type>cfg</type><classifier>jdbc</classifier></artifact><artifact><file>target/classes/http.cfg</file><type>cfg</type><classifier>http</classifier></artifact></artifacts></configuration></execution></executions></plugin>
注意:这里的artifact、file、type、classifier的配置方法为:
type为file的扩展名,classifier为file的文件名
配置好之后,执行mvn clean install ,mvn clean deploy
4:修改${karaf.home}/etc/org.apache.karaf.features.cfg文件
在featuresRepositories配置项后面加上:mvn:com.lala/demo-features/1.0.0/xml/features
5:修改${karaf.home}/etc/org.ops4j.pax.url.mvn.cfg文件,
在org.ops4j.pax.url.mvn.repositories配置项后面加上:http://192.168.1.100:8080/nexus/content/groups/public (maven私服的地址)
org.ops4j.pax.url.mvn.settings
org.ops4j.pax.url.mvn.localRepository
这2个配置项,如果你maven本地的仓库地址变了,就需要修改,否则,就不需要修改
5:修改好了之后,重启karaf,执行安装,即可看到效果
karaf@root()> feature:install apache-commons-utilskaraf@root()> listSTART LEVEL 100 , List Threshold: 50ID | State | Lvl | Version | Name--------------------------------------------------------52 | Active | 80 | 0.5 | Commons Discovery53 | Active | 80 | 2.4.0 | Commons IO54 | Active | 80 | 2.6 | Commons Lang55 | Active | 80 | 1.2 | Apache Commons Math Bundle56 | Active | 80 | 3.3.0 | Commons Netkaraf@root()>
- Apache Karaf自定义feature
- Apache Karaf自定义console命令
- Apache Karaf
- Apache Karaf用户指导
- Apache karaf端口配置
- Apache Karaf用户指导
- Apache Karaf离线打包
- apache karaf quick start
- karaf配置自定义featrues
- karaf-maven-plugin制作本地feature仓库
- Apache Karaf Overview 特性 了解
- Apache Karaf配置远程调试
- Apache Karaf开启ssl Https
- Apache Karaf配置远程调试
- 最近使用karaf+Jetty使用feature碰到了很多问题
- Apache Karaf安装带classifier的bundle
- karaf加入自定义log4j的配置
- Apache Kafka-0.9 feature
- ORA-00257 归档日志错误的解决方案
- iOS 环信集成(六) 退出登陆
- HDU 1022 Train Problem I
- 在android style文件中使用自定义属性
- netty4.0中EventExecutorGroup池中选择线程的方式
- Apache Karaf自定义feature
- Jlink V8固件恢复
- 一致性哈希算法是分布式系统中常用的算法
- WEB编辑器
- UIWebView 内容自适应屏幕
- 在淘宝上买一元夺宝代码受骗记
- ICCV 2015 papers
- 6 nRF51 DFU 初始化包
- VLFeat和Piotr’s Image & Video Matlab Toolbox