You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@commons.apache.org by ma...@apache.org on 2022/11/29 11:56:52 UTC
svn commit: r1081664 [8/10] - in /websites/production/commons/content/proper/commons-daemon: ./ apidocs/ apidocs/jquery/ apidocs/jquery/images/ apidocs/org/apache/commons/daemon/ apidocs/org/apache/commons/daemon/class-use/ apidocs/org/apache/commons/d...
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonConfiguration.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonConfiguration.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonConfiguration.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonConfiguration</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.html" class="el_package">org.apache.commons.daemon.support</a> > <span class="el_class">DaemonConfiguration</span></div><h1>DaemonConfiguration</h1><table class="coverage" cellspa
cing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">206 of 206</td><td class="ctr2">0%</td><td class="bar">20 of 20</td><td class="ctr2">0%</td><td class="ctr1"
>16</td><td class="ctr2">16</td><td class="ctr1">47</td><td class="ctr2">47</td><td class="ctr1">6</td><td class="ctr2">6</td></tr></tfoot><tbody><tr><td id="a1"><a href="DaemonConfiguration.java.html#L107" class="el_method">expandProperty(String)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="118" alt="118"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="14" alt="14"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">8</td><td class="ctr2" id="g0">8</td><td class="ctr1" id="h0">27</td><td class="ctr2" id="i0">27</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a3"><a href="DaemonConfiguration.java.html#L186" class="el_method">getPropertyArray(String)</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="32" height="10" title="32" alt="32"/></td><td class="ctr2" id="c1
">0%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="2" alt="2"/></td><td class="ctr2" id="e1">0%</td><td class="ctr1" id="f1">2</td><td class="ctr2" id="g1">2</td><td class="ctr1" id="h2">4</td><td class="ctr2" id="i2">4</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a4"><a href="DaemonConfiguration.java.html#L88" class="el_method">load(String)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="23" height="10" title="23" alt="23"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d2"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="2" alt="2"/></td><td class="ctr2" id="e2">0%</td><td class="ctr1" id="f2">2</td><td class="ctr2" id="g2">2</td><td class="ctr1" id="h1">8</td><td class="ctr2" id="i1">8</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a2"><a href="DaemonConfiguration.java.html#L160" class="el
_method">getProperty(String)</a></td><td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="18" height="10" title="18" alt="18"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d3"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="2" alt="2"/></td><td class="ctr2" id="e3">0%</td><td class="ctr1" id="f3">2</td><td class="ctr2" id="g3">2</td><td class="ctr1" id="h4">3</td><td class="ctr2" id="i4">3</td><td class="ctr1" id="j3">1</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a0"><a href="DaemonConfiguration.java.html#L75" class="el_method">DaemonConfiguration()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/redbar.gif" width="11" height="10" title="11" alt="11"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">1</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h3">4</td><td class="ctr2" id="i3">4</td><td class="ctr1" id="j4">1</td><td class
="ctr2" id="k4">1</td></tr><tr><td id="a5"><a href="DaemonConfiguration.java.html#L69" class="el_method">static {...}</a></td><td class="bar" id="b5"><img src="../jacoco-resources/redbar.gif" width="4" height="10" title="4" alt="4"/></td><td class="ctr2" id="c5">0%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">1</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h5">1</td><td class="ctr2" id="i5">1</td><td class="ctr1" id="j5">1</td><td class="ctr2" id="k5">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
\ No newline at end of file
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonConfiguration.java.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonConfiguration.java.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonConfiguration.java.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonConfiguration.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.source.html" class="el_package">org.apache.commons.daemon.support</a> > <span c
lass="el_source">DaemonConfiguration.java</span></div><h1>DaemonConfiguration.java</h1><pre class="source lang-java linenums">/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.daemon.support;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.text.ParseException;
+
+/**
+ * Used by jsvc for Daemon configuration.
+ * <p>
+ * Configuration is read from properties file.
+ * If no properties file is given the {@code daemon.properties}
+ * is used from the current directory.
+ * </p>
+ * <p>
+ * The properties file can have property values expanded at runtime
+ * by using System properties or execution environment. The part
+ * of the property value between {@code ${} and {@code }}
+ * will be used as System property or environment key. If found then
+ * the entire {@code ${foo}} will be replaced by the value of
+ * either system property or environment variable named {@code foo}.
+ * </p>
+ * <p>
+ * If no variable is found the {@code ${foo}} will be passed as is.
+ * In case of {@code $${foo}} this will be unescaped and resulting
+ * value will be {@code ${foo}}.
+ * </p>
+ *
+ */
+public final class DaemonConfiguration
+{
+ /**
+ * Default configuration file name.
+ */
+ protected final static String DEFAULT_CONFIG = "daemon.properties";
+ /**
+ * Property prefix
+ */
+ protected final static String PREFIX = "daemon.";
+ private final static String BTOKEN = "${";
+ private final static String ETOKEN = "}";
+
+
+ private final Properties configurationProperties;
+ private final Properties systemProperties;
+
+ /**
+ * An empty immutable {@code String} array.
+ */
+<span class="nc" id="L69"> static final String[] EMPTY_STRING_ARRAY = {};</span>
+
+ /**
+ * Default constructor
+ */
+ public DaemonConfiguration()
+<span class="nc" id="L75"> {</span>
+<span class="nc" id="L76"> configurationProperties = new Properties();</span>
+<span class="nc" id="L77"> systemProperties = System.getProperties();</span>
+<span class="nc" id="L78"> }</span>
+
+ /**
+ * Loads the configuration properties file.
+ *
+ * @param fileName The properties file to load.
+ * @return {@code true} if the file was loaded.
+ */
+ public boolean load(String fileName)
+ {
+<span class="nc bnc" id="L88" title="All 2 branches missed."> if (fileName == null) {</span>
+<span class="nc" id="L89"> fileName = DEFAULT_CONFIG;</span>
+ }
+
+<span class="nc" id="L92"> try (InputStream inputStream = new FileInputStream(fileName)) {</span>
+<span class="nc" id="L93"> configurationProperties.clear();</span>
+<span class="nc" id="L94"> configurationProperties.load(inputStream);</span>
+<span class="nc" id="L95"> return true;</span>
+<span class="nc" id="L96"> } catch (final IOException ex) {</span>
+ // Error reading properties file
+<span class="nc" id="L98"> return false;</span>
+ }
+ }
+
+ private String expandProperty(final String propValue)
+ throws ParseException
+ {
+ final StringBuilder expanded;
+ int btoken;
+<span class="nc" id="L107"> int ctoken = 0;</span>
+
+<span class="nc bnc" id="L109" title="All 2 branches missed."> if (propValue == null) {</span>
+<span class="nc" id="L110"> return null;</span>
+ }
+<span class="nc" id="L112"> expanded = new StringBuilder();</span>
+<span class="nc" id="L113"> btoken = propValue.indexOf(BTOKEN);</span>
+<span class="nc bnc" id="L114" title="All 2 branches missed."> while (btoken != -1) {</span>
+<span class="nc bnc" id="L115" title="All 4 branches missed."> if (btoken > 0 && propValue.charAt(btoken - 1) == BTOKEN.charAt(0)) {</span>
+ // Skip and unquote.
+<span class="nc" id="L117"> expanded.append(propValue.substring(ctoken, btoken));</span>
+<span class="nc" id="L118"> ctoken = btoken + 1;</span>
+<span class="nc" id="L119"> btoken = propValue.indexOf(BTOKEN, btoken + BTOKEN.length());</span>
+<span class="nc" id="L120"> continue;</span>
+ }
+<span class="nc" id="L122"> final int etoken = propValue.indexOf(ETOKEN, btoken);</span>
+<span class="nc bnc" id="L123" title="All 2 branches missed."> if (etoken == -1) {</span>
+ // We have "${" without "}"
+<span class="nc" id="L125"> throw new ParseException("Error while looking for teminating '" +</span>
+ ETOKEN + "'", btoken);
+ }
+<span class="nc" id="L128"> final String variable = propValue.substring(btoken + BTOKEN.length(), etoken);</span>
+<span class="nc" id="L129"> String sysvalue = systemProperties.getProperty(variable);</span>
+<span class="nc bnc" id="L130" title="All 2 branches missed."> if (sysvalue == null) {</span>
+ // Try with the environment if there was no
+ // property by that name.
+<span class="nc" id="L133"> sysvalue = System.getenv(variable);</span>
+ }
+<span class="nc bnc" id="L135" title="All 2 branches missed."> if (sysvalue != null) {</span>
+<span class="nc" id="L136"> final String strtoken = propValue.substring(ctoken, btoken);</span>
+<span class="nc" id="L137"> expanded.append(strtoken);</span>
+<span class="nc" id="L138"> expanded.append(sysvalue);</span>
+<span class="nc" id="L139"> ctoken = etoken + ETOKEN.length();</span>
+ }
+<span class="nc" id="L141"> btoken = propValue.indexOf(BTOKEN, etoken + ETOKEN.length());</span>
+<span class="nc" id="L142"> }</span>
+ // Add what's left.
+<span class="nc" id="L144"> expanded.append(propValue.substring(ctoken));</span>
+<span class="nc" id="L145"> return expanded.toString();</span>
+ }
+
+ /**
+ * Gets the configuration property.
+ *
+ * @param name The name of the property to get.
+ *
+ * @throws ParseException if the property is wrongly formatted.
+ *
+ * @return Configuration property including any expansion/replacement
+ */
+ public String getProperty(final String name)
+ throws ParseException
+ {
+<span class="nc bnc" id="L160" title="All 2 branches missed."> if (name == null) {</span>
+<span class="nc" id="L161"> return null;</span>
+ }
+<span class="nc" id="L163"> return expandProperty(configurationProperties.getProperty(PREFIX + name));</span>
+ }
+
+ /**
+ * Gets the configuration property array.
+ * <p>
+ * Property array is constructed form the list of properties
+ * which end with {@code [index]}
+ * </p>
+ * <pre>
+ * daemon.arg[0] = argument 1
+ * daemon.arg[1] = argument 2
+ * daemon.arg[2] = argument 3
+ * </pre>
+ * @param name The name of the property array to get.
+ *
+ * @throws ParseException if the property is wrongly formatted.
+ *
+ * @return Configuration property array including any expansion/replacement
+ */
+ public String[] getPropertyArray(final String name)
+ throws ParseException
+ {
+<span class="nc" id="L186"> final ArrayList<String> list = new ArrayList<>();</span>
+ String args;
+
+ // Load daemon.arg[0] ... daemon.arg[n] into the String array.
+ //
+<span class="nc bnc" id="L191" title="All 2 branches missed."> while ((args = getProperty(name + "[" + list.size() + "]")) != null) {</span>
+<span class="nc" id="L192"> list.add(args);</span>
+ }
+<span class="nc" id="L194"> return list.toArray(EMPTY_STRING_ARRAY);</span>
+ }
+}
+
+</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
\ No newline at end of file
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader$Context.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader$Context.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader$Context.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonLoader.Context</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.html" class="el_package">org.apache.commons.daemon.support</a> > <span class="el_class">DaemonLoader.Context</span></div><h1>DaemonLoader.Context</h1><table class="coverage" cell
spacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">17 of 17</td><td class="ctr2">0%</td><td class="bar">0 of 0</td><td class="ctr2">n/a</td><td class="ctr1"
>5</td><td class="ctr2">5</td><td class="ctr1">7</td><td class="ctr2">7</td><td class="ctr1">5</td><td class="ctr2">5</td></tr></tfoot><tbody><tr><td id="a4"><a href="DaemonLoader.java.html#L399" class="el_method">setController(DaemonController)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="4" alt="4"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"/><td class="ctr2" id="e0">n/a</td><td class="ctr1" id="f0">1</td><td class="ctr2" id="g0">1</td><td class="ctr1" id="h0">2</td><td class="ctr2" id="i0">2</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a3"><a href="DaemonLoader.java.html#L410" class="el_method">setArguments(String[])</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="4" alt="4"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d1"/><td class="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">1</td><td class=
"ctr2" id="g1">1</td><td class="ctr1" id="h1">2</td><td class="ctr2" id="i1">2</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a0"><a href="DaemonLoader.java.html#L383" class="el_method">DaemonLoader.Context()</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="90" height="10" title="3" alt="3"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">1</td><td class="ctr2" id="i2">1</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a2"><a href="DaemonLoader.java.html#L394" class="el_method">getController()</a></td><td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="90" height="10" title="3" alt="3"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">1</td><td class="ctr2" id=
"g3">1</td><td class="ctr1" id="h3">1</td><td class="ctr2" id="i3">1</td><td class="ctr1" id="j3">1</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a1"><a href="DaemonLoader.java.html#L405" class="el_method">getArguments()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/redbar.gif" width="90" height="10" title="3" alt="3"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">1</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">1</td><td class="ctr2" id="i4">1</td><td class="ctr1" id="j4">1</td><td class="ctr2" id="k4">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
\ No newline at end of file
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader$Controller.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader$Controller.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader$Controller.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonLoader.Controller</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.html" class="el_package">org.apache.commons.daemon.support</a> > <span class="el_class">DaemonLoader.Controller</span></div><h1>DaemonLoader.Controller</h1><table class="cover
age" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">116 of 116</td><td class="ctr2">0%</td><td class="bar">8 of 8</td><td class="ctr2">0%</td><td cl
ass="ctr1">13</td><td class="ctr2">13</td><td class="ctr1">39</td><td class="ctr2">39</td><td class="ctr1">9</td><td class="ctr2">9</td></tr></tfoot><tbody><tr><td id="a4"><a href="DaemonLoader.java.html#L366" class="el_method">fail(String, Exception)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="35" alt="35"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="4" alt="4"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">3</td><td class="ctr2" id="g0">3</td><td class="ctr1" id="h0">10</td><td class="ctr2" id="i0">10</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a8"><a href="DaemonLoader.java.html#L323" class="el_method">shutdown()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="68" height="10" title="20" alt="20"/></td><td class="ctr2" id="c1">0%</td><td class="b
ar" id="d1"><img src="../jacoco-resources/redbar.gif" width="60" height="10" title="2" alt="2"/></td><td class="ctr2" id="e1">0%</td><td class="ctr1" id="f1">2</td><td class="ctr2" id="g1">2</td><td class="ctr1" id="h1">7</td><td class="ctr2" id="i1">7</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a6"><a href="DaemonLoader.java.html#L336" class="el_method">reload()</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="68" height="10" title="20" alt="20"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d2"><img src="../jacoco-resources/redbar.gif" width="60" height="10" title="2" alt="2"/></td><td class="ctr2" id="e2">0%</td><td class="ctr1" id="f2">2</td><td class="ctr2" id="g2">2</td><td class="ctr1" id="h2">7</td><td class="ctr2" id="i2">7</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a7"><a href="DaemonLoader.java.html#L314" class="el_method">setAvailable(boolean)</a></td
><td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="37" height="10" title="11" alt="11"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f3">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">4</td><td class="ctr2" id="i3">4</td><td class="ctr1" id="j3">1</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a5"><a href="DaemonLoader.java.html#L307" class="el_method">isAvailable()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/redbar.gif" width="30" height="10" title="9" alt="9"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">1</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h5">2</td><td class="ctr2" id="i5">2</td><td class="ctr1" id="j4">1</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a0"><a href="DaemonLoader.java.html#L301" class="el_method">DaemonLoader.Controller()</a></td><td cl
ass="bar" id="b5"><img src="../jacoco-resources/redbar.gif" width="20" height="10" title="6" alt="6"/></td><td class="ctr2" id="c5">0%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">1</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h4">3</td><td class="ctr2" id="i4">3</td><td class="ctr1" id="j5">1</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a1"><a href="DaemonLoader.java.html#L348" class="el_method">fail()</a></td><td class="bar" id="b6"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="5" alt="5"/></td><td class="ctr2" id="c6">0%</td><td class="bar" id="d6"/><td class="ctr2" id="e6">n/a</td><td class="ctr1" id="f6">1</td><td class="ctr2" id="g6">1</td><td class="ctr1" id="h6">2</td><td class="ctr2" id="i6">2</td><td class="ctr1" id="j6">1</td><td class="ctr2" id="k6">1</td></tr><tr><td id="a3"><a href="DaemonLoader.java.html#L354" class="el_method">fail(String)</a></td><td class="bar" id="b7"><img src=".
./jacoco-resources/redbar.gif" width="17" height="10" title="5" alt="5"/></td><td class="ctr2" id="c7">0%</td><td class="bar" id="d7"/><td class="ctr2" id="e7">n/a</td><td class="ctr1" id="f7">1</td><td class="ctr2" id="g7">1</td><td class="ctr1" id="h7">2</td><td class="ctr2" id="i7">2</td><td class="ctr1" id="j7">1</td><td class="ctr2" id="k7">1</td></tr><tr><td id="a2"><a href="DaemonLoader.java.html#L360" class="el_method">fail(Exception)</a></td><td class="bar" id="b8"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="5" alt="5"/></td><td class="ctr2" id="c8">0%</td><td class="bar" id="d8"/><td class="ctr2" id="e8">n/a</td><td class="ctr1" id="f8">1</td><td class="ctr2" id="g8">1</td><td class="ctr1" id="h8">2</td><td class="ctr2" id="i8">2</td><td class="ctr1" id="j8">1</td><td class="ctr2" id="k8">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></di
v></body></html>
\ No newline at end of file
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonLoader</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.html" class="el_package">org.apache.commons.daemon.support</a> > <span class="el_class">DaemonLoader</span></div><h1>DaemonLoader</h1><table class="coverage" cellspacing="0" id="coverage
table"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">416 of 416</td><td class="ctr2">0%</td><td class="bar">24 of 24</td><td class="ctr2">0%</td><td class="ctr1">20</td><td class="ct
r2">20</td><td class="ctr1">120</td><td class="ctr2">120</td><td class="ctr1">8</td><td class="ctr2">8</td></tr></tfoot><tbody><tr><td id="a3"><a href="DaemonLoader.java.html#L118" class="el_method">load(String, String[])</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="200" alt="200"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="14" alt="14"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">8</td><td class="ctr2" id="g0">8</td><td class="ctr1" id="h0">59</td><td class="ctr2" id="i0">59</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a7"><a href="DaemonLoader.java.html#L46" class="el_method">version()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="49" height="10" title="82" alt="82"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d5"/><td class="ctr2
" id="e5">n/a</td><td class="ctr1" id="f5">1</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h2">13</td><td class="ctr2" id="i2">13</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a0"><a href="DaemonLoader.java.html#L67" class="el_method">check(String)</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="25" height="10" title="42" alt="42"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d1"><img src="../jacoco-resources/redbar.gif" width="34" height="10" title="4" alt="4"/></td><td class="ctr2" id="e1">0%</td><td class="ctr1" id="f1">3</td><td class="ctr2" id="g1">3</td><td class="ctr1" id="h1">14</td><td class="ctr2" id="i1">14</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a4"><a href="DaemonLoader.java.html#L101" class="el_method">signal()</a></td><td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="18" height="10" title="30" alt="30"/></td><td
class="ctr2" id="c3">0%</td><td class="bar" id="d2"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="2" alt="2"/></td><td class="ctr2" id="e2">0%</td><td class="ctr1" id="f2">2</td><td class="ctr2" id="g2">2</td><td class="ctr1" id="h3">9</td><td class="ctr2" id="i3">9</td><td class="ctr1" id="j3">1</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a5"><a href="DaemonLoader.java.html#L235" class="el_method">start()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/redbar.gif" width="12" height="10" title="20" alt="20"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d3"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="2" alt="2"/></td><td class="ctr2" id="e3">0%</td><td class="ctr1" id="f3">2</td><td class="ctr2" id="g3">2</td><td class="ctr1" id="h4">8</td><td class="ctr2" id="i4">8</td><td class="ctr1" id="j4">1</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a6"><a href="DaemonLoader.java.html#L256" class="e
l_method">stop()</a></td><td class="bar" id="b5"><img src="../jacoco-resources/redbar.gif" width="12" height="10" title="20" alt="20"/></td><td class="ctr2" id="c5">0%</td><td class="bar" id="d4"><img src="../jacoco-resources/redbar.gif" width="17" height="10" title="2" alt="2"/></td><td class="ctr2" id="e4">0%</td><td class="ctr1" id="f4">2</td><td class="ctr2" id="g4">2</td><td class="ctr1" id="h5">8</td><td class="ctr2" id="i5">8</td><td class="ctr1" id="j5">1</td><td class="ctr2" id="k5">1</td></tr><tr><td id="a2"><a href="DaemonLoader.java.html#L277" class="el_method">destroy()</a></td><td class="bar" id="b6"><img src="../jacoco-resources/redbar.gif" width="11" height="10" title="19" alt="19"/></td><td class="ctr2" id="c6">0%</td><td class="bar" id="d6"/><td class="ctr2" id="e6">n/a</td><td class="ctr1" id="f6">1</td><td class="ctr2" id="g6">1</td><td class="ctr1" id="h6">8</td><td class="ctr2" id="i6">8</td><td class="ctr1" id="j6">1</td><td class="ctr2" id="k6">1</td></tr><tr
><td id="a1"><a href="DaemonLoader.java.html#L31" class="el_method">DaemonLoader()</a></td><td class="bar" id="b7"><img src="../jacoco-resources/redbar.gif" width="1" height="10" title="3" alt="3"/></td><td class="ctr2" id="c7">0%</td><td class="bar" id="d7"/><td class="ctr2" id="e7">n/a</td><td class="ctr1" id="f7">1</td><td class="ctr2" id="g7">1</td><td class="ctr1" id="h7">1</td><td class="ctr2" id="i7">1</td><td class="ctr1" id="j7">1</td><td class="ctr2" id="k7">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
\ No newline at end of file
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader.java.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader.java.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonLoader.java.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1,415 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonLoader.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.source.html" class="el_package">org.apache.commons.daemon.support</a> > <span class="e
l_source">DaemonLoader.java</span></div><h1>DaemonLoader.java</h1><pre class="source lang-java linenums">/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.daemon.support;
+
+import org.apache.commons.daemon.DaemonContext;
+import org.apache.commons.daemon.DaemonController;
+import org.apache.commons.daemon.DaemonInitException;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Objects;
+
+/**
+ * Used by jsvc for Daemon management.
+ */
+<span class="nc" id="L31">public final class DaemonLoader</span>
+{
+
+ // N.B. These static mutable variables need to be accessed using synch.
+ private static Controller controller; //@GuardedBy("this")
+ private static Object daemon; //@GuardedBy("this")
+ /* Methods to call */
+ private static Method init; //@GuardedBy("this")
+ private static Method start; //@GuardedBy("this")
+ private static Method stop; //@GuardedBy("this")
+ private static Method destroy; //@GuardedBy("this")
+ private static Method signal; //@GuardedBy("this")
+
+ public static void version()
+ {
+<span class="nc" id="L46"> System.err.println("java version \"" +</span>
+<span class="nc" id="L47"> System.getProperty("java.version") + "\"");</span>
+<span class="nc" id="L48"> System.err.println(System.getProperty("java.runtime.name") +</span>
+ " (build " +
+<span class="nc" id="L50"> System.getProperty("java.runtime.version") + ")");</span>
+<span class="nc" id="L51"> System.err.println(System.getProperty("java.vm.name") +</span>
+ " (build " +
+<span class="nc" id="L53"> System.getProperty("java.vm.version") +</span>
+<span class="nc" id="L54"> ", " + System.getProperty("java.vm.info") + ")");</span>
+<span class="nc" id="L55"> System.err.println("commons daemon version \"" +</span>
+<span class="nc" id="L56"> System.getProperty("commons.daemon.version") + "\"");</span>
+<span class="nc" id="L57"> System.err.println("commons daemon process (id: " +</span>
+<span class="nc" id="L58"> System.getProperty("commons.daemon.process.id") +</span>
+ ", parent: " +
+<span class="nc" id="L60"> System.getProperty("commons.daemon.process.parent") + ")");</span>
+<span class="nc" id="L61"> }</span>
+
+ public static boolean check(final String className)
+ {
+ try {
+ /* Check the class name */
+<span class="nc" id="L67"> Objects.requireNonNull(className, "className");</span>
+ /* Get the ClassLoader loading this class */
+<span class="nc" id="L69"> final ClassLoader cl = DaemonLoader.class.getClassLoader();</span>
+<span class="nc bnc" id="L70" title="All 2 branches missed."> if (cl == null) {</span>
+<span class="nc" id="L71"> System.err.println("Cannot retrieve ClassLoader instance");</span>
+<span class="nc" id="L72"> return false;</span>
+ }
+
+ /* Find the required class */
+<span class="nc" id="L76"> final Class<?> c = cl.loadClass(className);</span>
+
+ /* This should _never_ happen, but double-checking doesn't harm */
+<span class="nc bnc" id="L79" title="All 2 branches missed."> if (c == null) {</span>
+<span class="nc" id="L80"> throw new ClassNotFoundException(className);</span>
+ }
+
+ /* Create a new instance of the daemon */
+<span class="nc" id="L84"> c.getConstructor().newInstance();</span>
+
+<span class="nc" id="L86"> } catch (final Throwable t) {</span>
+ /* In case we encounter ANY error, we dump the stack trace and
+ * return false (load, start and stop won't be called).
+ */
+<span class="nc" id="L90"> t.printStackTrace(System.err);</span>
+<span class="nc" id="L91"> return false;</span>
+<span class="nc" id="L92"> }</span>
+ /* The class was loaded and instantiated correctly, we can return
+ */
+<span class="nc" id="L95"> return true;</span>
+ }
+
+ public static boolean signal()
+ {
+ try {
+<span class="nc bnc" id="L101" title="All 2 branches missed."> if (signal != null) {</span>
+<span class="nc" id="L102"> signal.invoke(daemon);</span>
+<span class="nc" id="L103"> return true;</span>
+ }
+<span class="nc" id="L105"> System.out.println("Daemon doesn't support signaling");</span>
+<span class="nc" id="L106"> } catch (final Throwable ex) {</span>
+<span class="nc" id="L107"> System.err.println("Cannot send signal: " + ex);</span>
+<span class="nc" id="L108"> ex.printStackTrace(System.err);</span>
+<span class="nc" id="L109"> }</span>
+<span class="nc" id="L110"> return false;</span>
+ }
+
+ public static boolean load(final String className, String[] args)
+ {
+ try {
+ /* Check if the underlying library supplied a valid list of
+ arguments */
+<span class="nc bnc" id="L118" title="All 2 branches missed."> if (args == null) {</span>
+<span class="nc" id="L119"> args = new String[0];</span>
+ }
+
+ /* Check the class name */
+<span class="nc" id="L123"> Objects.requireNonNull(className, "className");</span>
+
+ /* Get the ClassLoader loading this class */
+<span class="nc" id="L126"> final ClassLoader cl = DaemonLoader.class.getClassLoader();</span>
+<span class="nc bnc" id="L127" title="All 2 branches missed."> if (cl == null) {</span>
+<span class="nc" id="L128"> System.err.println("Cannot retrieve ClassLoader instance");</span>
+<span class="nc" id="L129"> return false;</span>
+ }
+ final Class<?> c;
+<span class="nc bnc" id="L132" title="All 2 branches missed."> if (className.charAt(0) == '@') {</span>
+ /* Wrap the class with DaemonWrapper
+ * and modify arguments to include the real class name.
+ */
+<span class="nc" id="L136"> c = DaemonWrapper.class;</span>
+<span class="nc" id="L137"> final String[] a = new String[args.length + 2];</span>
+<span class="nc" id="L138"> a[0] = "-start";</span>
+<span class="nc" id="L139"> a[1] = className.substring(1);</span>
+<span class="nc" id="L140"> System.arraycopy(args, 0, a, 2, args.length);</span>
+<span class="nc" id="L141"> args = a;</span>
+<span class="nc" id="L142"> }</span>
+ else {
+<span class="nc" id="L144"> c = cl.loadClass(className);</span>
+ }
+ /* This should _never_ happen, but double-checking doesn't harm */
+<span class="nc bnc" id="L147" title="All 2 branches missed."> if (c == null) {</span>
+<span class="nc" id="L148"> throw new ClassNotFoundException(className);</span>
+ }
+ /* Check interfaces */
+<span class="nc" id="L151"> boolean isdaemon = false;</span>
+
+ try {
+<span class="nc" id="L154"> final Class<?> dclass = cl.loadClass("org.apache.commons.daemon.Daemon");</span>
+<span class="nc" id="L155"> isdaemon = dclass.isAssignableFrom(c);</span>
+ }
+<span class="nc" id="L157"> catch (final Exception ignored) {</span>
+ // Swallow if Daemon not found.
+<span class="nc" id="L159"> }</span>
+
+ /* Check methods */
+<span class="nc" id="L162"> final Class<?>[] myclass = new Class[1];</span>
+<span class="nc bnc" id="L163" title="All 2 branches missed."> if (isdaemon) {</span>
+<span class="nc" id="L164"> myclass[0] = DaemonContext.class;</span>
+ }
+ else {
+<span class="nc" id="L167"> myclass[0] = args.getClass();</span>
+ }
+
+<span class="nc" id="L170"> init = c.getMethod("init", myclass);</span>
+
+<span class="nc" id="L172"> start = c.getMethod("start");</span>
+<span class="nc" id="L173"> stop = c.getMethod("stop");</span>
+<span class="nc" id="L174"> destroy = c.getMethod("destroy");</span>
+
+ try {
+<span class="nc" id="L177"> signal = c.getMethod("signal");</span>
+<span class="nc" id="L178"> } catch (final NoSuchMethodException ignored) {</span>
+ // Signalling will be disabled.
+<span class="nc" id="L180"> }</span>
+
+ /* Create a new instance of the daemon */
+<span class="nc" id="L183"> daemon = c.getConstructor().newInstance();</span>
+
+<span class="nc bnc" id="L185" title="All 2 branches missed."> if (isdaemon) {</span>
+ /* Create a new controller instance */
+<span class="nc" id="L187"> controller = new Controller();</span>
+
+ /* Set the availability flag in the controller */
+<span class="nc" id="L190"> controller.setAvailable(false);</span>
+
+ /* Create context */
+<span class="nc" id="L193"> final Context context = new Context();</span>
+<span class="nc" id="L194"> context.setArguments(args);</span>
+<span class="nc" id="L195"> context.setController(controller);</span>
+
+ /* Now we want to call the init method in the class */
+<span class="nc" id="L198"> final Object[] arg = new Object[1];</span>
+<span class="nc" id="L199"> arg[0] = context;</span>
+<span class="nc" id="L200"> init.invoke(daemon, arg);</span>
+<span class="nc" id="L201"> }</span>
+ else {
+<span class="nc" id="L203"> final Object[] arg = new Object[1];</span>
+<span class="nc" id="L204"> arg[0] = args;</span>
+<span class="nc" id="L205"> init.invoke(daemon, arg);</span>
+ }
+
+ }
+<span class="nc" id="L209"> catch (final InvocationTargetException e) {</span>
+<span class="nc" id="L210"> final Throwable thrown = e.getTargetException();</span>
+ /* DaemonInitExceptions can fail with a nicer message */
+<span class="nc bnc" id="L212" title="All 2 branches missed."> if (thrown instanceof DaemonInitException) {</span>
+<span class="nc" id="L213"> failed(((DaemonInitException) thrown).getMessageWithCause());</span>
+ }
+ else {
+<span class="nc" id="L216"> thrown.printStackTrace(System.err);</span>
+ }
+<span class="nc" id="L218"> return false;</span>
+ }
+<span class="nc" id="L220"> catch (final Throwable t) {</span>
+ /* In case we encounter ANY error, we dump the stack trace and
+ * return false (load, start and stop won't be called).
+ */
+<span class="nc" id="L224"> t.printStackTrace(System.err);</span>
+<span class="nc" id="L225"> return false;</span>
+<span class="nc" id="L226"> }</span>
+ /* The class was loaded and instantiated correctly, we can return */
+<span class="nc" id="L228"> return true;</span>
+ }
+
+ public static boolean start()
+ {
+ try {
+ /* Attempt to start the daemon */
+<span class="nc" id="L235"> start.invoke(daemon);</span>
+
+ /* Set the availability flag in the controller */
+<span class="nc bnc" id="L238" title="All 2 branches missed."> if (controller != null) {</span>
+<span class="nc" id="L239"> controller.setAvailable(true);</span>
+ }
+
+<span class="nc" id="L242"> } catch (final Throwable t) {</span>
+ /* In case we encounter ANY error, we dump the stack trace and
+ * return false (load, start and stop won't be called).
+ */
+<span class="nc" id="L246"> t.printStackTrace(System.err);</span>
+<span class="nc" id="L247"> return false;</span>
+<span class="nc" id="L248"> }</span>
+<span class="nc" id="L249"> return true;</span>
+ }
+
+ public static boolean stop()
+ {
+ try {
+ /* Set the availability flag in the controller */
+<span class="nc bnc" id="L256" title="All 2 branches missed."> if (controller != null) {</span>
+<span class="nc" id="L257"> controller.setAvailable(false);</span>
+ }
+
+ /* Attempt to stop the daemon */
+<span class="nc" id="L261"> stop.invoke(daemon);</span>
+ }
+<span class="nc" id="L263"> catch (final Throwable t) {</span>
+ /* In case we encounter ANY error, we dump the stack trace and
+ * return false (load, start and stop won't be called).
+ */
+<span class="nc" id="L267"> t.printStackTrace(System.err);</span>
+<span class="nc" id="L268"> return false;</span>
+<span class="nc" id="L269"> }</span>
+<span class="nc" id="L270"> return true;</span>
+ }
+
+ public static boolean destroy()
+ {
+ try {
+ /* Attempt to stop the daemon */
+<span class="nc" id="L277"> destroy.invoke(daemon);</span>
+
+<span class="nc" id="L279"> daemon = null;</span>
+<span class="nc" id="L280"> controller = null;</span>
+<span class="nc" id="L281"> } catch (final Throwable t) {</span>
+ /* In case we encounter ANY error, we dump the stack trace and
+ * return false (load, start and stop won't be called).
+ */
+<span class="nc" id="L285"> t.printStackTrace(System.err);</span>
+<span class="nc" id="L286"> return false;</span>
+<span class="nc" id="L287"> }</span>
+<span class="nc" id="L288"> return true;</span>
+ }
+
+ private static native void shutdown(boolean reload);
+ private static native void failed(String message);
+
+ public static class Controller
+ implements DaemonController
+ {
+
+ private boolean available;
+
+ private Controller()
+<span class="nc" id="L301"> {</span>
+<span class="nc" id="L302"> this.setAvailable(false);</span>
+<span class="nc" id="L303"> }</span>
+
+ private boolean isAvailable()
+ {
+<span class="nc" id="L307"> synchronized (this) {</span>
+<span class="nc" id="L308"> return this.available;</span>
+ }
+ }
+
+ private void setAvailable(final boolean available)
+ {
+<span class="nc" id="L314"> synchronized (this) {</span>
+<span class="nc" id="L315"> this.available = available;</span>
+<span class="nc" id="L316"> }</span>
+<span class="nc" id="L317"> }</span>
+
+ @Override
+ public void shutdown()
+ throws IllegalStateException
+ {
+<span class="nc" id="L323"> synchronized (this) {</span>
+<span class="nc bnc" id="L324" title="All 2 branches missed."> if (!this.isAvailable()) {</span>
+<span class="nc" id="L325"> throw new IllegalStateException();</span>
+ }
+<span class="nc" id="L327"> this.setAvailable(false);</span>
+<span class="nc" id="L328"> DaemonLoader.shutdown(false);</span>
+<span class="nc" id="L329"> }</span>
+<span class="nc" id="L330"> }</span>
+
+ @Override
+ public void reload()
+ throws IllegalStateException
+ {
+<span class="nc" id="L336"> synchronized (this) {</span>
+<span class="nc bnc" id="L337" title="All 2 branches missed."> if (!this.isAvailable()) {</span>
+<span class="nc" id="L338"> throw new IllegalStateException();</span>
+ }
+<span class="nc" id="L340"> this.setAvailable(false);</span>
+<span class="nc" id="L341"> DaemonLoader.shutdown(true);</span>
+<span class="nc" id="L342"> }</span>
+<span class="nc" id="L343"> }</span>
+
+ @Override
+ public void fail()
+ {
+<span class="nc" id="L348"> fail(null, null);</span>
+<span class="nc" id="L349"> }</span>
+
+ @Override
+ public void fail(final String message)
+ {
+<span class="nc" id="L354"> fail(message, null);</span>
+<span class="nc" id="L355"> }</span>
+
+ @Override
+ public void fail(final Exception exception)
+ {
+<span class="nc" id="L360"> fail(null, exception);</span>
+<span class="nc" id="L361"> }</span>
+
+ @Override
+ public void fail(final String message, final Exception exception)
+ {
+<span class="nc" id="L366"> synchronized (this) {</span>
+<span class="nc" id="L367"> this.setAvailable(false);</span>
+<span class="nc" id="L368"> String msg = message;</span>
+<span class="nc bnc" id="L369" title="All 2 branches missed."> if (exception != null) {</span>
+<span class="nc bnc" id="L370" title="All 2 branches missed."> if (msg != null) {</span>
+<span class="nc" id="L371"> msg = msg + ": " + exception.toString();</span>
+ }
+ else {
+<span class="nc" id="L374"> msg = exception.toString();</span>
+ }
+ }
+<span class="nc" id="L377"> DaemonLoader.failed(msg);</span>
+<span class="nc" id="L378"> }</span>
+<span class="nc" id="L379"> }</span>
+
+ }
+
+<span class="nc" id="L383"> public static class Context</span>
+ implements DaemonContext
+ {
+
+ private DaemonController daemonController;
+
+ private String[] args;
+
+ @Override
+ public DaemonController getController()
+ {
+<span class="nc" id="L394"> return daemonController;</span>
+ }
+
+ public void setController(final DaemonController controller)
+ {
+<span class="nc" id="L399"> this.daemonController = controller;</span>
+<span class="nc" id="L400"> }</span>
+
+ @Override
+ public String[] getArguments()
+ {
+<span class="nc" id="L405"> return args;</span>
+ }
+
+ public void setArguments(final String[]args)
+ {
+<span class="nc" id="L410"> this.args = args;</span>
+<span class="nc" id="L411"> }</span>
+
+ }
+}
+</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
\ No newline at end of file
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper$Invoker.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper$Invoker.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper$Invoker.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonWrapper.Invoker</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.html" class="el_package">org.apache.commons.daemon.support</a> > <span class="el_class">DaemonWrapper.Invoker</span></div><h1>DaemonWrapper.Invoker</h1><table class="coverage" c
ellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">152 of 152</td><td class="ctr2">0%</td><td class="bar">22 of 22</td><td class="ctr2">0%</td><td class=
"ctr1">17</td><td class="ctr2">17</td><td class="ctr1">41</td><td class="ctr2">41</td><td class="ctr1">6</td><td class="ctr2">6</td></tr></tfoot><tbody><tr><td id="a5"><a href="DaemonWrapper.java.html#L258" class="el_method">validate()</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="63" alt="63"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="8" alt="8"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">5</td><td class="ctr2" id="g0">5</td><td class="ctr1" id="h0">17</td><td class="ctr2" id="i0">17</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a2"><a href="DaemonWrapper.java.html#L235" class="el_method">invoke()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="85" height="10" title="45" alt="45"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d1"><img
src="../jacoco-resources/redbar.gif" width="90" height="10" title="6" alt="6"/></td><td class="ctr2" id="e1">0%</td><td class="ctr1" id="f1">4</td><td class="ctr2" id="g1">4</td><td class="ctr1" id="h1">9</td><td class="ctr2" id="i1">9</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a0"><a href="DaemonWrapper.java.html#L222" class="el_method">addArguments(String[])</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="51" height="10" title="27" alt="27"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d2"><img src="../jacoco-resources/redbar.gif" width="60" height="10" title="4" alt="4"/></td><td class="ctr2" id="e2">0%</td><td class="ctr1" id="f2">3</td><td class="ctr2" id="g2">3</td><td class="ctr1" id="h2">7</td><td class="ctr2" id="i2">7</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a3"><a href="DaemonWrapper.java.html#L210" class="el_method">setClassName(String)</a></td><
td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="13" height="10" title="7" alt="7"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d3"><img src="../jacoco-resources/redbar.gif" width="30" height="10" title="2" alt="2"/></td><td class="ctr2" id="e3">0%</td><td class="ctr1" id="f3">2</td><td class="ctr2" id="g3">2</td><td class="ctr1" id="h3">3</td><td class="ctr2" id="i3">3</td><td class="ctr1" id="j3">1</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a4"><a href="DaemonWrapper.java.html#L216" class="el_method">setMethodName(String)</a></td><td class="bar" id="b4"><img src="../jacoco-resources/redbar.gif" width="13" height="10" title="7" alt="7"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d4"><img src="../jacoco-resources/redbar.gif" width="30" height="10" title="2" alt="2"/></td><td class="ctr2" id="e4">0%</td><td class="ctr1" id="f4">2</td><td class="ctr2" id="g4">2</td><td class="ctr1" id="h4">3</td><td class="ctr2" id="i4">3</td>
<td class="ctr1" id="j4">1</td><td class="ctr2" id="k4">1</td></tr><tr><td id="a1"><a href="DaemonWrapper.java.html#L205" class="el_method">DaemonWrapper.Invoker()</a></td><td class="bar" id="b5"><img src="../jacoco-resources/redbar.gif" width="5" height="10" title="3" alt="3"/></td><td class="ctr2" id="c5">0%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">1</td><td class="ctr2" id="g5">1</td><td class="ctr1" id="h5">2</td><td class="ctr2" id="i5">2</td><td class="ctr1" id="j5">1</td><td class="ctr2" id="k5">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
\ No newline at end of file
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonWrapper</title><script type="text/javascript" src="../jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.html" class="el_package">org.apache.commons.daemon.support</a> > <span class="el_class">DaemonWrapper</span></div><h1>DaemonWrapper</h1><table class="coverage" cellspacing="0" id="cover
agetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">279 of 279</td><td class="ctr2">0%</td><td class="bar">29 of 29</td><td class="ctr2">0%</td><td class="ctr1">22</td><td class=
"ctr2">22</td><td class="ctr1">58</td><td class="ctr2">58</td><td class="ctr1">5</td><td class="ctr2">5</td></tr></tfoot><tbody><tr><td id="a2"><a href="DaemonWrapper.java.html#L89" class="el_method">init(DaemonContext)</a></td><td class="bar" id="b0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="239" alt="239"/></td><td class="ctr2" id="c0">0%</td><td class="bar" id="d0"><img src="../jacoco-resources/redbar.gif" width="120" height="10" title="29" alt="29"/></td><td class="ctr2" id="e0">0%</td><td class="ctr1" id="f0">18</td><td class="ctr2" id="g0">18</td><td class="ctr1" id="h0">47</td><td class="ctr2" id="i0">47</td><td class="ctr1" id="j0">1</td><td class="ctr2" id="k0">1</td></tr><tr><td id="a0"><a href="DaemonWrapper.java.html#L52" class="el_method">DaemonWrapper()</a></td><td class="bar" id="b1"><img src="../jacoco-resources/redbar.gif" width="9" height="10" title="18" alt="18"/></td><td class="ctr2" id="c1">0%</td><td class="bar" id="d1"/><td class
="ctr2" id="e1">n/a</td><td class="ctr1" id="f1">1</td><td class="ctr2" id="g1">1</td><td class="ctr1" id="h1">5</td><td class="ctr2" id="i1">5</td><td class="ctr1" id="j1">1</td><td class="ctr2" id="k1">1</td></tr><tr><td id="a1"><a href="DaemonWrapper.java.html#L192" class="el_method">destroy()</a></td><td class="bar" id="b2"><img src="../jacoco-resources/redbar.gif" width="7" height="10" title="14" alt="14"/></td><td class="ctr2" id="c2">0%</td><td class="bar" id="d2"/><td class="ctr2" id="e2">n/a</td><td class="ctr1" id="f2">1</td><td class="ctr2" id="g2">1</td><td class="ctr1" id="h2">2</td><td class="ctr2" id="i2">2</td><td class="ctr1" id="j2">1</td><td class="ctr2" id="k2">1</td></tr><tr><td id="a3"><a href="DaemonWrapper.java.html#L174" class="el_method">start()</a></td><td class="bar" id="b3"><img src="../jacoco-resources/redbar.gif" width="2" height="10" title="4" alt="4"/></td><td class="ctr2" id="c3">0%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td c
lass="ctr1" id="f3">1</td><td class="ctr2" id="g3">1</td><td class="ctr1" id="h3">2</td><td class="ctr2" id="i3">2</td><td class="ctr1" id="j3">1</td><td class="ctr2" id="k3">1</td></tr><tr><td id="a4"><a href="DaemonWrapper.java.html#L183" class="el_method">stop()</a></td><td class="bar" id="b4"><img src="../jacoco-resources/redbar.gif" width="2" height="10" title="4" alt="4"/></td><td class="ctr2" id="c4">0%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">1</td><td class="ctr2" id="g4">1</td><td class="ctr1" id="h4">2</td><td class="ctr2" id="i4">2</td><td class="ctr1" id="j4">1</td><td class="ctr2" id="k4">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
\ No newline at end of file
Added: websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper.java.html
==============================================================================
--- websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper.java.html (added)
+++ websites/production/commons/content/proper/commons-daemon/jacoco/org.apache.commons.daemon.support/DaemonWrapper.java.html Tue Nov 29 11:56:50 2022
@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>DaemonWrapper.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Daemon</a> > <a href="index.source.html" class="el_package">org.apache.commons.daemon.support</a> > <span class="
el_source">DaemonWrapper.java</span></div><h1>DaemonWrapper.java</h1><pre class="source lang-java linenums">/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.daemon.support;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Objects;
+
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonContext;
+
+/**
+ * Implementation of the Daemon that allows running
+ * standard applications as daemons.
+ * The applications must have the mechanism to manage
+ * the application lifecycle.
+ *
+ */
+public class DaemonWrapper implements Daemon
+{
+
+ private final static String ARGS = "args";
+ private final static String START_CLASS = "start";
+ private final static String START_METHOD = "start.method";
+ private final static String STOP_CLASS = "stop";
+ private final static String STOP_METHOD = "stop.method";
+ private final static String STOP_ARGS = "stop.args";
+ private String configFileName;
+ private final DaemonConfiguration config;
+
+ private final Invoker startup;
+ private final Invoker shutdown;
+
+ public DaemonWrapper()
+<span class="nc" id="L52"> {</span>
+<span class="nc" id="L53"> config = new DaemonConfiguration();</span>
+<span class="nc" id="L54"> startup = new Invoker();</span>
+<span class="nc" id="L55"> shutdown = new Invoker();</span>
+<span class="nc" id="L56"> }</span>
+
+ /**
+ * Called from DaemonLoader on init stage.
+ * <p>
+ * Accepts the following configuration arguments:
+ * <ul>
+ * <li>-daemon-properties: - load DaemonConfiguration properties from the specified file to act as defaults</li>
+ * <li>-start: set start class name</li>
+ * <li>-start-method: set start method name</li>
+ * <li>-stop: set stop class name</li>
+ * <li>-stop-method: set stop method name</li>
+ * <li>-stop-argument: set optional argument to stop method</li>
+ * <li>Anything else is treated as a startup argument</li>
+ * </ul>
+ * <p>
+ * The following "-daemon-properties" are recognized:
+ * <ul>
+ * <li>args (startup argument)</li>
+ * <li>start</li>
+ * <li>start.method</li>
+ * <li>stop</li>
+ * <li>stop.method</li>
+ * <li>stop.args</li>
+ * </ul>
+ * These are used to set the corresponding item if it has not already been
+ * set by the command arguments. <b>However, note that args and stop.args are
+ * appended to any existing values.</b>
+ */
+ @Override
+ public void init(final DaemonContext context)
+ throws Exception
+ {
+<span class="nc" id="L89"> final String[] args = context.getArguments();</span>
+
+<span class="nc bnc" id="L91" title="All 2 branches missed."> if (args != null) {</span>
+ int i;
+ // Parse our arguments and remove them
+ // from the final argument array we are
+ // passing to our child.
+ arguments:
+<span class="nc bnc" id="L97" title="All 2 branches missed."> for (i = 0; i < args.length; i++) {</span>
+<span class="nc bnc" id="L98" title="All 2 branches missed."> if (args[i].equals("--")) {</span>
+ // Done with argument processing
+<span class="nc" id="L100"> break;</span>
+ }
+<span class="nc bnc" id="L102" title="All 7 branches missed."> switch (args[i]) {</span>
+ case "-daemon-properties":
+<span class="nc bnc" id="L104" title="All 2 branches missed."> if (++i == args.length) {</span>
+<span class="nc" id="L105"> throw new IllegalArgumentException(args[i - 1]);</span>
+ }
+<span class="nc" id="L107"> configFileName = args[i];</span>
+<span class="nc" id="L108"> break;</span>
+ case "-start":
+<span class="nc bnc" id="L110" title="All 2 branches missed."> if (++i == args.length) {</span>
+<span class="nc" id="L111"> throw new IllegalArgumentException(args[i - 1]);</span>
+ }
+<span class="nc" id="L113"> startup.setClassName(args[i]);</span>
+<span class="nc" id="L114"> break;</span>
+ case "-start-method":
+<span class="nc bnc" id="L116" title="All 2 branches missed."> if (++i == args.length) {</span>
+<span class="nc" id="L117"> throw new IllegalArgumentException(args[i - 1]);</span>
+ }
+<span class="nc" id="L119"> startup.setMethodName(args[i]);</span>
+<span class="nc" id="L120"> break;</span>
+ case "-stop":
+<span class="nc bnc" id="L122" title="All 2 branches missed."> if (++i == args.length) {</span>
+<span class="nc" id="L123"> throw new IllegalArgumentException(args[i - 1]);</span>
+ }
+<span class="nc" id="L125"> shutdown.setClassName(args[i]);</span>
+<span class="nc" id="L126"> break;</span>
+ case "-stop-method":
+<span class="nc bnc" id="L128" title="All 2 branches missed."> if (++i == args.length) {</span>
+<span class="nc" id="L129"> throw new IllegalArgumentException(args[i - 1]);</span>
+ }
+<span class="nc" id="L131"> shutdown.setMethodName(args[i]);</span>
+<span class="nc" id="L132"> break;</span>
+ case "-stop-argument":
+<span class="nc bnc" id="L134" title="All 2 branches missed."> if (++i == args.length) {</span>
+<span class="nc" id="L135"> throw new IllegalArgumentException(args[i - 1]);</span>
+ }
+<span class="nc" id="L137"> final String[] aa = new String[1];</span>
+<span class="nc" id="L138"> aa[0] = args[i];</span>
+<span class="nc" id="L139"> shutdown.addArguments(aa);</span>
+<span class="nc" id="L140"> break;</span>
+ default:
+ // This is not our option.
+ // Everything else will be forwarded to the main
+<span class="nc" id="L144"> break arguments;</span>
+ }
+ }
+<span class="nc bnc" id="L147" title="All 2 branches missed."> if (args.length > i) {</span>
+<span class="nc" id="L148"> final String[] copy = new String[args.length - i];</span>
+<span class="nc" id="L149"> System.arraycopy(args, i, copy, 0, copy.length);</span>
+<span class="nc" id="L150"> startup.addArguments(copy);</span>
+ }
+ }
+<span class="nc bnc" id="L153" title="All 2 branches missed."> if (config.load(configFileName)) {</span>
+ // Setup params if not set via cmdline.
+<span class="nc" id="L155"> startup.setClassName(config.getProperty(START_CLASS));</span>
+<span class="nc" id="L156"> startup.setMethodName(config.getProperty(START_METHOD));</span>
+ // Merge the config with command line arguments
+<span class="nc" id="L158"> startup.addArguments(config.getPropertyArray(ARGS));</span>
+
+<span class="nc" id="L160"> shutdown.setClassName(config.getProperty(STOP_CLASS));</span>
+<span class="nc" id="L161"> shutdown.setMethodName(config.getProperty(STOP_METHOD));</span>
+<span class="nc" id="L162"> shutdown.addArguments(config.getPropertyArray(STOP_ARGS));</span>
+ }
+<span class="nc" id="L164"> startup.validate();</span>
+<span class="nc" id="L165"> shutdown.validate();</span>
+<span class="nc" id="L166"> }</span>
+
+ /**
+ */
+ @Override
+ public void start()
+ throws Exception
+ {
+<span class="nc" id="L174"> startup.invoke();</span>
+<span class="nc" id="L175"> }</span>
+
+ /**
+ */
+ @Override
+ public void stop()
+ throws Exception
+ {
+<span class="nc" id="L183"> shutdown.invoke();</span>
+<span class="nc" id="L184"> }</span>
+
+ /**
+ */
+ @Override
+ public void destroy()
+ {
+ // Nothing for the moment
+<span class="nc" id="L192"> System.err.println("DaemonWrapper: instance " + this.hashCode() + " destroy");</span>
+<span class="nc" id="L193"> }</span>
+
+ // Internal class for wrapping the start/stop methods
+ static class Invoker
+ {
+ private String name;
+ private String call;
+ private String[] args;
+ private Method inst;
+ private Class<?> main;
+
+ protected Invoker()
+<span class="nc" id="L205"> {</span>
+<span class="nc" id="L206"> }</span>
+
+ protected void setClassName(final String name)
+ {
+<span class="nc bnc" id="L210" title="All 2 branches missed."> if (this.name == null) {</span>
+<span class="nc" id="L211"> this.name = name;</span>
+ }
+<span class="nc" id="L213"> }</span>
+ protected void setMethodName(final String name)
+ {
+<span class="nc bnc" id="L216" title="All 2 branches missed."> if (this.call == null) {</span>
+<span class="nc" id="L217"> this.call = name;</span>
+ }
+<span class="nc" id="L219"> }</span>
+ protected void addArguments(final String[] args)
+ {
+<span class="nc bnc" id="L222" title="All 2 branches missed."> if (args != null) {</span>
+<span class="nc" id="L223"> final ArrayList<String> aa = new ArrayList<>();</span>
+<span class="nc bnc" id="L224" title="All 2 branches missed."> if (this.args != null) {</span>
+<span class="nc" id="L225"> aa.addAll(Arrays.asList(this.args));</span>
+ }
+<span class="nc" id="L227"> aa.addAll(Arrays.asList(args));</span>
+<span class="nc" id="L228"> this.args = aa.toArray(DaemonConfiguration.EMPTY_STRING_ARRAY);</span>
+ }
+<span class="nc" id="L230"> }</span>
+
+ protected void invoke()
+ throws Exception
+ {
+<span class="nc bnc" id="L235" title="All 4 branches missed."> if (name.equals("System") && call.equals("exit")) {</span>
+ // Just call a System.exit()
+ // The start method was probably installed
+ // a shutdown hook.
+<span class="nc" id="L239"> System.exit(0);</span>
+ }
+ else {
+<span class="nc" id="L242"> Object obj = null;</span>
+<span class="nc bnc" id="L243" title="All 2 branches missed."> if ((inst.getModifiers() & Modifier.STATIC) == 0) {</span>
+ // We only need object instance for non-static methods.
+<span class="nc" id="L245"> obj = main.getConstructor().newInstance();</span>
+ }
+<span class="nc" id="L247"> final Object[] arg = new Object[1];</span>
+
+<span class="nc" id="L249"> arg[0] = args;</span>
+<span class="nc" id="L250"> inst.invoke(obj, arg);</span>
+ }
+<span class="nc" id="L252"> }</span>
+ // Load the class using reflection
+ protected void validate()
+ throws Exception
+ {
+ /* Check the class name */
+<span class="nc bnc" id="L258" title="All 2 branches missed."> if (name == null) {</span>
+<span class="nc" id="L259"> name = "System";</span>
+<span class="nc" id="L260"> call = "exit";</span>
+<span class="nc" id="L261"> return;</span>
+ }
+<span class="nc bnc" id="L263" title="All 2 branches missed."> if (args == null) {</span>
+<span class="nc" id="L264"> args = new String[0];</span>
+ }
+<span class="nc bnc" id="L266" title="All 2 branches missed."> if (call == null) {</span>
+<span class="nc" id="L267"> call = "main";</span>
+ }
+
+ // Get the ClassLoader loading this class
+<span class="nc" id="L271"> final ClassLoader classLoader = DaemonWrapper.class.getClassLoader();</span>
+<span class="nc" id="L272"> Objects.requireNonNull(classLoader, "classLoader");</span>
+<span class="nc" id="L273"> final Class<?>[] ca = new Class[1];</span>
+<span class="nc" id="L274"> ca[0] = args.getClass();</span>
+ // Find the required class
+<span class="nc" id="L276"> main = classLoader.loadClass(name);</span>
+<span class="nc bnc" id="L277" title="All 2 branches missed."> if (main == null) {</span>
+<span class="nc" id="L278"> throw new ClassNotFoundException(name);</span>
+ }
+ // Find the required method.
+ // NoSuchMethodException will be thrown if matching method
+ // is not found.
+<span class="nc" id="L283"> inst = main.getMethod(call, ca);</span>
+<span class="nc" id="L284"> }</span>
+ }
+}
+</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
\ No newline at end of file