From commits-return-34535-archive-asf-public=cust-asf.ponee.io@karaf.apache.org Mon Sep 3 08:10:53 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 49BA7180647 for ; Mon, 3 Sep 2018 08:10:52 +0200 (CEST) Received: (qmail 56745 invoked by uid 500); 3 Sep 2018 06:10:51 -0000 Mailing-List: contact commits-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@karaf.apache.org Delivered-To: mailing list commits@karaf.apache.org Received: (qmail 56730 invoked by uid 99); 3 Sep 2018 06:10:51 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Sep 2018 06:10:51 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 82A793A0E8A for ; Mon, 3 Sep 2018 06:10:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1839907 [2/4] - in /karaf/site/production/manual/latest: ./ commands/ Date: Mon, 03 Sep 2018 06:10:49 -0000 To: commits@karaf.apache.org From: jbonofre@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20180903061050.82A793A0E8A@svn01-us-west.apache.org> Modified: karaf/site/production/manual/latest/deployers.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/deployers.html?rev=1839907&r1=1839906&r2=1839907&view=diff ============================================================================== --- karaf/site/production/manual/latest/deployers.html (original) +++ karaf/site/production/manual/latest/deployers.html Mon Sep 3 06:10:48 2018 @@ -817,7 +817,7 @@ For instance:

Modified: karaf/site/production/manual/latest/developer-commands.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/developer-commands.html?rev=1839907&r1=1839906&r2=1839907&view=diff ============================================================================== --- karaf/site/production/manual/latest/developer-commands.html (original) +++ karaf/site/production/manual/latest/developer-commands.html Mon Sep 3 06:10:48 2018 @@ -809,7 +809,7 @@ system folder.

Modified: karaf/site/production/manual/latest/directory-structure.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/directory-structure.html?rev=1839907&r1=1839906&r2=1839907&view=diff ============================================================================== --- karaf/site/production/manual/latest/directory-structure.html (original) +++ karaf/site/production/manual/latest/directory-structure.html Mon Sep 3 06:10:48 2018 @@ -521,7 +521,7 @@ table.CodeRay td.code>pre{padding:0}

/bin: control scripts to start, stop, login, …​

  • -

    /demos: contains some simple Karaf samples

    +

    /examples: contains several examples to start with Apache Karaf

  • /etc: configuration files

    @@ -553,7 +553,7 @@ table.CodeRay td.code>pre{padding:0}
    • -

      /lib/boot: contains the systeù libraries used at Karaf bootstrap

      +

      /lib/boot: contains the system libraries used at Karaf bootstrap

    • /lib/endorsed: directory for endorsed libraries

      @@ -589,7 +589,7 @@ using the clean option to the Karaf star
    Added: karaf/site/production/manual/latest/docker.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/docker.html?rev=1839907&view=auto ============================================================================== --- karaf/site/production/manual/latest/docker.html (added) +++ karaf/site/production/manual/latest/docker.html Mon Sep 3 06:10:48 2018 @@ -0,0 +1,1029 @@ + + + + + + + +Docker + + + + + + +
    +
    +

    Docker

    +
    +

    Apache Karaf provides Docker resources allowing you to easily create your own image and container.

    +
    +
    +

    Official Karaf docker image are also available on Docker Hub.

    +
    +
    +

    But, Apache Karaf also provides a docker feature allows you to:

    +
    +
    +
      +
    • +

      manipulate Docker containers directly from Apache Karaf

      +
    • +
    • +

      create a Docker container based on the current running Apache Karaf instance (named provisioning)

      +
    • +
    +
    +
    +

    Docker images

    +
    +

    You can find the docker resource at http://github.com/apache/karaf/assemblies/docker.

    +
    +
    +

    As prerequisites, you have:

    +
    +
    + +
    +
    +
    Official images
    +
    +

    Apache Karaf official docker images are available on Docker HUB: https://hub.docker.com/_/karaf/

    +
    +
    +

    You can directly pull the official image:

    +
    +
    +
    +
    docker pull karaf
    +
    +
    +
    +
    +
    Build your own
    +
    +

    You can create your own docker image. The images are based on the official Java Alpine (OpenJDK 8) image. If you +want to build the Karaf image run:

    +
    +
    +
    +
    sh build.sh
    +
    +
    +
    +

    or

    +
    +
    +
    +
    docker build -t karaf .
    +
    +
    +
    +

    If you want to build the container for a specific version of Karaf you can configure it with the KARAF_VERSION arg:

    +
    +
    +
    +
    docker build --build-arg KARAF_VERSION=4.2.0 -t "karaf:4.2.0" karaf
    +
    +
    +
    +
    +
    Run
    +
    +
      +
    • +

      Run Karaf in interactive mode

      +
    • +
    +
    +
    +
    +
    docker-compose run karaf
    +
    +
    +
    +
      +
    • +

      Run Karaf as a daemon (without interaction)

      +
    • +
    +
    +
    +
    +
    docker-compose up
    +
    +
    +
    +
      +
    • +

      Kill Karaf

      +
    • +
    +
    +
    +
    +
    docker-compose kill
    +
    +
    +
    +
    Ports
    +
    +
      +
    • +

      The Karaf SSH server is on 8101

      +
    • +
    • +

      The Karaf WebContainer is on 8888

      +
    • +
    • +

      The Karaf JMX MBean server is on 1099 (default, not exposed to host) and 44444 (default, not exposed to host)

      +
    • +
    +
    +
    +

    Edit the docker-compose.yml file to edit port settings.

    +
    +
    +
    +
    +
    +

    Docker feature

    +
    +

    Docker is an optional feature from the Karaf Enterprise features repository.

    +
    +
    +

    It means that you have to install the docker feature first:

    +
    +
    +
    +
    karaf@root()> feature:install docker
    +
    +
    +
    +

    The Karaf Docker feature uses the Docker HTTP layer to communicate with the Docker backend. It could be on the same local +machine where Apache Karaf instance is running or a remote Docker machine.

    +
    +
    +

    The location of the Docker backend (URL) can be specified as an option to the docker:* commands. By default, Karaf Docker +feature uses http://localhost:2375. Please, take a look on the Docker documentation how to enable remote API using HTTP +for Docker daemon. As short notice, you just have to enable tcp transport connector enabled for the docker daemon. +You have to do it using the -H option on dockerd:

    +
    +
    +
    +
    /usr/bin/dockerd -H fd:// -H tcp://localhost:2375
    +
    +
    +
    +

    Apache Karaf Docker feature exposes DockerService OSGi service that you can use programmatically (the dockerClient:* commands +and the DockerMBean use the DockerService service).

    +
    +
    +
    +

    System-wide information

    +
    +

    The docker:info command provides some details about the docker backend:

    +
    +
    +
    +
    karaf@root()> docker:info
    +Containers: 0
    +Debug: false
    +Driver: overlay2
    +ExecutionDriver: null
    +IPv4Forwarding: true
    +Images: 1
    +IndexServerAddress: https://index.docker.io/v1/
    +InitPath: null
    +InitSha1: null
    +KernelVersion: 4.15.0-29-generic
    +MemoryLimit: true
    +NEventsListener: false
    +NFd: 20
    +NGoroutines: 34
    +SwapLimit: false
    +
    +
    +
    +
    +

    Show the Docker version information

    +
    +

    The docker:version command provides details about the docker version:

    +
    +
    +
    +
    karaf@root()> docker:version
    +Version: 17.12.1-ce
    +Os: linux
    +Kernel version: 4.15.0-29-generic
    +Go version: go1.10.1
    +Git commit: 7390fc6
    +Arch: amd64
    +API version: 1.35
    +Build time: 2018-02-28T17:46:05.000000000+00:00
    +Experimental: null
    +
    +
    +
    +
    +

    Search image

    +
    +

    The docker:search command (or search() operation on the DockerMBean) searches for a image on Docker HUB:

    +
    +
    +
    +
    karaf@root()> docker:search java
    +Name                                       │ Description                                                                                          │ Automated │ Official │ Star Count
    +───────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────┼───────────┼───────�
     �”€â”€â”€â”¼â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
    +java                                       │ Java is a concurrent, class-based, and object-oriented programming language.                         │ false     │ true     │ 1774
    +anapsix/alpine-java                        │ Oracle Java 8 (and 7) with GLIBC 2.23 over AlpineLinux                                               │ true      │ false    │ 332
    +node                                       │ Node.js is a JavaScript-based platform for server-side and networking applications.                  │ false     │ true     │ 5893
    +tomcat                                     │ Apache Tomcat is an open source implementation of the Java Servlet and JavaServer Pages technologies │ false     │ true     │ 1950
    +openjdk                                    │ OpenJDK is an open-source implementation of the Java Platform, Standard Edition                      │ false     │ true     │ 1097
    +frekele/java                               │ docker run --rm --name java frekele/java                                                             │ true      │ false    │ 10
    +ghost                                      │ Ghost is a free and open source blogging platform written in JavaScript                              │ false     │ true     │ 799
    +appuio/s2i-maven-java                      │ S2I Builder with Maven and Java                                                                      │ true      │ false    │ 1
    +zabbix/zabbix-java-gateway                 │ Zabbix Java Gateway                                                                                  │ true      │ false    │ 13
    +jetty                                      │ Jetty provides a Web server and javax.servlet container.                                             │ false     │ true     │ 260
    +fabric8/s2i-java                           │ S2I Builder Image for plain Java applications                                                        │ false     │ false    │ 5
    +appuio/s2i-gradle-java                     │ S2I Builder with Gradle and Java                                                                     │ true      │ false    │ 1
    +cloudbees/jnlp-slave-with-java-build-tools │ Extends cloudbees/java-build-tools docker image to make it a JNLP slave                              │ true      │ false    │ 18
    +blacklabelops/java                         │ Java Base Images.                                                                                    │ true      │ false    │ 8
    +groovy                                     │ Apache Groovy is a multi-faceted language for the Java platform.                                     │ false     │ true     │ 47
    +lwieske/java-8                             │ Oracle Java 8 Container - Full + Slim - Based off Alpine + CentOS (8u00 - 8u172)                     │ true      │ false    │ 39
    +davidcaste/alpine-java-unlimited-jce       │ Oracle Java 8 (and 7) with GLIBC 2.21 over AlpineLinux with unlimited JCE patch applied              │ true      │ false    │ 11
    +cfje/java-test-applications                │ Java Test Applications CI Image                                                                      │ false     │ false    │ 0
    +thingswise/java-docker                     │ Java + dcd                                                                                           │ true      │ false    │ 0
    +rightctrl/java                             │ Oracle Java                                                                                          │ true      │ false    │ 2
    +cfje/java-resource                         │ Java Concourse Resource                                                                              │ false     │ false    │ 0
    +cfje/java-buildpack                        │ Java Buildpack CI Image                                                                              │ false     │ false    │ 0
    +tomee                                      │ Apache TomEE is an all-Apache Java EE certified stack where Apache Tomcat is top dog.                │ false     │ true     │ 53
    +couchdb                                    │ CouchDB is a database that uses JSON for documents, an HTTP API, & JavaScript/declarative indexing.  │ false     │ true     │ 218
    +dwolla/java                                │ Dwolla’s custom Java image                                                                           │ true      │ false    │ 1
    +
    +
    +
    +
    +

    Pull image

    +
    +

    The docker:pull command (or pull() operation on the DockerMBean) pull a image from Docker HUB:

    +
    +
    +
    +
    karaf@root()> docker:pull -v java:8-jre-alpine
    +{"status":"Pulling from library/java","id":"latest"}
    +{"status":"Pulling fs layer","progressDetail":{},"id":"5040bd298390"}
    +{"status":"Pulling fs layer","progressDetail":{},"id":"fce5728aad85"}
    +{"status":"Pulling fs layer","progressDetail":{},"id":"76610ec20bf5"}
    +{"status":"Pulling fs layer","progressDetail":{},"id":"60170fec2151"}
    +{"status":"Pulling fs layer","progressDetail":{},"id":"e98f73de8f0d"}
    +{"status":"Pulling fs layer","progressDetail":{},"id":"11f7af24ed9c"}
    +{"status":"Pulling fs layer","progressDetail":{},"id":"49e2d6393f32"}
    +{"status":"Pulling fs layer","progressDetail":{},"id":"bb9cdec9c7f3"}
    +{"status":"Waiting","progressDetail":{},"id":"11f7af24ed9c"}
    +{"status":"Waiting","progressDetail":{},"id":"49e2d6393f32"}
    +{"status":"Waiting","progressDetail":{},"id":"bb9cdec9c7f3"}
    +{"status":"Waiting","progressDetail":{},"id":"60170fec2151"}
    +{"status":"Waiting","progressDetail":{},"id":"e98f73de8f0d"}
    +
    +
    +
    +
    +

    Listing images

    +
    +

    The docker:images command (or images() operation on the DockerMBean) lists the available images on docker:

    +
    +
    +
    +
    karaf@root()> docker:images
    +Id                                                                      │ RepoTags            │ Created    │ Labels │ Size      │ Virtual Size
    +────────────────────────────────────────────────────────────────────────┼─────────────────────┼────────────┼────────┼───────────┼─────────────
    +sha256:fdc893b19a147681ee764b2edab6c494d60fe99d83b14b8794bbcbc040ec7aa7 │ [java:8-jre-alpine] │ 1488578492 │ {}     │ 107854045 │ 107854045
    +sha256:d23bdf5b1b1b1afce5f1d0fd33e7ed8afbc084b594b9ccf742a5b27080d8a4a8 │ [java:latest]       │ 1484614374 │ {}     │ 643195347 │ 643195347
    +
    +
    +
    +
    +

    Remove image

    +
    +

    The docker:rmi command (or rmi() operation on the DockerMBean) removes an image from docker:

    +
    +
    +
    +
    karaf@root()> docker:rmi --force sha256:d23bdf5b1b1b1afce5f1d0fd33e7ed8afbc084b594b9ccf742a5b27080d8a4a8
    +
    +
    +
    +
    +

    Image history

    +
    +

    The docker:history command displays the complete history for a given image:

    +
    +
    +
    +
    karaf@root()> docker:history sha256:fdc893b19a147681ee764b2edab6c494d60fe99d83b14b8794bbcbc040ec7aa7
    +ID                                                                      │ Created    │ Created By                                                                                                                                                                                                                 │ Tags │ Size
    +────────────────────────────────────────────────────────────────────────┼────────────┼────────────────────────────────────────────────────────────────────────────────�
     �”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¼â”€â”€â”€â”€â”€â”€â”¼â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â
     ”€â”€
    +sha256:fdc893b19a147681ee764b2edab6c494d60fe99d83b14b8794bbcbc040ec7aa7 │ 1488578492 │ /bin/sh -c set -x        && apk add --no-cache           openjdk8-jre="$JAVA_ALPINE_VERSION"     && [ "$JAVA_HOME" = "$(docker-java-home)" ]                                                                                                │      │ [java:8-jre-alpine]
    +<missing>                                                               │ 1488578488 │ /bin/sh -c #(nop)  ENV JAVA_ALPINE_VERSION=8.111.14-r0                                                                                                                                                                     │      │
    +<missing>                                                               │ 1488578488 │ /bin/sh -c #(nop)  ENV JAVA_VERSION=8u111                                                                                                                                                                                  │      │
    +<missing>                                                               │ 1488578487 │ /bin/sh -c #(nop)  ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin                                                           │      │
    +<missing>                                                               │ 1488578487 │ /bin/sh -c #(nop)  ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk/jre                                                                                                                                                         │      │
    +<missing>                                                               │ 1488578458 │ /bin/sh -c {             echo '#!/bin/sh';               echo 'set -e';          echo;           echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"';    } > /usr/local/bin/docker-java-home       && chmod +x /usr/local/bin/docker-java-home │      │
    +<missing>                                                               │ 1488578457 │ /bin/sh -c #(nop)  ENV LANG=C.UTF-8                                                                                                                                                                                        │      │
    +<missing>                                                               │ 1488573141 │ /bin/sh -c #(nop) ADD file:3df55c321c1c8d73f22bc69240c0764290d6cb293da46ba8f94ed25473fb5853 in /                                                                                                                           │      │
    +
    +
    +
    +
    +

    Pushing and tagging image

    +
    +

    The docker:push command allows you to push an image on a given repository.

    +
    +
    +

    The docker:tag command create a new tag for a given image.

    +
    +
    +
    +

    Create container

    +
    +

    The Karaf Docker feature can create a Docker container based on a given image.

    +
    +
    +

    You can use either the docker:create shell command or the create() operation on the JMX DockerMBean.

    +
    +
    +

    For instance, here’s an example of the docker:bootstrap to create a Docker container based on elasticsearch instance:

    +
    +
    +
    +
    karaf@root()> docker:create --image fdc893b19a147681ee764b2edab6c494d60fe99d83b14b8794bbcbc040ec7aa7 --cmd /bin/bash test
    +
    +
    +
    +
    +

    Listing containers

    +
    +

    You can list the containers:

    +
    +
    +
    +
    karaf@root()> docker:ps -a
    +Id                                                               │ Names   │ Command   │ Created    │ Image                                                            │ Image ID                                                                │ Status  │ State   │ Ports │ Size │ Size Root
    +─────────────────────────────────────────────────────────────────┼─────────┼───────────┼────────────┼─────────────────────────────────────────────────────────────────�
     �”€â”¼â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¼â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¼â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¼â”€â”€â”€â”€â”€â”€â”€â”¼â”€â”€â”€â”€â”€â”€â”¼â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
    +92f8b280a7fa69c9ff673ed9678b7040a56c16c9c4aa403498a538cf0f501e9e │ [/test] │ /bin/bash │ 1532809485 │ fdc893b19a147681ee764b2edab6c494d60fe99d83b14b8794bbcbc040ec7aa7 │ sha256:fdc893b19a147681ee764b2edab6c494d60fe99d83b14b8794bbcbc040ec7aa7 │ Created │ created │       │ 0    │ 0
    +
    +
    +
    +

    You can also use the containers attribute on the DockerMBean JMX MBean or the containers() method on the DockerService service.

    +
    +
    +
    +

    Provision Docker container

    +
    +

    Provisioning is a specific way of creating container based on the current running Karaf instance: it creates a Docker container using the current running Apache Karaf instance karaf.base.

    +
    +
    +

    You can then reuse this container to create a Docker image and to duplicate the container on another Docker backend via dockerhub.

    +
    +
    +
    +
    karaf@root()> docker:provision my-karaf
    +
    +
    +
    +

    You can also use the provision() method on the DockerMBean JMX MBean or the DockerService service.

    +
    +
    +
    +

    Start container

    +
    +

    You can start a container using the docker:start command:

    +
    +
    +
    +
    karaf@root()> docker:start my-container
    +
    +
    +
    +

    You can also use the start() method on the DockerMBean JMX MBean or the DockerService service.

    +
    +
    +
    +

    Stop container

    +
    +

    You can stop a container using the docker:stop command:

    +
    +
    +
    +
    karaf@root()> docker:stop my-container
    +
    +
    +
    +

    You can also use the stop() method on the DockerMBean JMX MBean or the DockerService service.

    +
    +
    +
    +

    Restart container

    +
    +

    You can restart a container using the docker:restart command:

    +
    +
    +
    +
    karaf@root()> docker:restart my-container
    +
    +
    +
    +
    +

    Delete container

    +
    +

    You can delete an existing Docker container using the docker:rm commmand:

    +
    +
    +
    +
    karaf@root()> docker:rm my-container
    +
    +
    +
    +

    You can also use the rm() method on the DockerMBean JMX MBean or the DockerService service.

    +
    +
    +
    +

    Pause container

    +
    +

    The docker:pause command pauses all processes within one or more containers:

    +
    +
    +
    +
    karaf@root()> docker:pause my-container
    +
    +
    +
    +
    +

    Unpause container

    +
    +

    The docker:unpause command unpauses all processes within one or more containers:

    +
    +
    +
    +
    karaf@root()> docker:unpause my-container
    +
    +
    +
    +
    +

    Kill container

    +
    +

    The docker:kill command kills a running container:

    +
    +
    +
    +
    karaf@root()> docker:kill my-container
    +
    +
    +
    +
    +

    Rename container

    +
    +

    The docker:rename command renames an existing container:

    +
    +
    +
    +
    karaf@root()> docker:rename my-container new-container
    +
    +
    +
    +
    +

    Logs

    +
    +

    The docker:logs command displays the log on an existing container:

    +
    +
    +
    +
    karaf@root()> docker:logs --timestamps --details --stdout --stderr my-container
    +
    +
    +
    +
    +

    Top

    +
    +

    The docker:top command displays the current running processes in an existing container:

    +
    +
    +
    +
    karaf@root()> docker:top my-container
    +
    +
    +
    +
    +
    + + + \ No newline at end of file Modified: karaf/site/production/manual/latest/ejb.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/ejb.html?rev=1839907&r1=1839906&r2=1839907&view=diff ============================================================================== --- karaf/site/production/manual/latest/ejb.html (original) +++ karaf/site/production/manual/latest/ejb.html Mon Sep 3 06:10:48 2018 @@ -615,7 +615,7 @@ openejb-soap | 4.5.2 | Modified: karaf/site/production/manual/latest/extending.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/extending.html?rev=1839907&r1=1839906&r2=1839907&view=diff ============================================================================== --- karaf/site/production/manual/latest/extending.html (original) +++ karaf/site/production/manual/latest/extending.html Mon Sep 3 06:10:48 2018 @@ -516,408 +516,9 @@ table.CodeRay td.code>pre{padding:0}

    Apache Karaf is a very flexible container that you can extend very easily.

    -

    Console

    +

    Shell commands

    -

    In this section, you will see how to extend the console by adding your own command.

    -
    -
    -

    We will leverage Apache Maven to create and build the OSGi bundle. -This OSGi bundle will use Blueprint. We don’t cover the details of OSGi bundle and Blueprint, see the specific -sections for details.

    -
    -
    -
    Create the Maven project
    -
    -

    To create the Maven project, we can:

    -
    -
    -
      -
    • -

      use a Maven archetype

      -
    • -
    • -

      create by hand

      -
    • -
    -
    -
    -
    Using archetype
    -
    -

    The Maven Quickstart archetype can create an empty Maven project where you can put your project definition.

    -
    -
    -

    You can directly use:

    -
    -
    -
    -
    mvn archetype:generate \
    -  -DarchetypeArtifactId=maven-archetype-quickstart \
    -  -DgroupId=org.apache.karaf.shell.samples \
    -  -DartifactId=shell-sample-commands \
    -  -Dversion=1.0-SNAPSHOT
    -
    -
    -
    -

    It results to a ready to use project, including a pom.xml.

    -
    -
    -

    You can also use Maven archetype in interactive mode. You will have to answer to some questions used to generate -the project with the pom.xml:

    -
    -
    -
    -
    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
    -
    -
    -
    -
    -
    -
    By hand
    -
    -

    Alternatively, you can simply create the directory shell-sample-commands and create the pom.xml file inside it:

    -
    -
    -
    -
    <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>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.core</artifactId>
    -      <version>${project.version}</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>${felix.plugin.version}</version>
    -        <configuration>
    -          <instructions>
    -            <Import-Package>
    -              org.apache.felix.service.command,
    -              org.apache.karaf.shell.commands,
    -              org.apache.karaf.shell.console,
    -              *
    -            </Import-Package>
    -          </instructions>
    -        </configuration>
    -      </plugin>
    -    </plugins>
    -  </build>
    -
    -</project>
    -
    -
    -
    -
    -
    Configuring for Java 8
    -
    -

    We are using annotations to define commands, so we need to ensure Maven will actually use JDK 1.6 or 1.7 to compile the jar. -Just add the following snippet after the dependencies section.

    -
    -
    -
    -
    <build>
    -  <plugins>
    -    <plugin>
    -      <groupId>org.apache.maven.plugins</groupId>
    -      <artifactId>maven-compiler-plugin</artifactId>
    -      <configuration>
    -        <target>1.8</target>
    -        <source>1.8</source>
    -      </configuration>
    -    </plugin>
    -  </plugins>
    -</build>
    -
    -
    -
    -
    -
    Loading the project in your IDE
    -
    -

    We can use Maven to generate the needed files for your IDE:

    -
    -
    -

    Inside the project, run the following command

    -
    -
    -
    -
    mvn eclipse:eclipse
    -
    -
    -
    -

    or

    -
    -
    -
    -
    mvn idea:idea
    -
    -
    -
    -

    The project files for your IDE should now be created. Just open the IDE and load the project.

    -
    -
    -
    -
    Creating a basic command class
    -
    -

    We can now create the command class HelloShellCommand.java

    -
    -
    -
    -
    package org.apache.karaf.shell.samples;
    -
    -import org.apache.karaf.shell.api.action.Action;
    -import org.apache.karaf.shell.api.action.Command;
    -import org.apache.karaf.shell.api.action.lifecycle.Service;
    -
    -@Command(scope = "test", name = "hello", description="Says hello")
    -@Service
    -public class HelloShellCommand implements Action {
    -
    -    @Override
    -    public Object execute() throws Exception {
    -        System.out.println("Executing Hello command");
    -        return null;
    -    }
    -}
    -
    -
    -
    -
    -
    Manifest
    -
    -

    In order for Karaf to find your command, you need to add the Karaf-Commands=* manifest header.

    -
    -
    -

    This is usually done by modifying the maven bundle plugin configuration

    -
    -
    -
    -
    <plugin>
    -    <groupId>org.apache.felix</groupId>
    -    <artifactId>maven-bundle-plugin</artifactId>
    -    <configuration>
    -        <instructions>
    -            <Karaf-Commands>*</Karaf-Commands>
    -        </instructions>
    -    </configuration>
    -</plugin>
    -
    -
    -
    -
    -
    Compile
    -
    -

    Let’s try to build the jar. Remove the test classes and sample classes if you used the artifact, then from the command line, run:

    -
    -
    -
    -
    mvn install
    -
    -
    -
    -

    The end of the maven output should look like:

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

    Launch Apache Karaf and install your bundle:

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

    Let’s try running the command:

    -
    -
    -
    -
    karaf@root()> test:hello
    -Executing Hello command
    -
    -
    -
    -
    -
    Command completer
    -
    -

    A completer allows you to automatically complete a command argument using <tab>. A completer is simply a bean which is -injected to a command.

    -
    -
    -

    Of course to be able to complete it, the command should require an argument.

    -
    -
    -
    -
    Command argument
    -
    -

    We add an argument to the HelloCommand:

    -
    -
    -
    -
    package org.apache.karaf.shell.samples;
    -
    -import org.apache.karaf.shell.api.action.Action;
    -import org.apache.karaf.shell.api.action.Argument;
    -import org.apache.karaf.shell.api.action.Command;
    -import org.apache.karaf.shell.api.action.Completion;
    -import org.apache.karaf.shell.api.action.lifecycle.Service;
    -
    -@Command(scope = "test", name = "hello", description="Says hello")
    -@Service
    -public class HelloShellCommand implements Action {
    -
    -    @Argument(index = 0, name = "name", description = "The name that sends the greet.", required = true, multiValued = false)
    -    @Completion(SimpleNameCompleter.class)
    -    String name = null;
    -
    -    @Override
    -    public Object execute() throws Exception {
    -        System.out.println("Hello " + name);
    -        return null;
    -    }
    -}
    -
    -
    -
    -
    -
    Completer bean
    -
    -

    A completer is a bean which implements the Completer interface:

    -
    -
    -
    -
    package org.apache.karaf.shell.samples;
    -
    -import org.apache.karaf.shell.api.action.lifecycle.Service;
    -import org.apache.karaf.shell.api.console.CommandLine;
    -import org.apache.karaf.shell.api.console.Completer;
    -import org.apache.karaf.shell.api.console.Session;
    -import org.apache.karaf.shell.support.completers.StringsCompleter;
    -
    -/**
    - * <p>
    - * A very simple completer.
    - * </p>
    - */
    -@Service
    -public class SimpleNameCompleter implements Completer {
    -
    -    public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    -        StringsCompleter delegate = new StringsCompleter();
    -        delegate.getStrings().add("Mike");
    -        delegate.getStrings().add("Eric");
    -        delegate.getStrings().add("Jenny");
    -        return delegate.complete(session, commandLine, candidates);
    -    }
    -
    -}
    -
    -
    -
    -
    -
    Completers for option values
    -
    -

    Quite often your commands will not have just arguments, but also options. You can provide completers for option values. -The snippet below shows the HelloShellCommand with an option to specify what the greet message will be.

    -
    -
    -
    -
    package org.apache.karaf.shell.samples;
    -
    -import org.apache.karaf.shell.api.action.Action;
    -import org.apache.karaf.shell.api.action.Argument;
    -import org.apache.karaf.shell.api.action.Command;
    -import org.apache.karaf.shell.api.action.Completion;
    -import org.apache.karaf.shell.api.action.Option;
    -import org.apache.karaf.shell.api.action.lifecycle.Service;
    -
    -@Command(scope = "test", name = "hello", description="Says hello")
    -@Service
    -public class HelloShellCommand implements Action {
    -
    -    @Argument(index = 0, name = "name", description = "The name that sends the greet.", required = true, multiValued = false)
    -    @Completion(SimpleNameCompleter.class)
    -    String name = null;
    -
    -    @Option(name = "-g", aliases = "--greet", description = "The configuration pid", required = false, multiValued = false)
    -    @Completion(GreetCompleter.class)
    -    String greet = "Hello;
    -
    -    @Override
    -    public Object execute() throws Exception {
    -        System.out.println(greet + " " + name);
    -        return null;
    -    }
    -}
    -
    -
    -
    -
    -
    Completers with state
    -
    -

    Some times we want to tune the behavior of the completer depending on the commands already executed, in the current shell -or even the rest of the arguments that have been already passed to the command. Such example is the config:set-property -command which will provide auto completion for only for the properties of the pid specified by a previously issued config:edit -command or by the option --pid.

    -
    -
    -

    The Session object provides map like methods for storing key/value pairs and can be used to put/get the state. -The pre-parsed CommandLine objects allows you to check the previous arguments and options on the command line and to fine tune -the behavior of the Completer. -Those two objects are given to the Completer when calling the complete method.

    -
    -
    -
    -
    Test
    -
    -

    Launch a Karaf instance and run the following command to install the newly created bundle:

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

    Let’s try running the command:

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

    See [examples/karaf-command-example] to add your own shell commands.

    @@ -926,14 +527,14 @@ Those two objects are given to the Compl

    You can also extend the Apache Karaf WebConsole by providing and installing a webconsole plugin.

    -

    A plugin is an OSGi bundle that register a Servlet as an OSGi service with some webconsole properties.

    +

    A plugin is an OSGi bundle that register a Servlet as an OSGi service with webconsole properties.

    Modified: karaf/site/production/manual/latest/failover.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/failover.html?rev=1839907&r1=1839906&r2=1839907&view=diff ============================================================================== --- karaf/site/production/manual/latest/failover.html (original) +++ karaf/site/production/manual/latest/failover.html Mon Sep 3 06:10:48 2018 @@ -908,7 +908,7 @@ to update the slave configuration to bin Modified: karaf/site/production/manual/latest/github-contributions.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/github-contributions.html?rev=1839907&r1=1839906&r2=1839907&view=diff ============================================================================== --- karaf/site/production/manual/latest/github-contributions.html (original) +++ karaf/site/production/manual/latest/github-contributions.html Mon Sep 3 06:10:48 2018 @@ -616,7 +616,7 @@ git format-patch archon/trunk Modified: karaf/site/production/manual/latest/http.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/http.html?rev=1839907&r1=1839906&r2=1839907&view=diff ============================================================================== --- karaf/site/production/manual/latest/http.html (original) +++ karaf/site/production/manual/latest/http.html Mon Sep 3 06:10:48 2018 @@ -596,7 +596,7 @@ So it is much more convenient than regis