Karaf开发手册(1)

 由  snoopy7713 发布

Karaf开发手册

  • 品牌控制台
  • 扩展控制台
  • 定制发布
  • 安全框架
  • 使用features-maven-plugin
  • 故障排除,调试,分析,监测
  • 开发命令
  • 使用编程方式连接到控制台
  • 编写集成测试
  • 创建bundles
  • Shell 语法

品牌控制台

本章节指导你如何使用品牌控制台。通过品牌控制台,你可以定义自己的欢迎信息和弹出控制台。

  • 创建你的品牌 bundle
  • 首先 Kara查找输出org.apache.karaf.branding的包,该包包含branding.properties文件
  • 你需要创建一个仅有org/apache/karaf/branding/branding.properties文件的bundle。
  • 你的品牌bundle看上去就像下面的文件:

        <?xml version="1.0" encoding="UTF-8"?>
        <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>
            <groupId>your.group.id</groupId>
            <artifactId>your.branding.artifact.id</artifactId>
            <version>1.0-SNAPSHOT</version>
            <packaging>bundle</packaging>
            <name>Your Branding Bundle Name</name>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <version>2.2</version>
                        <extensions>true</extensions>
                        <configuration>
                            <instructions>
                             <Bundle-SymbolicName>manual</bundle-SymbolicName>
                                <Import-Package>*</Import-Package>
                                <Private-Package>!*</Private-Package>
                                <Export-Package>
                                    org.apache.karaf.branding
                                </Export-Package>
                                <Spring-Context>*;public-context:=false</Spring-Context>
                            </instructions>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </project>
    

现在加入一个文件 src/main/resources/org/apache/karaf/branding/branding.properties 如下:

{
}
welcome = \
\u001B[36m        __ __                  ____      \u001B[0m\r\n\
\u001B[36m       / //_/____ __________ _/ __/      \u001B[0m\r\n\
\u001B[36m      / ,<  / __ `/ ___/ __ `/ /_        \u001B[0m\r\n\
\u001B[36m     / /| |/ /_/ / /  / /_/ / __/        \u001B[0m\r\n\
\u001B[36m    /_/ |_|\\__,_/_/   \\__,_/_/         \u001B[0m\r\n\
\r\n\
\u001B[1m  Apache Karaf\u001B[0m (2.2.2)\r\n\
\r\n\
Hit '\u001B[1m<tab>\u001B[0m' for a list of available commands\r\n\
   and '\u001B[1m[cmd] --help\u001B[0m' for help on a specific command.\r\n\
Hit '\u001B[1m<ctrl-d>\u001B[0m' or '\u001B[1mosgi:shutdown\u001B[0m' to shutdown Karaf.\r\n

prompt = \u001B[1m${USER}@${APPLICATION}\u001B[0m>
{
}

正如你看到的,branding.properties 有两个属性

  • Welcome 是当你使用Karaf的时候的欢迎信息
  • Prompt 是用于控制台提示符的字符串,这个字符串支持变量参数;
    • $} 定义用户姓名的提示符,注意:显然是“karaf”的硬编码。然而你可以定义你自己的静态用户名
    • - ${{APPLICATION}}定义Karaf实例名

就像你看到的,两个字符串支持ASCII转义格式。如例 \u001B[1m 以粗体切换前景 \u001B[0m切换成正常格式 下面是一些提示例子:

# Define a user with fanzy colors
prompt = \u001B[36mmy-karaf-user\u001B[0m\u001B[1m@\u001B[0m\u001B[34m${APPLICATION}\u001B[0m>
# Static sober prompt
prompt = my-user@my-karaf>

使用branding bundle 注册Karaf

为使Karaf获得branding jar 请编辑$KARAF_HOME/etc/custom.properties 文件内容:

org.osgi.framework.system.packages.extra = \ 
org.apache.karaf.branding;

安装branding bundle

  • 生成branding bundle
  • mvn install
  • 将generated jar 文件拖放到 Karaf 的lib目录下
  • 运行Karaf,你将看到你的品牌Karaf 控制台

扩展控制台

本章节将指导你通过几步扩展控制台并创建一个新的shell。我们将使用Maven,Blueprint 和OSGi,因为你需要先了解这些技术。

你也可以在这里找到控制台的相关信息http://felix.apache.org/site/rfc-147-overview.html.

通过maven创建工程

我们首先使用maven创建一个项目。我们通过以下方式使用maven原型

命令行:

使用命令行创建我们的工程:

   mvn archetype:create \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DgroupId=org.apache.karaf.shell.samples \
  -DartifactId=shell-sample-commands \
  -Dversion=1.0-SNAPSHOT
    以上命令产生主pom.xml 和 一些附属包

交互shell

你可以使用交互模式创建工程框架 mvn archetype:generate 出现提示的时候使用如下值

Choose a number:  (1/2/3/4/5/6/7/.../32/33/34/35/36) 15: : 15
Define value for groupId: : org.apache.karaf.shell.samples
Define value for artifactId: : shell-sample-commands
Define value for version:  1.0-SNAPSHOT: : 
Define value for package: : org.apache.karaf.shell.samples

生成手册

另外,你可以只创建目录 shell-sample-commands 和文件pom.xml 内容如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>org.apache.karaf.shell.samples</groupId>
  <artifactId>shell-sample-commands<artifactId>
  <packaging>bundle</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>shell-sample-commmands</name>


  <dependencies>
    <dependency>
      <groupId>org.apache.karaf.shell</groupId>
      <artifactId>org.apache.karaf.shell.console</artifactId>
      <version>2.2.2</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.4</version>
        <configuration>
          <instructions>
            <Import-Package>
              org.apache.felix.service.command,
              org.apache.felix.gogo.commands,
              org.apache.karaf.shell.console,
              *
            </Import-Package>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

配置java5

我们使用注解定义的命令,因此,我们需要确定maven是用了JDK1.5编译jar 只需要在下面的依赖部分添加代码片段:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <target>1.5</target>
        <source>1.5</source>
      </configuration>
    </plugin>
  </plugins>
</build>

在IDE中加载工程

我们在IDE中使用maven产生需要的文件;

在工程内部,运行下面的命令: mvn eclipse:eclipsemvn idea:idea。 IDE工程文件被建立了,打开IDE加载工程。

创建一个基本的命令类

现在我们创建HelloShellCommand.java命令类 package org.apache.karaf.shell.samples;
import org.apache.felix.gogo.commands.Command; import org.apache.karaf.shell.console.OsgiCommandSupport;
@Command(scope = "test", name = "hello", description="Says hello") public class HelloShellCommand extends OsgiCommandSupport {
@Override protected Object doExecute() throws Exception { System.out.println("Executing Hello command"); return null; } }

创建相关的blueprint 配置文件

Blueprint 配置文件被用来创建命令和在OSGi注册表中注册,这是在Karaf 控制台产生可用命令的方法。这个blueprint配置文件必须装载在src/main/resources目录下,如果没有这个目录,就创建他 mkdir src/main/resources 然后重新生成IDE工程文件并重新装载他以便这个文件夹成为资源文件夹。

在目录中创建 OSGI-INF/blueprint/目录并把下面的文件放进去(这个文件取名没有什么影响);

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
        <command name="test/hello">
            <action class="org.apache.karaf.shell.samples.HelloShellCommand"/>
        </command>
    </command-bundle>
</blueprint>

编译jar

让我们生成jar。如果你手工移除测试类和用例类,那么运行一下命令: mvn install

最后的maven输出如下:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

测试Karaf

装载一个Karaf例子然后运行命令去安装新创建的bundle

karaf@root> osgi:install -s 
mvn:org.apache.karaf.shell.samples/shell-sample-commands/1.0-SNAPSHOT

运行以下命令:

karaf@root> test:hello
Executing Hello command

完整的命令

一个完整的命令允许你通过自动的完成一个命令参数。一个完整的命令是简单的把一个bean注入到一个命令中。当然,执行命令需要一个参数。

命令参数

我们为HelloCommand添加一个参数。

package org.apache.karaf.shell.samples;

import org.apache.felix.gogo.commands.Command;
import org.apache.felix.gogo.commands.Argument;
import org.apache.karaf.shell.console.OsgiCommandSupport;

@Command(scope = "test", name = "hello", description="Says hello")
public class HelloShellCommand extends OsgiCommandSupport {

    @Argument(index = 0, name = "arg", description = "The command argument", required = false, multiValued = false)
    String arg = null;

    @Override
    protected Object doExecute() throws Exception {
        System.out.println("Executing Hello command");
        return null;
    }
}

Blueprint 配置文件和原来的一样。

Completer bean

完全实现了Completer接口的bean

package org.apache.karaf.shell.samples;

import org.apache.karaf.shell.console.completer.StringsCompleter;
import org.apache.karaf.shell.console.Completer;

/**
 * <p>
 * A very simple completer.
 * </p>
 */
public class SimpleCompleter implements Completer {

 /**
  * @param buffer it's the beginning string typed by the user
  * @param cursor it's the position of the cursor
  * @param candidates the list of completions proposed to the user
  */
 public int complete(String buffer, int cursor, List candidates) {
      StringsCompleter delegate = new StringsCompleter();
      delegate.getStrings().add("one");
      delegate.getStrings().add("two");
      delegate.getStrings().add("three");
      return delegate.complete(buffer, cursor, candidates);
 }    
}

Blueprint 配置文件

利用Blueprint,你可以“注入”completer链接到你的命令。同样completer可以用于多个命令,一个命令页可以有多个completers;

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
        <command name="test/hello">
             <action class="org.apache.karaf.shell.samples.HelloShellCommand"/>
        </command>
        <completers>
           <ref component-id="simpleCompleter"/>
           <null/>
        </completers>
    </command-bundle>
<bean id="simpleCompleter" class="org.apache.karaf.shell.samples.SimpleCompleter"/>
</blueprint>

测试Karaf

启动一个Karaf实例,运行如下命令,安装新创建的bundle

karaf@root> osgi:install -s 
mvn:org.apache.karaf.shell.samples/shell-sample-commands/1.0-SNAPSHOT

运行下面的命令:

karaf@root> test:hello <tab>
one     two     three

定制发布

由于Karaf是一个OSGi容器,它大量用于应用程序和中间件的内核。

你根据自己的需要构件你自己的Karaf发布版。这样,定制发布版可以包括:

  1. 你想通过配置文件修改默认值(在etc文件夹)
  2. 在部署文件夹中放入预包装构件
  3. 预填充系统资源库(包括你自己的bundle和功能描述符)
  4. 重命名或在bin文件夹中放入特殊的脚本
  5. 加入标识
  6. 文档文件

Maven 装配

下面基本的Karaf定制 发布:

  1. 在一个给定的目录解压缩标准Karaf发布版
  2. 通过你实现的功能填充系统
  3. 将你的品牌或者其他系统bundle jar文件填入lib目录
  4. 在etc文件夹中覆盖configuration文件。

这些功能可通过你的脚本实现,想更容易和便捷,就使用Apache Maven和一套Maven插件 如下面的例子:Maven POM就像下面:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <groupId>my.company</groupId>
  <artifactId>mycustom-karaf</artifactId>
  <version>1.0</version>
  <packaging>pom</packaging>
  <name>My Unix Custom Karaf Distribution</name>

  <properties>
    <karaf.version>2.1.3</karaf.version>
  </properties>

  <dependencies>
    <dependency>
        <groupId>org.apache.karaf</groupId>
        <artifactId>apache-karaf</artifactId>
        <version>2.2.2</version>
        <type>tar.gz</type>
    </dependency>
    <dependency>
        <groupId>org.apache.karaf</groupId>
        <artifactId>apache-karaf</artifactId>
        <version>2.2.2</version>
        <type>xml</type>
        <classifier>features</classifier>
    </dependency>
 </dependencies>

  <build>
    <resources>
        <resource>
            <directory>/home/jbonofre/workspace/karaf/karaf-2.2.2/manual/src/main/filtered-resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*</include>
            </includes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
            <execution>
                <id>filter</id>
                <phase>generate-resources</phase>
                <goals>
                    <goal>resources</goal>
                </goals>
           </execution>
       </executions>
      </plugin>
     <plugin>
        <groupId>org.apache.karaf.tooling</groupId>
        <artifactId>features-maven-plugin</artifactId>
        <version>2.2.2</version>
        <executions>
            <execution>
               <id>add-features-to-repo</id>
               <phase>generate-resources</phase>
               <goals>
                    <goal>add-features-to-repo</goal>
               </goals>
               <configuration>
                 <descriptors>
                    <descriptor>mvn:org.apache.karaf/apache-karaf/2.2.2/xml/features</descriptor>
                    <descriptor>file:/home/jbonofre/workspace/karaf/karaf-2.2.2/manual/target/classes/my-features.xml</descriptor>
                 </descriptors>
                 <features>
                     <feature>my-feature</feature>
                 </features>
               </configuration>
           </execution>
        </executions>
    </plugin>
    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-dependency-plugin</artifactId>
       <executions>
         <execution>
            <id>copy</id>
            <phase>generate-resources</phase>
            <goals>
                 <goal>copy</goal>
            </goals>
            <configuration>
            <!-- Define here the artifacts which should be considered in the assembly -->
            <!-- For instance, the branding jar -->
                 <artifactItems>
                     <artifactItem>
                        <groupId>my.groupId</groupId>
                        <artifactId>my.branding.id</artifactId>
                        <version>1.0</version>
                        <outputDirectory>target/dependencies</outputDirectory>
                        <destFileName>mybranding.jar</destFileName>
                     </artifactItem>
                  </artifactItems>
            </configuration>
        </execution>
        <execution>
        <!-- Uncompress the standard Karaf distribution -->
            <id>unpack</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                      <groupId>org.apache.karaf</groupId>
                      <artifactId>apache-karaf</artifactId>
                      <type>tar.gz</type>
                      <outputDirectory>target/dependencies</outputDirectory>
                    </artifactItem>
               </artifactItems>
            </configuration>
        </execution>
    </executions>
  </plugin>
  <plugin>
     <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
        <execution>
            <id>bin</id>
            <phase>package</phase>
            <goals>
                 <goal>single</goal>
           </goals>
           <configuration>
              <descriptors>
                <descriptor>src/main/descriptors/bin.xml</descriptor>
              </descriptors>
              <appendAssemblyId>false</appendAssemblyId>
              <tarLongFileMode>gnu</tarLongFileMode>
           </configuration>
       </execution>
    </executions>
   </plugin>
  </plugins>
 </build>
</project>

Maven POM将下载Karaf 标准的发布版和准备Maven 装配插件而处理的资源

你的Maven工程结构可能如下:

  1. pom.xml:先前的POM 文件
  2. src/main/descriptors/bin.xml:装配maven插件的描述符(看下面)
  3. src/main/filtered-resources:包括了所有有关maven 属性被替换或过滤的文件,特别是他包含一些属性描述符和配置文件
  4. src/main/distribution:包含所有将被复制到你定制的发布版中的文件。

如例,src/main/filtered-resources 可以包含:

  1. my-features.xml 将替换maven属性
  2. etc/org.apache.karaf.features.cfg 文件包含你的my-features描述符:

        #
        # Comma separated list of features repositories to register by default
        #
        featuresRepositories=mvn:org.apache.karaf/apache-karaf/2.2.2/xml/features,mvn:my.groupId/my-features/2.2.2/xml/features
        
        #
        # Comma separated list of features to install at startup
        #
        featuresBoot=config,ssh,management,my-feature
    

src/main/distribution 包含所有的你定制的Karaf 配置文件和脚本,如:
1. etc/org.ops4j.pax.logging.cfg

    # Root logger
    log4j.rootLogger=INFO, out, osgi:VmLogAppender
    log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
    
    # CONSOLE appender not used by default
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
    
    # File appender
    log4j.appender.out=org.apache.log4j.RollingFileAppender
    log4j.appender.out.layout=org.apache.log4j.PatternLayout
    log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32C %4L | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
    log4j.appender.out.file=${karaf.home}/log/my-customer-distribution.log
    log4j.appender.out.append=true
    log4j.appender.out.maxFileSize=1MB
    log4j.appender.out.maxBackupIndex=10
    
    # Sift appender
    log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender
    log4j.appender.sift.key=bundle.name
    log4j.appender.sift.default=my-custom
    log4j.appender.sift.appender=org.apache.log4j.FileAppender
    log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout
    log4j.appender.sift.appender.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
    log4j.appender.sift.appender.file=${karaf.data}/log/$\\{bundle.name\\}.log
    log4j.appender.sift.appender.append=true
       etc/system.properties
    #
    # The properties defined in this file will be made available through system
    # properties at the very beginning of the FAS boot process.
    #
    
    # Log level when the pax-logging service is not available
    # This level will only be used while the pax-logging service bundle
    # is not fully available.
    # To change log levels, please refer to the org.ops4j.pax.logging.cfg file
    # instead.
    org.ops4j.pax.logging.DefaultServiceLog.level=ERROR
    
    #
    # Name of this custom instance.
    #
    karaf.name=my-custom
    
    #
    # Default repository where bundles will be loaded from before using
    # other maven repositories. For the full maven configuration, see the
    # org.ops4j.pax.url.mvn.cfg file.
    #
    karaf.default.repository=system
    
    #
    # Location of a shell script that will be run when starting a shell
    # session. This script can be used to create aliases and define
    # additional commands.
    #
    karaf.shell.init.script=${karaf.home}/etc/shell.init.script
    
    #
    # Set this empty property to avoid errors when validating xml documents.
    #
    xml.catalog.files=
    
    #
    # Suppress the bell in the console when hitting backspace to many times
    # for example
    #
    jline.nobell=true
    
    #
    # Default port for the OSGi HTTP Service
    #
    org.osgi.service.http.port=8181
    
    #
    # Allow usage of ${custom.home} as an alias for ${karaf.home}
    #
    custom.home=${karaf.home}
  1. etc/users.properties admin=admin,admin
  2. 你可以添加一个etc/custom.properties,这是一个占位符,可以用它做任何的替换,如:

        karaf.systemBundlesStartLevel=50
        obr.repository.url=http://svn.apache.org/repos/asf/servicemix/smx4/obr-repo/repository.xml
        org.osgi.framework.system.packages.extra = \
          org.apache.karaf.branding; \
          com.sun.org.apache.xalan.internal.xsltc.trax; \
          com.sun.org.apache.xerces.internal.dom; \
          com.sun.org.apache.xerces.internal.jaxp; \
          com.sun.org.apache.xerces.internal.xni; \
          com.sun.jndi.ldap
    

    现在,我们可以使用Maven装配插件“装配”我们定制的发布版了。Maven装配插件在src/main/descriptors/bin.xml中使用装配描述符。

    <assembly>
        <id>bin</id>
        <formats>
            <format>tar.gz</format>
        </formats>
        <fileSets>
            <!-- Expanded Karaf Standard Distribution -->
            <fileSet>
                <directory>target/dependencies/apache-karaf-2.2.2</directory>
                <outputDirectory>/</outputDirectory>
                <excludes>
                    <exclude>**/demos/**</exclude>
                    <exclude>bin/**</exclude>
                    <exclude>etc/system.properties</exclude>
                    <exclude>etc/users.properties</exclude>
                    <exclude>etc/org.apache.karaf.features.cfg</exclude>
                    <exclude>etc/org.ops4j.pax.logging.cfg</exclude>
                    <exclude>LICENSE</exclude>
                    <exclude>NOTICE</exclude>
                    <exclude>README</exclude>
                    <exclude>RELEASE-NOTES</exclude>
                    <exclude>karaf-manual*.html</exclude>
                    <exclude>karaf-manual*.pdf</exclude>
                </excludes>
            </fileSet>
            <!-- Copy over bin/* separately to get the correct file mode -->
            <fileSet>
                <directory>target/dependencies/apache-karaf-2.2.2</directory>
                <outputDirectory>/</outputDirectory>
                <includes>
                    <include>bin/admin</include>
                    <include>bin/karaf</include>
                    <include>bin/start</include>
                    <include>bin/stop</include>
                </includes>
                <fileMode>0755</fileMode>
            </fileSet>
            <!-- Copy over jar files -->
            <fileSet>
                <directory>target/dependencies</directory>
                <includes>
                    <include>my-custom.jar</include>
                </includes>
                <outputDirectory>/lib/</outputDirectory>
            </fileSet>
            <fileSet>
                <directory>src/main/distribution</directory>
                <outputDirectory>/</outputDirectory>
                <fileMode>0644</fileMode>
            </fileSet>
            <fileSet>
                <directory>target/classes/etc</directory>
                <outputDirectory>/etc/</outputDirectory>
                <lineEnding>unix</lineEnding>
                <fileMode>0644</fileMode>
            </fileSet>
            <fileSet>
                <directory>target/features-repo</directory>
                <outputDirectory>/system</outputDirectory>
            </fileSet>
        </fileSets>
        <files>
            <file>
                <source>/home/jbonofre/workspace/karaf/karaf-2.2.2/manual/target/dependencies/apache-karaf-2.2.2/bin/karaf</source>
                <outputDirectory>/bin/</outputDirectory>
                <destName>my-custom</destName>
                <fileMode>0755</fileMode>
                <lineEnding>unix</lineEnding>
            </file>
            <file>
                <source>/home/jbonofre/workspace/karaf/karaf-2.2.2/manual/target/classes/features.xml</source>
                <outputDirectory>/system/my.groupid/my-features/2.2.2</outputDirectory>
                <destName>my-features-2.2.2-features.xml</destName>
                <fileMode>0644</fileMode>
                <lineEnding>unix</lineEnding>
            </file>
        </files>
    </assembly>
    

    只需要执行下面命令就可以生成你的定制karaf发布版mvn install 你会发现你的Karaf 定制版tar.gz在目标目录中。


snoopy7713 2013-11-18 11:19

这是别人翻译的水平有限,等我亲自写一篇关于OSGi的作品。保证准确性高。

顶(6) 踩(0) 回复

老陈 2013-11-18 11:17

这个教程写的实操性很差,根本跑不通。

顶(3) 踩(0) 回复

zjf_123 2013-08-29 14:48

是不是太混乱了。。有很多地方都错了。。这难道是坑?比如说“扩展控制台”中的。。

顶(3) 踩(0) 回复
查看评论