Modified: karaf/site/production/manual/latest/index.html URL: http://svn.apache.org/viewvc/karaf/site/production/manual/latest/index.html?rev=1816059&r1=1816058&r2=1816059&view=diff ============================================================================== --- karaf/site/production/manual/latest/index.html (original) +++ karaf/site/production/manual/latest/index.html Wed Nov 22 14:52:25 2017 @@ -554,14 +554,10 @@ table.CodeRay td.code>pre{padding:0} <li><a href="#_systemmbean">4.3.5. SystemMBean</a></li> </ul> </li> -<li><a href="#_integration_in_the_operating_system_the_service_wrapper">4.4. Integration in the operating system: the Service Wrapper</a> +<li><a href="#_integration_in_the_operating_system">4.4. Integration in the operating system</a> <ul class="sectlevel3"> -<li><a href="#_supported_platforms">4.4.1. Supported platforms</a></li> -<li><a href="#_installation_2">4.4.2. Installation</a></li> -<li><a href="#_installation_3">4.4.3. Installation</a></li> -<li><a href="#_uninstall">4.4.4. Uninstall</a></li> -<li><a href="#_note_for_macos_users">4.4.5. Note for MacOS users</a></li> -<li><a href="#_configuration">4.4.6. Configuration</a></li> +<li><a href="#_service_wrapper">4.4.1. Service Wrapper</a></li> +<li><a href="#_service_script_templates">4.4.2. Service Script Templates</a></li> </ul> </li> <li><a href="#_using_the_console">4.5. Using the console</a> @@ -582,9 +578,10 @@ table.CodeRay td.code>pre{padding:0} <ul class="sectlevel3"> <li><a href="#_configuration_files">4.7.1. Configuration files</a></li> <li><a href="#_log4j_v2_support">4.7.2. Log4j v2 support</a></li> -<li><a href="#_commands_2">4.7.3. Commands</a></li> -<li><a href="#_jmx_logmbean">4.7.4. JMX LogMBean</a></li> -<li><a href="#_advanced_configuration">4.7.5. Advanced configuration</a></li> +<li><a href="#__code_karaf_log_console_code_property">4.7.3. <code>karaf.log.console</code> property</a></li> +<li><a href="#_commands_2">4.7.4. Commands</a></li> +<li><a href="#_jmx_logmbean">4.7.5. JMX LogMBean</a></li> +<li><a href="#_advanced_configuration">4.7.6. Advanced configuration</a></li> </ul> </li> <li><a href="#_configuration_3">4.8. Configuration</a> @@ -597,6 +594,7 @@ table.CodeRay td.code>pre{padding:0} <li><a href="#_artifacts_repositories_and_urls">4.9. Artifacts repositories and URLs</a> <ul class="sectlevel3"> <li><a href="#_maven_url_handler">4.9.1. Maven URL Handler</a></li> +<li><a href="#_maven_configuration_commands">4.9.2. Maven configuration commands</a></li> </ul> </li> <li><a href="#_provisioning">4.10. Provisioning</a> @@ -607,13 +605,14 @@ table.CodeRay td.code>pre{padding:0} <li><a href="#_features_repositories_2">4.10.4. Features repositories</a></li> <li><a href="#_boot_features">4.10.5. Boot features</a></li> <li><a href="#_features_upgrade">4.10.6. Features upgrade</a></li> -<li><a href="#_feature_bundles">4.10.7. Feature bundles</a></li> -<li><a href="#_dependent_features">4.10.8. Dependent features</a></li> -<li><a href="#_feature_configurations">4.10.9. Feature configurations</a></li> -<li><a href="#_feature_configuration_files">4.10.10. Feature configuration files</a></li> -<li><a href="#_commands_3">4.10.11. Commands</a></li> -<li><a href="#_deployer">4.10.12. Deployer</a></li> -<li><a href="#_jmx_featurembean">4.10.13. JMX FeatureMBean</a></li> +<li><a href="#_overrides">4.10.7. Overrides</a></li> +<li><a href="#_feature_bundles">4.10.8. Feature bundles</a></li> +<li><a href="#_dependent_features">4.10.9. Dependent features</a></li> +<li><a href="#_feature_configurations">4.10.10. Feature configurations</a></li> +<li><a href="#_feature_configuration_files">4.10.11. Feature configuration files</a></li> +<li><a href="#_commands_3">4.10.12. Commands</a></li> +<li><a href="#_deployer">4.10.13. Deployer</a></li> +<li><a href="#_jmx_featurembean">4.10.14. JMX FeatureMBean</a></li> </ul> </li> <li><a href="#_deployers">4.11. Deployers</a> @@ -687,15 +686,24 @@ table.CodeRay td.code>pre{padding:0} </li> <li><a href="#_webconsole_2">4.18. WebConsole</a> <ul class="sectlevel3"> -<li><a href="#_installation_4">4.18.1. Installation</a></li> +<li><a href="#_installation_3">4.18.1. Installation</a></li> <li><a href="#_access">4.18.2. Access</a></li> </ul> </li> -<li><a href="#_tuning">4.19. Tuning</a> +<li><a href="#_scheduler">4.19. Scheduler</a> <ul class="sectlevel3"> -<li><a href="#_garbage_collection">4.19.1. Garbage Collection</a></li> -<li><a href="#_threads">4.19.2. Threads</a></li> -<li><a href="#_system_packages">4.19.3. System packages</a></li> +<li><a href="#_installation_4">4.19.1. Installation</a></li> +<li><a href="#_configuration_7">4.19.2. Configuration</a></li> +<li><a href="#_schedule_a_new_job_using_the_whitebox_service_paradigm_recommended">4.19.3. Schedule a new Job using the Whitebox-Service paradigm (recommended)</a></li> +<li><a href="#_schedule_a_new_job_using_the_gogo_shell">4.19.4. Schedule a new Job using the Gogo Shell</a></li> +<li><a href="#_schedule_a_new_job_using_the_scheduler_service">4.19.5. Schedule a new Job using the Scheduler Service</a></li> +</ul> +</li> +<li><a href="#_tuning">4.20. Tuning</a> +<ul class="sectlevel3"> +<li><a href="#_garbage_collection">4.20.1. Garbage Collection</a></li> +<li><a href="#_threads">4.20.2. Threads</a></li> +<li><a href="#_system_packages">4.20.3. System packages</a></li> </ul> </li> </ul> @@ -912,7 +920,7 @@ Framework, but you can easily switch to <div class="sect2"> <h3 id="_prerequisites">2.1. Prerequisites</h3> <div class="paragraph"> -<p>Karaf requires a Java SE 7 or Java SE 8 environment to run. Refer to <a href="http://www.oracle.com/technetwork/java/javase/" class="bare">http://www.oracle.com/technetwork/java/javase/</a> for details on how to download and install Java SE 1.7 or greater.</p> +<p>Karaf requires a Java SE 8 or Java SE 9 environment to run. Refer to <a href="http://www.oracle.com/technetwork/java/javase/" class="bare">http://www.oracle.com/technetwork/java/javase/</a> for details on how to download and install Java SE 1.8 or greater.</p> </div> <div class="ulist"> <ul> @@ -960,7 +968,7 @@ Framework, but you can easily switch to / /| |/ /_/ / / / /_/ / __/ /_/ |_|\__,_/_/ \__,_/_/ - Apache Karaf (4.0.0) + Apache Karaf (4.2.0) Hit '<tab>' for a list of available commands and '[cmd] --help' for help on a specific command. @@ -977,7 +985,9 @@ karaf@root()></pre> </div> <div class="listingblock"> <div class="content"> -<pre>karaf@root()> Display all 294 possibilities? (y or n) +<pre>karaf@root()> +karaf: do you wish to see to see all 356 possibilities (219 lines)? +karaf@root()> Display all 294 possibilities? (y or n) ... shell:logout shell:more shell:new shell:printf shell:sleep shell:sort shell:source shell:stack-traces-print shell:tac shell:tail shell:threads shell:watch shell:wc shell:while @@ -1008,25 +1018,27 @@ ARGUMENTS The list of bundle (identified by IDs or name or name/version) separated by whitespaces OPTIONS - -t - Specifies the bundle threshold; bundles with a start-level less than this value will not get printed out. - --no-format - Disable table rendered output - -s - Shows the symbolic name - -l - Show the locations - --no-ellipsis - - --help - Display this help message + -name, -n + Show bundle name -u Shows the update locations + -r + Shows the bundle revisions + --no-ellipsis + + -l + Show the locations + -s + Shows the symbolic name --context, -c Use the given bundle context (defaults to 0) - -r - Shows the bundle revisions</pre> + --help + Display this help message + -t + Specifies the bundle threshold; bundles with a start-level less than this value will not get printed out. + --no-format + Disable table rendered output</pre> </div> </div> <div class="paragraph"> @@ -1039,15 +1051,27 @@ OPTIONS <p>While you will learn in the Karaf user’s guide how to fully use and leverage Apache Karaf, let’s install a sample <a href="http://camel.apache.org">Apache Camel</a> application for now:</p> </div> <div class="paragraph"> -<p>In the console, run the following commands:</p> +<p>Copy and paste the following commands in the console:</p> </div> <div class="listingblock"> <div class="content"> -<pre>karaf@root()> feature:repo-add camel 2.15.2 -Adding feature url mvn:org.apache.camel.karaf/apache-camel/2.15.2/xml/features -karaf@root()> feature:install camel-spring -karaf@root()> bundle:install -s mvn:org.apache.camel/camel-example-osgi/2.15.2 -Bundle ID: 82</pre> +<pre>feature:repo-add camel 2.20.0 +feature:install deployer camel-blueprint aries-blueprint +cat > deploy/example.xml <<END +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> + + <camelContext xmlns="http://camel.apache.org/schema/blueprint"> + <route> + <from uri="timer://test?fixedRate=true&amp;period=2000" /> + <setBody> + <simple>Message at ${date:now:yyyy-MM-dd HH:mm:ss}</simple> + </setBody> + <to uri="log:test" /> + </route> + </camelContext> + +</blueprint> +END</pre> </div> </div> <div class="paragraph"> @@ -1061,11 +1085,8 @@ The previous commands download the Camel <div class="content"> <pre>karaf@root()> log:display ... -2015-06-30 13:39:44,731 | INFO | timer://myTimer | ExampleRouter | 53 - org.apache.camel.camel-core - 2.15.2 | Exchange[ExchangePattern: InOnly, BodyType: String, Body: SpringDSL set body: Tue Jun 30 13:39:44 CEST 2015] -2015-06-30 13:39:46,730 | INFO | timer://myTimer | MyTransform | 82 - camel-example-osgi - 2.15.2 | >>>> SpringDSL set body: Tue Jun 30 13:39:46 CEST 2015 -2015-06-30 13:39:46,731 | INFO | timer://myTimer | ExampleRouter | 53 - org.apache.camel.camel-core - 2.15.2 | Exchange[ExchangePattern: InOnly, BodyType: String, Body: SpringDSL set body: Tue Jun 30 13:39:46 CEST 2015] -2015-06-30 13:39:48,730 | INFO | timer://myTimer | MyTransform | 82 - camel-example-osgi - 2.15.2 | >>>> SpringDSL set body: Tue Jun 30 13:39:48 CEST 2015 -2015-06-30 13:39:48,730 | INFO | timer://myTimer | ExampleRouter | 53 - org.apache.camel.camel-core - 2.15.2 | Exchange[ExchangePattern: InOnly, BodyType: String, Body: SpringDSL set body: Tue Jun 30 13:39:48 CEST 2015]</pre> +2017-10-13 10:04:11,225 | INFO | 7 - timer://test | test | 28 - org.apache.camel.camel-core - 2.20.0 | Exchange[ExchangePattern: InOnly, BodyType: String, Body: Message at 2017-10-13 10:04:11] +2017-10-13 10:04:13,225 | INFO | 7 - timer://test | test | 28 - org.apache.camel.camel-core - 2.20.0 | Exchange[ExchangePattern: InOnly, BodyType: String, Body: Message at 2017-10-13 10:04:13]</pre> </div> </div> </div> @@ -1076,8 +1097,8 @@ The previous commands download the Camel </div> <div class="listingblock"> <div class="content"> -<pre>karaf@root()> bundle:stop camel-example-osgi -karaf@root()> bundle:uninstall camel-example-osgi</pre> +<pre>karaf@root()> bundle:stop example.xml +karaf@root()> bundle:uninstall example.xml</pre> </div> </div> </div> @@ -1096,7 +1117,10 @@ karaf@root()> bundle:uninstall camel- </div> <div class="listingblock"> <div class="content"> -<pre>karaf@root()> system:shutdown</pre> +<pre>karaf@root()> feature:install system +karaf@root()> system:shutdown +Confirm: halt instance root (yes/no): yes +karaf@root()></pre> </div> </div> <div class="paragraph"> @@ -2478,15 +2502,25 @@ Running ...</pre> </div> </div> <div class="sect2"> -<h3 id="_integration_in_the_operating_system_the_service_wrapper">4.4. Integration in the operating system: the Service Wrapper</h3> +<h3 id="_integration_in_the_operating_system">4.4. Integration in the operating system</h3> <div class="paragraph"> <p>In the previous chapter, we saw the different scripts and commands to start, stop, restart Apache Karaf.</p> </div> <div class="paragraph"> -<p>Instead of using these commands and scripts, you can integrate Apache Karaf directly in your operating system service control.</p> +<p>Instead of using these commands and scripts, you can integrate Apache Karaf directly in your operating system service control using:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><a href="#_service_wrapper">Service Wrapper</a></p> +</li> +<li> +<p><a href="#_service_script_templates">Service Script Templates</a></p> +</li> +</ul> </div> <div class="paragraph"> -<p>Apache Karaf provides the "Service Wrapper". The service wrapper allows you to directly integrate Apache Karaf:</p> +<p>The above methods allow you to directly integrate Apache Karaf:</p> </div> <div class="ulist"> <ul> @@ -2498,6 +2532,8 @@ Running ...</pre> </li> </ul> </div> +<div class="sect3"> +<h4 id="_service_wrapper">4.4.1. Service Wrapper</h4> <div class="paragraph"> <p>The "Service Wrapper" correctly handles "user’s log outs" under Windows, service dependencies, and the ability to run services which interact with the desktop.</p> </div> @@ -2506,8 +2542,8 @@ Running ...</pre> The "Service Wrapper" is able to detect crashes, freezes, out of memory and other exception events, then automatically react by restarting Apache Karaf with a minimum of delay. It guarantees the maximum possible uptime of Apache Karaf.</p> </div> -<div class="sect3"> -<h4 id="_supported_platforms">4.4.1. Supported platforms</h4> +<div class="sect4"> +<h5 id="_supported_platforms">Supported platforms</h5> <div class="ulist"> <ul> <li> @@ -2537,8 +2573,8 @@ It guarantees the maximum possible uptim </ul> </div> </div> -<div class="sect3"> -<h4 id="_installation_2">4.4.2. Installation</h4> +<div class="sect4"> +<h5 id="_installation_2">Installation</h5> <div class="paragraph"> <p>Apache Karaf Service Wrapper is an optional feature. You have to install the "Service Wrapper" installer first.</p> </div> @@ -2581,47 +2617,6 @@ OPTIONS (defaults to )</pre> </div> </div> -</div> -<div class="sect3"> -<h4 id="_installation_3">4.4.3. Installation</h4> -<div class="paragraph"> -<p>Karaf Wrapper is an optional feature. To install it, simply type:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre>karaf@root> feature:install wrapper</pre> -</div> -</div> -<div class="paragraph"> -<p>Once installed, wrapper feature will provide <code>wrapper:install</code> new command in the Karaf shell:</p> -</div> -<div class="listingblock"> -<div class="content"> -<pre>karaf@root> wrapper:install --help -DESCRIPTION - wrapper:install - - Install the container as a system service in the OS. - -SYNTAX - wrapper:install [options] - -OPTIONS - -s, --start-type - Mode in which the service is installed. AUTO_START or DEMAND_START (Default: AUTO_START) - (defaults to AUTO_START) - --help - Display this help message - -n, --name - The service name that will be used when installing the service. (Default: karaf) - (defaults to karaf) - -d, --display - The display name of the service. - -D, --description - The description of the service. - (defaults to )</pre> -</div> -</div> <div class="paragraph"> <p>The <code>wrapper:install</code> command detects the running Operating Service and provide the service/daemon ready to be integrated in your system.</p> </div> @@ -2702,8 +2697,8 @@ update-rc.d karaf-service defaults</pre> <p>This will enable Karaf at system boot.</p> </div> </div> -<div class="sect3"> -<h4 id="_uninstall">4.4.4. Uninstall</h4> +<div class="sect4"> +<h5 id="_uninstall">Uninstall</h5> <div class="paragraph"> <p>The <code>wrapper:install</code> provides the system commands to perform to uninstall the service/daemon).</p> </div> @@ -2732,8 +2727,8 @@ update-rc.d karaf-service defaults</pre> </div> </div> </div> -<div class="sect3"> -<h4 id="_note_for_macos_users">4.4.5. Note for MacOS users</h4> +<div class="sect4"> +<h5 id="_note_for_macos_users">Note for MacOS users</h5> <div class="paragraph"> <p>On MacOS you can install the service for an user or for the system.</p> </div> @@ -2784,8 +2779,8 @@ launchctl stop org.apache.karaf.KARAF</p </div> </div> </div> -<div class="sect3"> -<h4 id="_configuration">4.4.6. Configuration</h4> +<div class="sect4"> +<h5 id="_configuration">Configuration</h5> <div class="paragraph"> <p>When using scripts in the Apache Karaf <code>bin</code> folder, you can using <code>bin/setenv</code> Unix script (<code>bin\setenv.bat</code> on Windows) as described in the [Start, stop, restart, connect|start-stop] section of the documentation.</p> </div> @@ -2919,8 +2914,6 @@ wrapper.java.additional.4=-Dkaraf.etc=%K wrapper.java.additional.5=-Dcom.sun.management.jmxremote wrapper.java.additional.6=-Dkaraf.startLocalConsole=false wrapper.java.additional.7=-Dkaraf.startRemoteShell=true -wrapper.java.additional.8=-Djava.endorsed.dirs=%JAVA_HOME%/jre/lib/endorsed:%JAVA_HOME%/lib/endorsed:%KARAF_HOME%/lib/endorsed -wrapper.java.additional.9=-Djava.ext.dirs=%JAVA_HOME%/jre/lib/ext:%JAVA_HOME%/lib/ext:%KARAF_HOME%/lib/ext # Uncomment to enable jmx #wrapper.java.additional.n=-Dcom.sun.management.jmxremote.port=1616 @@ -3007,6 +3000,278 @@ wrapper.ntservice.interactive=false</pre </div> </div> </div> +<div class="sect3"> +<h4 id="_service_script_templates">4.4.2. Service Script Templates</h4> +<div class="paragraph"> +<p>By using the "Service Script Templates", you can run Apache Karaf with the help of operating system specific init scripts.</p> +</div> +<div class="admonitionblock note"> +<table> +<tr> +<td class="icon"> +<div class="title">Note</div> +</td> +<td class="content"> +<div class="paragraph"> +<p>As opposite of Service Wrapper, the templates targeting Unix system do not rely on a 3th party binaries</p> +</div> +</td> +</tr> +</table> +</div> +<div class="paragraph"> +<p>You can find these templates under the bin/contrib directory.</p> +</div> +<div class="paragraph"> +<p> <br></p> +</div> +<div class="sect4"> +<h5 id="_unix">Unix</h5> +<div class="paragraph"> +<p>The karaf-service.sh utility helps you to generate ready to use scripts by automatically identify the operating system, the default init system and the template to use.</p> +</div> +<div class="admonitionblock note"> +<table> +<tr> +<td class="icon"> +<div class="title">Note</div> +</td> +<td class="content"> +<div class="paragraph"> +<p>You may still need to customize the generated files to adapt them to your environment.</p> +</div> +</td> +</tr> +</table> +</div> +<div class="paragraph"> +<p>The utility karaf-service.sh can be configured by defining environment variables or by passing command line options:</p> +</div> +<table class="tableblock frame-all grid-all spread"> +<colgroup> +<col style="width: 33%;"> +<col style="width: 33%;"> +<col style="width: 33%;"> +</colgroup> +<tbody> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">Command line option</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Environment variable</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Description</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-k</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_PATH</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf installation path (mandatory)</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-d</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_DATA</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf data path (default to ${KARAF_SERVICE_PATH}/data)</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-c</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_CONF</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf configuration file (default to ${KARAF_SERVICE_PATH/etc/${KARAF_SERVICE_NAME}.conf</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-t</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_ETC</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf etc path (default to ${KARAF_SERVICE_PATH/etc}</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-p</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_PIDFILE</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf pid path (default to ${KARAF_SERVICE_DATA}/${KARAF_SERVICE_NAME}.pid)</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-n</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_NAME</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf service name (default karaf)</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-e</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_ENV</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf environment variable (can be repeated)</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-u</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_USER</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf user</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-g</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_GROUP</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf group (default ${KARAF_SERVICE_USER)</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-l</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_LOG</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf console log (default to ${KARAF_SERVICE_DATA}/log/${KARAF_SERVICE_NAME}-console.log)</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-f</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_TEMPLATE</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Template file to use</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">-x</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">KARAF_SERVICE_EXECUTABLE</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Karaf executable name (defaul karaf</p></td> +</tr> +</tbody> +</table> +<div class="paragraph"> +<p> <br></p> +</div> +</div> +<div class="sect4"> +<h5 id="_systemd">Systemd</h5> +<div class="paragraph"> +<p>When karaf-service.sh detect Systemd, it generates three files:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>a systemd unit file to manage the root Apache Karaf container</p> +</li> +<li> +<p>a systemd environment file with variables used by the root Apache Karaf container</p> +</li> +<li> +<p>a systemd template unit file to manage Apache Karaf child containers</p> +</li> +</ul> +</div> +<div class="literalblock"> +<div class="title">Example</div> +<div class="content"> +<pre>$ ./karaf-service.sh -k /opt/karaf-4 -n karaf-4 +Writing service file "/opt/karaf-4/bin/contrib/karaf-4.service" +Writing service configuration file ""/opt/karaf-4/etc/karaf-4.conf" +Writing service file "/opt/karaf-4/bin/contrib/[email protected]" + +$ cp /opt/karaf-4/bin/contrib/karaf-4.service /etc/systemd/system +$ cp /opt/karaf-4/bin/contrib/[email protected] /etc/systemd/system + +$ systemctl enable karaf-4.service</pre> +</div> +</div> +<div class="paragraph"> +<p> <br></p> +</div> +</div> +<div class="sect4"> +<h5 id="_sysv">SysV</h5> +<div class="paragraph"> +<p>When karaf-service.sh detect a SysV system, it generates two files:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>an init script to manage the root Apache Karaf container</p> +</li> +<li> +<p>an environment file with variables used by the root Apache Karaf container</p> +</li> +</ul> +</div> +<div class="literalblock"> +<div class="title">Example</div> +<div class="content"> +<pre>$ ./karaf-service.sh -k /opt/karaf-4 -n karaf-4 +Writing service file "/opt/karaf-4/bin/contrib/karaf-4" +Writing service configuration file "/opt/karaf-4/etc/karaf-4.conf" + +$ ln -s /opt/karaf-4/bin/contrib/karaf-4 /etc/init.d/ +$ chkconfig karaf-4 on</pre> +</div> +</div> +<div class="admonitionblock note"> +<table> +<tr> +<td class="icon"> +<div class="title">Note</div> +</td> +<td class="content"> +<div class="paragraph"> +<p>To enable service startup upon boot, please consult your operating system init guide</p> +</div> +</td> +</tr> +</table> +</div> +<div class="paragraph"> +<p> <br></p> +</div> +</div> +<div class="sect4"> +<h5 id="_solaris_smf">Solaris SMF</h5> +<div class="paragraph"> +<p>When karaf-service.sh detect a Solaris system, it generates a single file:</p> +</div> +<div class="literalblock"> +<div class="title">Example</div> +<div class="content"> +<pre>$ ./karaf-service.sh -k /opt/karaf-4 -n karaf-4 -u lburgazz -g lburgazz +Writing service file "/opt/karaf-4/bin/contrib/karaf-4.xml" + +$ svccfg validate /opt/karaf-4/bin/contrib/karaf-4.xml +$ svccfg import /opt/karaf-4/bin/contrib/karaf-4.xml</pre> +</div> +</div> +<div class="admonitionblock note"> +<table> +<tr> +<td class="icon"> +<div class="title">Note</div> +</td> +<td class="content"> +<div class="paragraph"> +<p>The generated SMF descriptor is defined as transient so the start method is executed once</p> +</div> +</td> +</tr> +</table> +</div> +<div class="paragraph"> +<p> <br></p> +</div> +</div> +<div class="sect4"> +<h5 id="_windows">Windows</h5> +<div class="paragraph"> +<p>Installation of Apache Karaf as windows service is supported through <a href="https://github.com/kohsuke/winsw">winsw</a>.</p> +</div> +<div class="paragraph"> +<p>Steps:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p>Rename karaf-service-win.exe to the service name i.e karaf-4.exe</p> +</li> +<li> +<p>Rename karaf-service-win.xml to match the service name i.e. karaf-4.xml</p> +</li> +<li> +<p>Customize the service descriptor to fit your needs</p> +</li> +<li> +<p>Use the service executable to install/star/stop the service</p> +</li> +</ul> +</div> +<div class="literalblock"> +<div class="title">Example</div> +<div class="content"> +<pre>C:\opt\apache-karaf-4\bin\contrib> karaf-4.exe install +C:\opt\apache-karaf-4\bin\contrib> karaf-4.exe start</pre> +</div> +</div> +</div> +</div> +</div> <div class="sect2"> <h3 id="_using_the_console">4.5. Using the console</h3> <div class="sect3"> @@ -4408,7 +4673,89 @@ used by the log commands (see later).</p </div> </div> <div class="sect3"> -<h4 id="_commands_2">4.7.3. Commands</h4> +<h4 id="__code_karaf_log_console_code_property">4.7.3. <code>karaf.log.console</code> property</h4> +<div class="paragraph"> +<p>Before Karaf starts <em>proper</em> logging facilities (pax-logging), it may configure <code>java.util.logging</code>. Standard +Java logging is used initially by <code>Main</code> class and <code>org.apache.karaf.main.lock.Lock</code> implementations. +In order to configure logging level, please set system property <code>karaf.log.console</code> to one of standard JUL +levels:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>SEVERE</code> (highest value)</p> +</li> +<li> +<p><code>WARNING</code></p> +</li> +<li> +<p><code>INFO</code></p> +</li> +<li> +<p><code>CONFIG</code></p> +</li> +<li> +<p><code>FINE</code></p> +</li> +<li> +<p><code>FINER</code></p> +</li> +<li> +<p><code>FINEST</code> (lowest value)</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>Additionally, de-facto standard log4j(2) levels can be used:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>TRACE</code></p> +</li> +<li> +<p><code>DEBUG</code></p> +</li> +<li> +<p><code>INFO</code></p> +</li> +<li> +<p><code>WARN</code></p> +</li> +<li> +<p><code>ERROR</code></p> +</li> +<li> +<p><code>OFF</code></p> +</li> +<li> +<p><code>DEFAULT</code></p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>And because <code>org.ops4j.pax.logging</code> PID uses <code>karaf.log.console</code> property, it’s in fact better to use log4j levels instead:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>log4j2.rootLogger.appenderRef.Console.filter.threshold.level = ${karaf.log.console:-OFF}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>For example, setting <code>karaf.log.console</code> to <code>INFO</code> (or lower) will turn on these logs when starting Karaf:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>Jul 04, 2017 7:53:18 AM org.apache.karaf.main.Main launch +INFO: Installing and starting initial bundles +Jul 04, 2017 7:53:18 AM org.apache.karaf.main.Main launch +INFO: All initial bundles installed and set to start +...</code></pre> +</div> +</div> +</div> +<div class="sect3"> +<h4 id="_commands_2">4.7.4. Commands</h4> <div class="paragraph"> <p>Instead of changing the <code>etc/org.ops4j.pax.logging.cfg</code> file, Apache Karaf provides a set of commands allowing to dynamically change the log configuration and see the log content:</p> @@ -4732,7 +5079,7 @@ my.logger.custom=appender2</pre> </div> </div> <div class="sect3"> -<h4 id="_jmx_logmbean">4.7.4. JMX LogMBean</h4> +<h4 id="_jmx_logmbean">4.7.5. JMX LogMBean</h4> <div class="paragraph"> <p>All actions that you can perform with the <code>log:*</code> command can be performed using the LogMBean.</p> </div> @@ -4764,7 +5111,7 @@ my.logger.custom=appender2</pre> </div> </div> <div class="sect3"> -<h4 id="_advanced_configuration">4.7.5. Advanced configuration</h4> +<h4 id="_advanced_configuration">4.7.6. Advanced configuration</h4> <div class="sect4"> <h5 id="_filters">Filters</h5> <div class="paragraph"> @@ -5060,6 +5407,24 @@ name convention.</p> </div> </div> <div class="paragraph"> +<p>Properties can be referenced inside configuration files using the syntax <code>${<name>}</code>. Default and alternate +values can be specified using <code>${<name>:-<default_value>}</code> and <code>${<name>:+<alternate_value>}</code> syntaxes respectively.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>existing_property=baz +property1=${missing_property:-foo} # "foo" +property2=${missing_property:+foo} # empty string +property3=${existing_property:-bar} # "baz" +property4=${existing_property:+bar} # "bar"</pre> +</div> +</div> +<div class="paragraph"> +<p>Environment variables can be referenced inside configuration files using the syntax <code>${env:<name>}</code> (e.g. +<code>property=${env:FOO}</code> will set "property" to the value of the enviroment variable "FOO"). Default and alternate +values can be defined for them as well using the same syntax as above.</p> +</div> +<div class="paragraph"> <p>In Apache Karaf, a configuration is PID with a set of properties attached.</p> </div> <div class="paragraph"> @@ -5077,7 +5442,7 @@ name convention.</p> # felix.fileinstall.enableConfigSave = true felix.fileinstall.dir = ${karaf.etc} -felix.fileinstall.filter = .*\\.cfg +felix.fileinstall.filter = .*\\.(cfg|config) felix.fileinstall.poll = 1000 felix.fileinstall.noInitialDelay = true felix.fileinstall.log.level = 3 @@ -5093,12 +5458,12 @@ configuration service (ConfigAdmin). If persisted back in the configuration false. Default is <code>true</code>.</p> </li> <li> -<p><code>felix.fileinstall.dir</code> is the directory where Apache Karaf is looking for configuration files. Default is <code>${karaf.etc</code>} +<p><code>felix.fileinstall.dir</code> is the directory where Apache Karaf is looking for configuration files. Default is <code>${karaf.etc}</code> meaning the value of the <code>KARAF_ETC</code> variable.</p> </li> <li> <p><code>felix.fileinstall.filter</code> is the file name pattern used to load only some configuration files. Only files matching -the pattern will be loaded. Default value is <code>.*\\.cfg</code> meaning *.cfg files.</p> +the pattern will be loaded. Default value is <code>.*\\.(cfg|config)</code> meaning *.cfg and *.config files.</p> </li> <li> <p><code>felix.fileinstall.poll</code> is the polling interval (in milliseconds). Default value is <code>1000</code> meaning that Apache @@ -5119,10 +5484,15 @@ this value is high, more verbose the con </ul> </div> <div class="paragraph"> -<p>You can change the configuration at runtime by directly editiing the configuration file.</p> +<p>You can change the configuration at runtime by directly editing the configuration file.</p> +</div> +<div class="paragraph"> +<p>You can also do the same using the <code>config:*</code> commands or the ConfigMBean.</p> </div> <div class="paragraph"> -<p>You can also do the same using the <code>config:*</code> commands or the ConfigMBean.</p> +<p>Apache Karaf persists configuration using own persistence manager in case of when available persistence managers do not support that. +Configuration files are placed by default in <code>KARAF_ETC</code>, but it could be overridden via variable <code>storage</code> in <code>etc/org.apache.karaf.config.cfg</code>. +If you want to disable karaf persistence manager, set storage variable to empty string (<code>storage=</code>).</p> </div> </div> <div class="sect3"> @@ -5539,7 +5909,7 @@ pattern | Pattern | String | %d{ABSOLUTE </div> <div class="listingblock"> <div class="content"> -<pre><bundle>http://repo1.maven.org/maven2/org/apache/servicemix/nmr/org.apache.servicemix.nmr.api/1.0.0-m2/org.apache.servicemix.nmr.api-1.0.0-m2.jar</bundle></pre> +<pre class="CodeRay highlight nowrap"><code><bundle>http://repo1.maven.org/maven2/org/apache/servicemix/nmr/org.apache.servicemix.nmr.api/1.0.0-m2/org.apache.servicemix.nmr.api-1.0.0-m2.jar</bundle></code></pre> </div> </div> <div class="paragraph"> @@ -5577,30 +5947,421 @@ located in a directory which is not avai <p>In addition to being less verbose, the Maven url handlers can also resolve snapshots and can use a local copy of the jar if one is available in your Maven local repository.</p> </div> <div class="paragraph"> -<p>The <code>org.ops4j.pax.url.mvn</code> bundle resolves <code>mvn</code> URLs. It can be configured using the file <code>etc/org.ops4j.pax.url.cfg</code></p> +<p>The <code>org.ops4j.pax.url.mvn</code> bundle resolves <code>mvn</code> URLs. It can be configured using the file <code>etc/org.ops4j.pax.url.cfg</code>. +Full reference of <code>org.ops4j.pax.url.mvn</code> PID configuration can be found <a href="https://ops4j1.jira.com/wiki/display/paxurl/Aether+Configuration">on pax-web Wiki page</a>.</p> +</div> +<div class="paragraph"> +<p>The most important property is:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>org.ops4j.pax.url.mvn.repositories</code> : Comma separated list of remote repository URLs that are checked in order of occurence when resolving maven artifacts</p> +</li> +</ul> </div> <div class="paragraph"> -<p>The most important property is :</p> +<p>Two other significant properties are:</p> </div> <div class="ulist"> <ul> <li> -<p><code>org.ops4j.pax.url.mvn.repositories</code> : Comma separated list of repository remote repository URLs that are checked in order of occurence when resolving maven artifacts</p> +<p><code>org.ops4j.pax.url.mvn.defaulRepositories</code> : Comma separated list of locations that are checked before querying remote repositories. These can be treated as read-only repositories, as nothing is written there during artifact resolution.</p> +</li> +<li> +<p><code>org.ops4j.pax.url.mvn.localRepository</code> : by default (implicitly) it’s standard <code>~/.m2/repository</code> location. This +local repository is used to store artifacts downloaded from one of remote repositories, so at next resolution attempt +no remote request is issued.</p> </li> </ul> </div> <div class="paragraph"> -<p>By default, snapshots are disabled. To enable an URL for snapshots append @snapshots to a repository entry. For example</p> +<p>By default, snapshots are disabled. To enable an URL for snapshots append <code>@snapshots</code> to a repository URI. For example</p> </div> <div class="listingblock"> <div class="content"> -<pre>http://www.example.org/repo@snapshots</pre> +<pre>org.ops4j.pax.url.mvn.repositories = http://www.example.org/repo@snapshots</pre> </div> </div> <div class="paragraph"> <p>Repositories on the local machine are supported through <code>file:/</code> URLs.</p> </div> </div> +<div class="sect3"> +<h4 id="_maven_configuration_commands">4.9.2. Maven configuration commands</h4> +<div class="paragraph"> +<p>Full configuration of <code>org.ops4j.pax.url.mvn</code> bundle can be done using <code>org.ops4j.pax.url.mvn</code> PID (see <code>etc/org.ops4j.pax.url.mvn.cfg</code> file). This however may be cumbersome in some scenarios.</p> +</div> +<div class="paragraph"> +<p>In order to make user’s life easier and provide more <em>domain</em> oriented approach, Karaf provides several shell commands that makes Maven configuration easier.</p> +</div> +<div class="sect4"> +<h5 id="_maven_summary">maven:summary</h5> +<div class="paragraph"> +<p>This command shows quick summary about current <code>org.ops4j.pax.url.mvn</code> PID configuration. For example:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> maven:summary -s + +Option â Value â Source +âââââââââââââââââââââââââââ¼âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¼ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ� �ââââââââââââââââââââââ +Local repository â /home/ggrzybek/.m2/repository â Implicit ${user.home}/.m2/repository +Settings file â /home/ggrzybek/.m2/settings.xml â Implicit ${user.home}/.m2/settings.xml +Security settings file â /home/ggrzybek/.m2/settings-security.xml â Implicit ${user.home}/.m2/settings-security.xml +Global update policy â â Implicit "never", but doesn't override repository-specific value +Global checksum policy â warn â Default "warn" +Update releases â false â Default "false" +Require Config Admin â true â BundleContext property (org.ops4j.pax.url.mvn.requireConfigAdminConfig) +Use fallback repository â false â Explicit org.ops4j.pax.url.mvn PID configuration (org.ops4j.pax.url.mvn.useFallbackRepositories) +Offline mode â false â Default "false" +SSL/TLS certificate check â true â Explicit org.ops4j.pax.url.mvn PID configuration (org.ops4j.pax.url.mvn.certificateCheck) +Remote repositories â http://repo1.maven.org/maven2/ â PID configuration + â http://repository.apache.org/content/groups/snapshots-group/ â PID configuration + â https://oss.sonatype.org/content/repositories/snapshots/ â PID configuration + â https://oss.sonatype.org/content/repositories/ops4j-snapshots/ â PID configuration +Default repositories â file:/data/servers/apache-karaf-4.2.0-SNAPSHOT/system/ â PID configuration + â file:/data/servers/apache-karaf-4.2.0-SNAPSHOT/data/kar/ â PID configuration +HTTP proxies â proxy.everfree.forest:3128 â Maven XML settings</code></pre> +</div> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>-s</code> option show where the value of the option come from. It may be implicit, explicit or default. We can also see +whether the value was configured in PID or in <code>settings.xml</code> file.</p> +</li> +<li> +<p><code>-p</code> option uses original option names from <code>org.ops4j.pax.url.mvn</code> PID instead of descriptive option names</p> +</li> +<li> +<p><code>-d</code> option shows additional description, explaining what given option should be used for</p> +</li> +<li> +<p><code>-x</code> option turns on password display - if there’s master password configured, it’ll be displayed in clear text. +This option may be used only by user with <code>admin</code> role.</p> +</li> +</ul> +</div> +</div> +<div class="sect4"> +<h5 id="_maven_repository_list">maven:repository-list</h5> +<div class="paragraph"> +<p>This command displays all configured Maven repositories - in much more readable way than plain <code>config:proplist --pid org.ops4j.pax.url.mvn</code> command does.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> maven:repository-list -v + +== Remote repositories +ID â URL â Releases â Snapshots â Defined in +âââââââââââââââââââââââââââââââââ¼âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¼ââââââââââââââ¼ââââââââââââââ¼âââââââââââ +central â http://repo1.maven.org/maven2/ â yes (daily) â no â PID +apache â http://repository.apache.org/content/groups/snapshots-group/ â no â yes (daily) â PID +sonatype.snapshots.deploy â https://oss.sonatype.org/content/repositories/snapshots/ â no â yes (daily) â PID +ops4j.sonatype.snapshots.deploy â https://oss.sonatype.org/content/repositories/ops4j-snapshots/ â no â yes (daily) â PID +special â https://repository.everfree.forest/ â yes (daily) â no â SETTINGS + +== Default repositories +ID â URL â Releases â Snapshots +âââââââââââââââââââââââââ¼âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¼ââââââââââââââ¼ââââââââââââ +system.repository â file:/data/servers/apache-karaf-4.2.0-SNAPSHOT/system/ â yes (daily) â yes (daily) +kar.repository â file:/data/servers/apache-karaf-4.2.0-SNAPSHOT/data/kar/ â yes (daily) â yes (daily) +child.system.repository â file:/data/servers/apache-karaf-4.2.0-SNAPSHOT/system/ â yes (daily) â yes (daily)</code></pre> +</div> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>-v</code> option shows additional information about policies related to given repository</p> +</li> +<li> +<p><code>-x</code> shows credentials for given repository (if defined)</p> +</li> +</ul> +</div> +</div> +<div class="sect4"> +<h5 id="_maven_password">maven:password</h5> +<div class="paragraph"> +<p><code>org.ops4j.pax.url.mvn</code> bundle uses Aether library to handle Maven resolution. It uses <code>settings.xml</code> file if +credentials have to be used when accessing remote Maven repositories. This isn’t done by <code>org.ops4j.pax.url.mvn</code>, +but by Aether itself (or rather maven-settings library). When dealing with <code>settings.xml</code> file, passwords that +are stored there may need to be decrypted. +Outside of Karaf, we can use <code>mvn -emp</code> and <code>mvn -ep</code> passwords and manually configure <code>~/.m2/settings-security.xml</code> +file.</p> +</div> +<div class="paragraph"> +<p>Karaf makes the task of managing credentials easier.</p> +</div> +<div class="paragraph"> +<p>In order to use encrypted repository (or http proxy) passwords inside <code>settings.xml</code> file, Maven must know the <em>master +password</em> stored inside <code>settings-security.xml</code> file. This file isn’t usually present inside <code>~/.m2</code> directory and if +there’s a need to use it, one has to be created manually.</p> +</div> +<div class="paragraph"> +<p>Here’s the way to encrypt Maven <em>master password</em> (which is used to encrypt ordinary passwords for repository or http proxies):</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> maven:password -emp +Master password to encrypt: ***** +Encrypted master password: {y+p9TiYuwVEHMHV14ej0Ni34zBnXXQrIOqjww/3Ro6U=}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>The above usage simply prints encrypted <em>master password</em>. We can however make this password persistent. This will +result in new <code>settings-security.xml</code> file to be created and change in <code>org.ops4j.pax.url.mvn.security</code> property.</p> +</div> +<div class="admonitionblock note"> +<table> +<tr> +<td class="icon"> +<div class="title">Note</div> +</td> +<td class="content"> +Karaf maven commands will never overwrite your current <code>~/.m2/settings.xml</code> or <code>~/.m2/settings-security.xml</code> files. +If there’s a need to change these files, maven commands will make a copy of existing file and set relevant <code>org.ops4j.pax.url.mvn</code> PID options +to point to new locations. +</td> +</tr> +</table> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> maven:password -emp --persist +Maven security settings will be stored in new file. This file will be used in org.ops4j.pax.url.mvn.security property. Continue? (y/N) y +Master password to encrypt: ***** +Encrypted master password: {lPPIFSUcPrMHnhwdauttAJYZcOe1D9sYGj4rwoaTwnY=} +New security settings stored in "/data/servers/apache-karaf-4.2.0-SNAPSHOT/data/cache/bundle53/data/maven-security-settings-1498120766139.xml" +karaf@root()> maven:summary -x + +Option â Value +âââââââââââââââââââââââââââ¼âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ +... +Security settings file â /data/servers/apache-karaf-4.2.0-SNAPSHOT/data/cache/bundle53/data/maven-security-settings-1498120766139.xml +Master password â admin +...</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Now, when Maven <em>master password</em> is set, we can encrypt ordinary passwords that may be then used when defining/changing +remote repositories or http proxies:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> maven:password -ep +Password to encrypt: ***** +Encrypted password: {fHl8U3pINkEH7RR1CufRT+utj5gJHfqsRgd6wTo92Eo=} +You can use this encrypted password when defining repositories and proxies</code></pre> +</div> +</div> +</div> +<div class="sect4"> +<h5 id="_configuring_repositories_default_and_remote">Configuring repositories (default and remote)</h5> +<div class="paragraph"> +<p>As mentioned before, there are two kinds of repositories that are used/queried by <code>org.ops4j.pax.url.mvn</code> bundle when resolving +<code>mvn:</code> based URIs:</p> +</div> +<div class="dlist"> +<dl> +<dt class="hdlist1">default repositories</dt> +<dd> +<p>These are read-only local repositories that are simply queried before performing any remote access. +The best example of such repository is <code>$KARAF_HOME/system</code> directory.</p> +</dd> +<dt class="hdlist1">remote repositories</dt> +<dd> +<p>These are well-known Maven remote repositories - usually accessible over http(s) protocol. Popular +repositories are Sonatype Nexus or JFrog Artifactory.</p> +</dd> +</dl> +</div> +<div class="paragraph"> +<p>Both kinds of repositories may be created using <code>maven:repository-add</code> command.</p> +</div> +<div class="paragraph"> +<p>Here’s how default repository may be created:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> maven:repository-add --default -id my.default.repository --snapshots '${karaf.home}/special-repository' + +... +== Default repositories +ID â URL â Releases â Snapshots +âââââââââââââââââââââââââ¼âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¼ââââââââââââââ¼ââââââââââââ +... +my.default.repository â file:/data/servers/apache-karaf-4.2.0-SNAPSHOT/special-repository/ â yes (daily) â yes (daily)</code></pre> +</div> +</div> +<div class="paragraph"> +<p>For remote repository, we can specify more options (like credentials or update policies):</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> maven:repository-add -idx 0 -id my.remote.repository --snapshots -up never --username admin --password '{fHl8U3pINkEH7RR1CufRT+utj5gJHfqsRgd6wTo92Eo=}' http://localhost/cloud-repository +Maven settings will be updated and org.ops4j.pax.url.mvn.settings property will change. Continue? (y/N) y +New settings stored in "/data/servers/apache-karaf-4.2.0-SNAPSHOT/data/cache/bundle53/data/maven-settings-1498121385253.xml" + +karaf@root()> maven:repository-list -x + +== Remote repositories +ID â URL â Username â Password +âââââââââââââââââââââââââââââââââ¼âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¼âââââââââââ¼âââââââââ +my.remote.repository â http://localhost/cloud-repository/ â admin â admin +...</code></pre> +</div> +</div> +<div class="paragraph"> +<p>In the above example, new <code>settings.xml</code> file was created. The reason is that although new repository itself was added +to <code>org.ops4j.pax.url.mvn.repositories</code> property, the credentials had to be stored in <code>settings.xml</code> file:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code><servers> + <server> + <username>admin</username> + <password>{fHl8U3pINkEH7RR1CufRT+utj5gJHfqsRgd6wTo92Eo=}</password> + <id>my.remote.repository</id> + </server> +</servers></code></pre> +</div> +</div> +<div class="paragraph"> +<p>Here’s summary of all options for <code>maven:repository-add</code> command:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>-id</code> mandatory identifier of repository</p> +</li> +<li> +<p><code>-d</code> option may be used to configure default repositories instead of remote ones</p> +</li> +<li> +<p><code>-nr</code> option disables non-SNAPSHOT artifacts resolution in this repository</p> +</li> +<li> +<p><code>-s</code> option enables SNAPSHOT artifacts resolution in this repository</p> +</li> +<li> +<p><code>-up</code> sets <em>update policy</em> for given repository (<code>daily</code>, <code>always</code>, <code>never</code>, <code>interval:MINUTES</code>)</p> +</li> +<li> +<p><code>-cp</code> sets <em>checksum policy</em> for given repository (<code>fail</code>, <code>warn</code>, <code>ignore</code>)</p> +</li> +<li> +<p><code>-f</code> disables confirmation prompts for commands</p> +</li> +<li> +<p><code>-idx</code> allows to insert a repository at given position (instead of simply appending new repository at the end of current list of repositories)</p> +</li> +<li> +<p><code>-u</code> sets username for remote repository access</p> +</li> +<li> +<p><code>-p</code> sets password for remote repository access (may be encrypted using <code>maven:password -ep</code>)</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p>After creating a repository, it may be deleted (using <code>maven:repository-remove</code> command) or changed (<code>maven:repository-change</code> command). +All the options are the same as in <code>maven:repository-add</code> command. When removing a repository, only <code>-id</code> (and possibly <code>-d</code>) options are needed.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> repository-remove -d -id my.default.repository +Are you sure to remove repository with ID "my.default.repository" for URL file:/data/servers/apache-karaf-4.2.0-SNAPSHOT/special-repository/? (y/N) y + +karaf@root()> repository-change -id special --username discord --password d1sc0rd +Maven settings will be updated and org.ops4j.pax.url.mvn.settings property will change. Continue? (y/N) y +New settings stored in "/data/servers/apache-karaf-4.2.0-SNAPSHOT/data/cache/bundle53/data/maven-settings-1498122026388.xml"</code></pre> +</div> +</div> +</div> +<div class="sect4"> +<h5 id="_configuring_http_proxies">Configuring HTTP proxies</h5> +<div class="paragraph"> +<p>When accessing remote repositories using <code>org.ops4j.pax.url.mvn</code> (Aether library) there may be a need to let Maven/Aether +know about HTTP proxies to use. HTTP proxies <strong>can’t be configured</strong> inside <code>etc/org.ops4j.pax.url.mvn.cfg</code> file. It has to +be done in <code>settings.xml</code> and its location has to be set in <code>org.ops4j.pax.url.mvn.settings</code> PID property.</p> +</div> +<div class="paragraph"> +<p><code>maven:http-proxy</code> command can be used to add/change/remove HTTP proxy definition. It automatically does a copy +of existing <code>settings.xml</code> file and changes <code>org.ops4j.pax.url.mvn.settings</code> PID property.</p> +</div> +<div class="paragraph"> +<p>For example:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code>karaf@root()> maven:http-proxy-list -x + +ID â Host â Port â Non-proxy hosts â Username â Password +ââââââââââ¼ââââââââââââââââââââââââ¼âââââââ¼ââââââââââââââââââ¼âââââââââââ¼âââââââââââââ +my.proxy â proxy.everfree.forest â 3128 â 192.168.2.* â admin â super-secret + +karaf@root()> maven:http-proxy --remove -id my.proxy +New settings stored in "/data/servers/apache-karaf-4.2.0-SNAPSHOT/data/cache/bundle53/data/maven-settings-1498122255098.xml" + +No HTTP proxies configured in /data/servers/apache-karaf-4.2.0-SNAPSHOT/data/cache/bundle53/data/maven-settings-1498122255098.xml + +karaf@root()> maven:http-proxy --add -id my.proxy --username discord --password '{fHl8U3pINkEH7RR1CufRT+utj5gJHfqsRgd6wTo92Eo=}' --non-proxy-hosts '127.*|192.168.*|localhost' proxy.everfree.forest:3128 +New settings stored in "/data/servers/apache-karaf-4.2.0-SNAPSHOT/data/cache/bundle53/data/maven-settings-1498122328731.xml" + +karaf@root()> maven:http-proxy-list -x + +ID â Host â Port â Non-proxy hosts â Username â Password +ââââââââââ¼ââââââââââââââââââââââââ¼âââââââ¼ââââââââââââââââââââââââââââ¼âââââââââââ¼âââââââââ +my.proxy â proxy.everfree.forest â 3128 â 127.*|192.168.*|localhost â discord â admin</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Here’s summary of options for <code>maven:http-proxy</code> command:</p> +</div> +<div class="ulist"> +<ul> +<li> +<p><code>-id</code> identifier of HTTP proxy</p> +</li> +<li> +<p><code>-add</code> / <code>--change</code> / <code>--remove</code> is an operation to perform on proxy</p> +</li> +<li> +<p><code>-f</code> disables confirmation prompts for commands</p> +</li> +<li> +<p><code>-u</code> sets username for remote HTTP proxy</p> +</li> +<li> +<p><code>-p</code> sets password for remote HTTP proxy (may be encrypted using <code>maven:password -ep</code>)</p> +</li> +<li> +<p><code>-n</code> sets <em>non proxy hosts</em> option, which is <code>|</code>-separated list of glob patterns for IP addresses/host names that should be +accessed bypassing HTTP proxy</p> +</li> +</ul> +</div> +<div class="paragraph"> +<p><code>maven:http-proxy</code> configures for example this section in <code>settings.xml</code>:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight nowrap"><code><proxies> + <proxy> + <username>discord</username> + <password>{fHl8U3pINkEH7RR1CufRT+utj5gJHfqsRgd6wTo92Eo=}</password> + <port>3128</port> + <host>proxy.everfree.forest</host> + <nonProxyHosts>127.*|192.168.*|localhost</nonProxyHosts> + <id>my.proxy</id> + </proxy> +</proxies></code></pre> +</div> +</div> +</div> +</div> </div> <div class="sect2"> <h3 id="_provisioning">4.10. Provisioning</h3> @@ -5779,10 +6540,10 @@ not been previously installed using <cod <div class="ulist"> <ul> <li> -<p><code>featuresRepositories</code> contains a list (coma separated) of features repositories (features XML) URLs.</p> +<p><code>featuresRepositories</code> contains a list (comma-separated) of features repositories (features XML) URLs.</p> </li> <li> -<p><code>featuresBoot</code> contains a list (come separated) of features to install at boot.</p> +<p><code>featuresBoot</code> contains a list (comma-separated) of features to install at boot.</p> </li> </ul> </div> @@ -5800,7 +6561,22 @@ not been previously installed using <cod </div> </div> <div class="sect3"> -<h4 id="_feature_bundles">4.10.7. Feature bundles</h4> +<h4 id="_overrides">4.10.7. Overrides</h4> +<div class="paragraph"> +<p>Bundles defined in features can be overridden by using a file etc/overrides.properties. +Each line in the file defines one override. The syntax is: +<bundle-uri>[;range="[min,max)"] +The given bundle will override all bundles in feature definitions with the same symbolic name if the version +of the override is greater than the version of the overridden bundle and the range matches. +If no range is given then compatibility on the micro version level is assumed.</p> +</div> +<div class="paragraph"> +<p>So for example the override mvn:org.ops4j.pax.logging/pax-logging-service/1.8.5 +would overide pax-logging-service 1.8.3 but not 1.8.6 or 1.7.0.</p> +</div> +</div> +<div class="sect3"> +<h4 id="_feature_bundles">4.10.8. Feature bundles</h4> <div class="sect4"> <h5 id="_start_level">Start Level</h5> <div class="paragraph"> @@ -5858,7 +6634,7 @@ To do so, a feature can specify the <cod </div> </div> <div class="sect3"> -<h4 id="_dependent_features">4.10.8. Dependent features</h4> +<h4 id="_dependent_features">4.10.9. Dependent features</h4> <div class="paragraph"> <p>A feature can depend to a set of other features:</p> </div> @@ -5889,11 +6665,14 @@ To do so, a feature can specify the <cod <p>The feature with the highest version available in the range will be installed.</p> </div> <div class="paragraph"> -<p>If a single version is specified, this version will be chosen.</p> +<p>If a single version is specified, the range will be considered open-ended.</p> </div> <div class="paragraph"> <p>If nothing is specified, the highest available will be installed.</p> </div> +<div class="paragraph"> +<p>To specify an exact version, use a closed range such as <code>[3.1,3.1]</code>.</p> +</div> <div class="sect4"> <h5 id="_feature_prerequisites">Feature prerequisites</h5> <div class="paragraph"> @@ -5902,7 +6681,7 @@ To do so, a feature can specify the <cod </div> </div> <div class="sect3"> -<h4 id="_feature_configurations">4.10.9. Feature configurations</h4> +<h4 id="_feature_configurations">4.10.10. Feature configurations</h4> <div class="paragraph"> <p>The <code><config/></code> element in a feature XML allows a feature to create and/or populate a configuration (identified by a configuration PID).</p> </div> @@ -5924,7 +6703,7 @@ To do so, a feature can specify the <cod </div> </div> <div class="sect3"> -<h4 id="_feature_configuration_files">4.10.10. Feature configuration files</h4> +<h4 id="_feature_configuration_files">4.10.11. Feature configuration files</h4> <div class="paragraph"> <p>Instead of using the <code><config/></code> element, a feature can specify <code><configfile/></code> elements.</p> </div> @@ -5980,7 +6759,7 @@ the features and bundles capabilities an </div> </div> <div class="sect3"> -<h4 id="_commands_3">4.10.11. Commands</h4> +<h4 id="_commands_3">4.10.12. Commands</h4> <div class="sect4"> <h5 id="__code_feature_repo_list_code"><code>feature:repo-list</code></h5> <div class="paragraph"> @@ -6394,7 +7173,7 @@ themselves if not used by other feature. </div> </div> <div class="sect3"> -<h4 id="_deployer">4.10.12. Deployer</h4> +<h4 id="_deployer">4.10.13. Deployer</h4> <div class="paragraph"> <p>You can "hot deploy" a features XML by dropping the file directly in the <code>deploy</code> folder.</p> </div> @@ -6433,7 +7212,7 @@ feature3 won’t be installed:</p> </div> </div> <div class="sect3"> -<h4 id="_jmx_featurembean">4.10.13. JMX FeatureMBean</h4> +<h4 id="_jmx_featurembean">4.10.14. JMX FeatureMBean</h4> <div class="paragraph"> <p>On the JMX layer, you have a MBean dedicated to the management of the features and features repositories: the FeatureMBean.</p> </div> @@ -6664,7 +7443,7 @@ DynamicImport-Package: *</pre> <p>For example <code>my-config-1.0.1.xml</code> will lead to <code>name = my-config</code> and <code>version = 1.0.1</code>.</p> </div> <div class="paragraph"> -<p>The default imported packages are extracted from the spring file definition and includes all classes referenced directly.</p> +<p>The default imported packages are extracted from the blueprint file definition and includes all classes referenced directly.</p> </div> <div class="paragraph"> <p>If you need to customize the generated manifest, you can do so by including an xml element in your blueprint configuration:</p> @@ -7125,6 +7904,9 @@ is supported by the <code>kar:install</c <p>The Apache Karaf KAR service is looking for features XML files in the KAR file, registers the features XML and automatically installs all features described in the features repositories present in the KAR file.</p> </div> +<div class="paragraph"> +<p>Optionally, you can control if the bundles should be automatically started or not using <code>--no-start</code> option.</p> +</div> </div> <div class="sect4"> <h5 id="__code_kar_uninstall_code"><code>kar:uninstall</code></h5> @@ -7190,7 +7972,18 @@ installs all features described in the f # Enable or disable the refresh of the bundles when installing # the features contained in a KAR file # -noAutoRefreshBundles=false</pre> +noAutoRefreshBundles=false + +# +# Enable or disable the automatic start of the bundles when installing +# the features contained in a KAR file +# +noAutoStartBundles=false + +# +# Directory where the kar are stored (when downloaded from Maven for instance) +# +#karStorage=${karaf.data}/kar</pre> </div> </div> <div class="paragraph"> @@ -7220,6 +8013,9 @@ You can disable the automatic bundles re <p><code>install(url)</code> installs the KAR file at the given <code>url</code>.</p> </li> <li> +<p><code>install(url, noAutoStartBundles)</code> installs the KAR file at the given <code>url</code>, deciding if you want to automatically start the bundles or not.</p> +</li> +<li> <p><code>create(repository, features)</code> creates a KAR file using the given features <code>repository</code> name, and optionally the list of <code>features</code> to include in the KAR file.</p> </li> @@ -7870,6 +8666,12 @@ the users and a public key associated to <li> <p>OsgiConfigLoginModule uses a configuration as backend</p> </li> +<li> +<p>Krb5LoginModule uses a Kerberos Server as backend</p> +</li> +<li> +<p>GSSAPILdapLoginModule uses a LDAP server as backend but delegate LDAP server authentication to an other backend (typically Krb5LoginModule)</p> +</li> </ul> </div> <div class="paragraph"> @@ -9235,13 +10037,59 @@ So it is much more convenient than regis </li> </ul> </div> -<div class="sect4"> -<h5 id="_configuration_4">Configuration</h5> -<div class="paragraph"> -<p>The default port used by the WebContainer is 8181.</p> +<div class="sect4"> +<h5 id="_configuration_4">Configuration</h5> +<div class="paragraph"> +<p>The default port used by the WebContainer is 8181. Note: the connector is actually bound only when at least a servlet or webapplication is using it. +It means that just installing the <code>http</code> or <code>war</code> feature doesn’t bind the connector.</p> +</div> +<div class="paragraph"> +<p>By default, Karaf creates an internal Jetty connector that you can configure via <code>etc/org.ops4j.pax.web.cfg</code>:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight"><code>org.osgi.service.http.port=8181</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Note: if you want to use port numbers < 1024, remember you have to run with root privileges.</p> +</div> +<div class="paragraph"> +<p>It’s possible to enable HTTPs "internal" connector. The first step is to create a keystore containing a server certificate. +For instance the following command creates a keystore with a self-signed certificate:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight"><code>keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore -storepass karaf1234 -validity 360 -keysize 2048</code></pre> +</div> +</div> +<div class="paragraph"> +<p>Now, we can enable and configure the HTTPs connector with this keystore in <code>etc/org.ops4j.pax.web.cfg</code>:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight"><code>org.osgi.service.http.port.secure=8443 +org.osgi.service.http.secure.enabled=true +org.ops4j.pax.web.ssl.keystore=/path/to/keystore +org.ops4j.pax.web.ssl.password=foo +org.ops4j.pax.web.ssl.keypassword=karaf1234</code></pre> +</div> +</div> +<div class="paragraph"> +<p>It’s possible to use only HTTPs and to disable the HTTP using:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight"><code>org.osgi.service.http.enabled=false</code></pre> +</div> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight"><code>org.osgi.service.https.enabled=true</code></pre> +</div> </div> <div class="paragraph"> -<p>The WebContainer configuration is in the <code>etc/jetty.xml</code> configuration file.</p> +<p>As an alternative to the default connectors, it is possible to configure additional connectors in the <code>etc/jetty.xml</code> configuration file.</p> </div> <div class="paragraph"> <p>The <code>etc/jetty.xml</code> is a standard Eclipse Jetty configuration file.</p> @@ -10200,7 +11048,7 @@ OPTIONS </div> <div class="listingblock"> <div class="content"> -<pre>karaf@root()> jdbc:ds-create -dn derby -dbName test -url jdbc:derby:test test</pre> +<pre>karaf@root()> jdbc:ds-create -dn derby -url "jdbc:derby:test;create=true" test</pre> </div> </div> <div class="paragraph"> @@ -11926,7 +12774,7 @@ Enter host password for user 'karaf': For instance, Apache Karaf Cellar provides additional pages to administrate cluster groups, nodes, etc.</p> </div> <div class="sect3"> -<h4 id="_installation_4">4.18.1. Installation</h4> +<h4 id="_installation_3">4.18.1. Installation</h4> <div class="paragraph"> <p>To enable the Apache Karaf WebConsole, you just have to install the <code>webconsole</code> feature:</p> </div> @@ -11978,9 +12826,222 @@ Right now, the WebConsole doesn’t </div> </div> <div class="sect2"> -<h3 id="_tuning">4.19. Tuning</h3> +<h3 id="_scheduler">4.19. Scheduler</h3> +<div class="paragraph"> +<p>Apache Karaf provides an optional Scheduler which provides a Service Listener which listens for Runnable Services and schedules their execution, based on the service properties.</p> +</div> +<div class="paragraph"> +<p>This Scheduler implementation uses the Quartz Scheduler library to understand cron-like expressions.</p> +</div> +<div class="sect3"> +<h4 id="_installation_4">4.19.1. Installation</h4> +<div class="paragraph"> +<p>To enable the Apache Karaf Scheduler, you just have to install the <code>scheduler</code> feature:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>karaf@root()> feature:install scheduler</pre> +</div> +</div> +<div class="paragraph"> +<p>The <code>scheduler</code> feature automatically installs the <code>scheduler</code> Gogo command group, too:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>scheduler:list +scheduler:schedule +scheduler:unschedule</pre> +</div> +</div> +</div> +<div class="sect3"> +<h4 id="_configuration_7">4.19.2. Configuration</h4> +<div class="paragraph"> +<p>All jobs allow configuration using service properties:</p> +</div> +<table class="tableblock frame-all grid-all spread"> +<caption class="title">Table 1. Scheduler properties</caption> +<colgroup> +<col style="width: 20%;"> +<col style="width: 13%;"> +<col style="width: 66%;"> +</colgroup> +<thead> +<tr> +<th class="tableblock halign-left valign-top">Property</th> +<th class="tableblock halign-left valign-top">Default</th> +<th class="tableblock halign-left valign-top">Description</th> +</tr> +</thead> +<tbody> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">Scheduler.PROPERTY_SCHEDULER_PERIOD</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">-</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Defines the period for a job. The period is expressed in seconds. This property needs to be of type Long.</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">Scheduler.PROPERTY_SCHEDULER_IMMEDIATE</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Define if a periodically job should be scheduled immediate. +Default is to not startup immediate, the job is started the first time after the period has expired. +This property needs to be of type Boolean.</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">Scheduler.PROPERTY_SCHEDULER_EXPRESSION</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">-</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Define the cron expression for a job. Must be a Quartz compatible expression.</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">Scheduler.PROPERTY_SCHEDULER_CONCURRENT</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">-</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Define if the job can be run concurrently.</p></td> +</tr> +<tr> +<td class="tableblock halign-left valign-top"><p class="tableblock">Scheduler.PROPERTY_SCHEDULER_NAME</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">-</p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">Define the job name.</p></td> +</tr> +</tbody> +</table> +</div> +<div class="sect3"> +<h4 id="_schedule_a_new_job_using_the_whitebox_service_paradigm_recommended">4.19.3. Schedule a new Job using the Whitebox-Service paradigm (recommended)</h4> +<div class="paragraph"> +<p>This example uses Declarative Services to register a Service of Type "org.apache.karaf.scheduler.Job" so that it is recognized by the Scheduler Service.</p> +</div> +<div class="paragraph"> +<p>Alternatively, jobs can be registered as type "Runnable" in a more API neutral way. In this case you won’t get the "JobContext" information though.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>@Component(immediate = true, property = { + Scheduler.PROPERTY_SCHEDULER_EXPRESSION + "=0 0/10 * * * ?", +} ) +public class SchedulerPing implements Job { + + @Override + public void execute(JobContext context) { + // .. + } +}</pre> +</div> +</div> +<div class="paragraph"> +<p>This will register a Job with the WhiteboxHandler. You can verify that the job is registered:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>karaf@root()> scheduler:list +Name â Schedule +ââââââââââââââââââââââââ¼âââââââââââââââââââââ +Registered Service.185 â cron(0 0/10 * * * ?)</pre> +</div> +</div> +<div class="paragraph"> +<p>The Karaf scheduler can also schedule <code>Runnable</code> service.</p> +</div> +<div class="paragraph"> +<p>For instance, if you have the following bean:</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre class="CodeRay highlight"><code>@Component(immediate = true, property = { + "scheduler.period:Long=60", + "scheduler.concurrent:Boolean=false", + "scheduler.name=PingJob" + } +) +public class PingThread implements Runnable { + + @Override + public void run() { + // .. + } + +}</code></pre> +</div> +</div> +<div class="paragraph"> +<p>This will register a job for the thread (runnable):</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>karaf@root()> scheduler:list +Name â Schedule +ââââââââââââââââââââââââââââ¼ââââââââââââââââââââââââââââââââââââââââââ +PingJob.126 â at(2017-11-22T15:37:17.103+01:00, -1, 10)</pre> +</div> +</div> +</div> +<div class="sect3"> +<h4 id="_schedule_a_new_job_using_the_gogo_shell">4.19.4. Schedule a new Job using the Gogo Shell</h4> +<div class="listingblock"> +<div class="content"> +<pre>karaf@root()> scheduler:schedule --help +DESCRIPTION + scheduler:schedule + + Schedule a script execution + +SYNTAX + scheduler:schedule [options] script + +ARGUMENTS + script + The script to schedule + +OPTIONS + --at + Absolute date in ISO format (ex: 2014-05-13T13:56:45) + --concurrent + Should jobs run concurrently or not (defaults to false) + --period + Time during executions (in seconds) + --times + Number of times this job should be executed + (defaults to -1) + --cron + The cron expression + --help + Display this help message + --name + Name of this job</pre> +</div> +</div> +</div> +<div class="sect3"> +<h4 id="_schedule_a_new_job_using_the_scheduler_service">4.19.5. Schedule a new Job using the Scheduler Service</h4> +<div class="paragraph"> +<p>Recommendation: Before using this low level api for registering jobs, consider using the whitebox approach instead.</p> +</div> +<div class="listingblock"> +<div class="content"> +<pre>.. +import org.apache.karaf.scheduler.Scheduler; + +@Component +public class Demo { + + @Reference Scheduler scheduler; + + public void useScheduler() + { + schedule(new MyJob(), scheduler.EXPR("0 0/10 * * * ?")); + } + + class MyJob implements Job { + .. + } + +}</pre> +</div> +</div> +</div> +</div> +<div class="sect2"> +<h3 id="_tuning">4.20. Tuning</h3> <div class="sect3"> -<h4 id="_garbage_collection">4.19.1. Garbage Collection</h4> +<h4 id="_garbage_collection">4.20.1. Garbage Collection</h4> <div class="paragraph"> <p>Like any Java applications, Apache Karaf uses a JVM. An important feature of the JVM is the Garbage Collector.</p> </div> @@ -12004,9 +13065,6 @@ Right now, the WebConsole doesn’t <li> <p><code>-XX:+UnlockDiagnosticVMOptions</code></p> </li> -<li> -<p><code>-XX:+UnsyncloadClass</code></p> -</li> </ul> </div> <div class="paragraph"> @@ -12106,7 +13164,7 @@ memory leaks, and see the possible optim </div> </div> <div class="sect3"> -<h4 id="_threads">4.19.2. Threads</h4> +<h4 id="_threads">4.20.2. Threads</h4> <div class="paragraph"> <p>In high loaded system, the number of threads can be very large.</p> </div> @@ -12214,7 +13272,7 @@ to all workqueues (a workqueue can be as </div> </div> <div class="sect3"> -<h4 id="_system_packages">4.19.3. System packages</h4> +<h4 id="_system_packages">4.20.3. System packages</h4> <div class="paragraph"> <p>The <code>etc/jre.properties</code> defines the packages directly provided by the JVM.</p> </div> @@ -13577,7 +14635,7 @@ Define value for package: : org.apache.k <dependencies> <dependency> <groupId>org.apache.karaf.shell</groupId> - <artifactId>org.apache.karaf.shell.console</artifactId> + <artifactId>org.apache.karaf.shell.core</artifactId> <version>${project.version}</version> </dependency> <dependency> @@ -13613,7 +14671,7 @@ Define value for package: : org.apache.k </div> </div> <div class="sect4"> -<h5 id="_configuring_for_java_6_7">Configuring for Java 6/7</h5> +<h5 id="_configuring_for_java_8">Configuring for Java 8</h5> <div class="paragraph"> <p>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 <code>dependencies</code> section.</p> @@ -13626,8 +14684,8 @@ Just add the following snippet after the <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <target>1.6</target> - <source>1.6</source> + <target>1.8</target> + <source>1.8</source> </configuration> </plugin> </plugins> @@ -13819,7 +14877,7 @@ public class SimpleNameCompleter impleme delegate.getStrings().add("Mike"); delegate.getStrings().add("Eric"); delegate.getStrings().add("Jenny"); - return delegate.complete(buffer, cursor, candidates); + return delegate.complete(session, commandLine, candidates); } }</pre> @@ -13977,11 +15035,11 @@ Those two objects are given to the Compl <tbody> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock">feature</p></td> -<td class="tableblock halign-left valign-top"><p class="tableblock">The feature packaging generates a features.xml descriptor using the <code>karaf:features-generate-descriptor</code></p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">The feature packaging verifies a features.xml descriptor using the <code>karaf:verify</code> goal.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock">kar</p></td> -<td class="tableblock halign-left valign-top"><p class="tableblock">The kar packaging generates a features.xml descriptor using the <code>karaf:features-generate-descriptor</code> and then packages a kar using the <code>karaf:features-create-kar</code></p></td> +<td class="tableblock halign-left valign-top"><p class="tableblock">The kar packaging generates a features.xml descriptor using the <code>karaf:features-generate-descriptor</code> and then packages a kar using the <code>karaf:features-create-kar</code> goal.</p></td> </tr> <tr> <td class="tableblock halign-left valign-top"><p class="tableblock">karaf-assembly</p></td> @@ -14096,9 +15154,6 @@ option in the Karaf shell console.</p> <div class="sect4"> <h5 id="__code_karaf_features_generate_descriptor_code"><code>karaf:features-generate-descriptor</code></h5> <div class="paragraph"> -<p>Except in unusual circumstances, use the <code><packaging>feature</packaging></code> to run this goal.</p> -</div> -<div class="paragraph"> <p>The <code>karaf:features-generate-descriptor</code> goal generates a features XML file based on the Maven dependencies. By default, it will follow Maven transitive dependencies, stopping when it encounters bundles already present in features that are Maven dependencies.</p> </div> @@ -14109,7 +15164,7 @@ By default, it will follow Maven transit <p>You can track dependency changes and warn or fail on change.</p> </div> <div class="sect5"> -<h6 id="_configuration_7">Configuration</h6> +<h6 id="_configuration_8">Configuration</h6> <div class="paragraph"> <p>Specify the packaging as a top level element</p> </div> @@ -14197,11 +15252,19 @@ This can be overridden by specifying the <artifactId>karaf-maven-plugin</artifactId> <version>${project.version}</version> <extensions>true</extensions> - <configuration> - <startLevel>80</startLevel> - <aggregateFeatures>true</aggregateFeatures> - </configuration> - </plugin> + <configuration> + <enableGeneration>true</enableGeneration> + </configuration> + <executions> + <execution> + <id>generate-features-file</id> + <phase>generate-resources</phase> + <goals> + <goal>features-generate-descriptor</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> </project></pre> @@ -14212,6 +15275,9 @@ This can be overridden by specifying the <div class="sect4"> <h5 id="__code_karaf_verify_code"><code>karaf:verify</code></h5> <div class="paragraph"> +<p>Except in unusual circumstances, use the <code><packaging>feature</packaging></code> to run this goal.</p> +</div> +<div class="paragraph"> <p>The <code>karaf:verify</code> goal verifies and validates a features XML descriptor by checking if all the required imports for the bundles defined in the features can be matched to a provided export.</p> </div> @@ -14231,32 +15297,32 @@ It reads the definition for the packages <pre><project> <build> <plugins> - <plugin> - <groupId>org.apache.karaf.tooling</groupId> - <artifactId>karaf-maven-plugin</artifactId>
[... 278 lines stripped ...]
