Karaf容器简介答题.pptx
文本预览下载声明
Karaf容器;Apache Karaf是什么?;Karaf容器的特点;Karaf容器的特点;bundle:osgi中的模块
feature:一组bundle,其具备特定的功能,比如hibernate就算是一个feature,其由多个bundle组成
feature-repo:feature资源库,由一组feature组合而成,apache已经提供了一部分,可以进入etc配置文件中查看;Bundle 运行
Bundle 的运行主要依靠于 OSGi 框架为其创建的类加载器(Class Loader),加载器负责查找和加载 Bundle 自身或所依赖的类资源。 ClassLoader 之间的依赖关系构成了一个有向图,如下图所示:;In OSGi, a bundle can depend to other bundles. So, it means that to deploy an OSGi application, most of the time, you have to firstly deploy a lot of other bundles required by the application.
So, you have to find these bundles first, install the bundles. Again, thesedependency bundles may require other bundles to satisfy their own dependencies.;Feature ;Maven是一个项目管理和综合工具。Maven提供了开发人员构建一个完整的生命周期框架。开发团队可以自动完成项目的基础工具建设,Maven使用标准的目录结构和默认构建生命周期。
Maven的另外一个特色是利用中央构建资源库去访问您项目中需要的.jars(像Perls?CPAN)。您只用列出需要的.jars及相应版本,Maven会自动下载。当第一次运行Maven,或者运行一个新的goal时,可以在控制台上看到中央构建资源库下载.jars的详细过程。;;Karaf Web控制台的安装:
feature:install webconsole
访问地址:http://localhost:8181/system/console
缺省用户名/密码:karaf/karaf;在karaf上部署一个示例应用程序
这里给出安装一个示例应用(Apache Camel application),更详细的参考Karaf user’s guide。
在karaf控制台中运行如下命令:
karaf@root() feature:repo-add camel 2.10.0
Adding feature url mvn:org.apache.camel.karaf/apache-camel/2.10.0/xml/features
karaf@root() feature:install camel-spring
karaf@root() bundle:install -s mvn:org.apache.camel/camel-example-osgi/2.10.1
安装Camel 2.10.0,然后使用Camel启动一个定时器,每个2秒钟在控制台输出一条消息。输出信息如下:
SpringDSL set body: Fri Jan 07 11:59:51 CET 2011
SpringDSL set body: Fri Jan 07 11:59:53 CET 2011
SpringDSL set body: Fri Jan 07 11:59:55 CET 2011
先前的命令会下载 Camel features descriptor 和 安装示例feature:
停止和卸载示例应用程序:
karaf@root() bundle:stop org.apache.camel.camel-example-osgi
停止 Karaf
控制台中输入(Ctrl+D):
^D
或者运行如下的命令也可以停止Karaf:
system:shutdown
如何清除Karaf状态?
正常情况下,Karaf会记住所安装的和启动的features和bundles。要想重置Karaf为初始状态,可以删除data命令(删除之前先关闭Karaf)。也可以在启动karaf时使用clean选项:
bin/karaf clean;新建一个maven项目,groupId:com.lala,artifactId:demo-features,version:1.0.0
1:resources目录下,新建http.cfg、jdbc.cfg两个配置文件,内容随便
2:
显示全部