OSGI-karaf安装及使用

____________________________________________________________

karaf是OSGI的容器实例,类似tomcat是servlet的容器实例一样

官网:http://karaf.apache.org

1,下载源文件

在http://karaf.apache.org/index/community/download.html

下载apache-karaf-2.3.0.zip, apache-karaf-2.3.0-src.zip

2,解压

解压apache-karaf-2.3.0.zip,比如到E:\workspace\apache-karaf-2.3.0

解压apache-karaf-2.3.0-src.zip并把src目录移动到E:\workspace\apache-karaf-2.3.0

目录结构为:

/bin: startup scripts

/data: working directory

/demos: 

/deploy: hot deploy directory

/etc: configuration files

/lib: contains the bootstrap libraries

/src: unzip from apache-karaf-2.3.0-src.zip

/system: OSGi bundles repository, laid out as a Maven 2 repository

/instances: directory containing child instances //mvn 成功后,会创建此目录

/cache: OSGi framework bundle cache

/generated-bundles: temporary folder used by the deployer

/log: log files

/deploy: hot deploy directory

/instances: directory containing child instances

/lib: contains the bootstrap libraries

/lib/ext: directory for JRE extensions

/lib/endorsed: directory for endorsed libraries

/system: OSGi bundles repository, laid out as a Maven 2 repository

3,执行mvn命令

E:\workspace\apache-karaf-2.3.0\src>mvn clean install -DskipTests=true

出现karaf@root时就证明成功了,如果卡死,可以任务管理器关掉2个java.exe

4,启动karaf

然后进入E:\workspace\apache-karaf-2.3.0\bin>karaf//会启动2个java.exe

验证:下面是成功的输出

karaf@root> admin:list

 SSH Port   RMI Ports         State       Pid  Name

[    8101] [1099/44444     ] [Started ] [ 2704] root

5, Managing child instances

admin:create alpha//创建子实例

会建立apache-karaf-2.3.0\instances\alpha目录,并有子目录:bin,data,deploy,etc,system

admin:list//LISTING ALL container instances

//连接child instance, 需要再打开一个cmd,启动子实例

admin:connect [-u username] [-p password] instance //CONNECTING TO A CHILD INSTANCE

logout//退出连接

admin:stop instance

admin:destroy instance

6, 关闭Karaf : osgi:shutdown.

更多命令可以用帮助命令,--help,或者cmd提示。

猜你喜欢

转载自luckywnj.iteye.com/blog/1719974
今日推荐