This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 4469fae  CAMEL-12636: Polished camel-jmx
4469fae is described below

commit 4469faeaf272368ee82bd11a1c7aee0892eaa1fe
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Jul 11 09:31:52 2018 +0200

    CAMEL-12636: Polished camel-jmx
---
 .../camel-jmx/src/main/docs/jmx-component.adoc     | 28 +++++------
 .../apache/camel/component/jmx/JMXEndpoint.java    | 57 +++++++++++-----------
 .../camel/component/jmx/JMXMonitorConsumer.java    |  5 +-
 3 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/components/camel-jmx/src/main/docs/jmx-component.adoc 
b/components/camel-jmx/src/main/docs/jmx-component.adoc
index e180f6f..ecabd57 100644
--- a/components/camel-jmx/src/main/docs/jmx-component.adoc
+++ b/components/camel-jmx/src/main/docs/jmx-component.adoc
@@ -53,11 +53,11 @@ with the following path and query parameters:
 | Name | Description | Default | Type
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the 
Camel routing Error Handler, which mean any exceptions occurred while the 
consumer is trying to pickup incoming messages, or the likes, will now be 
processed as a message and handled by the routing Error Handler. By default the 
consumer will use the org.apache.camel.spi.ExceptionHandler to deal with 
exceptions, that will be logged at WARN or ERROR level and ignored. | false | 
boolean
 | *format* (consumer) | Format for the message body. Either xml or raw. If 
xml, the notification is serialized to xml. If raw, then the raw java object is 
set as the body. | xml | String
-| *granularityPeriod* (consumer) | monitor types only The frequency to poll 
the bean to check the monitor. | 10000 | long
-| *monitorType* (consumer) | monitor types only The type of monitor to create. 
One of string, gauge, counter. |  | String
+| *granularityPeriod* (consumer) | The frequency to poll the bean to check the 
monitor (monitor types only). | 10000 | long
+| *monitorType* (consumer) | The type of monitor to create. One of string, 
gauge, counter (monitor types only). |  | String
 | *objectDomain* (consumer) | *Required* The domain for the mbean you're 
connecting to |  | String
 | *objectName* (consumer) | The name key for the mbean you're connecting to. 
This value is mutually exclusive with the object properties that get passed. |  
| String
-| *observedAttribute* (consumer) | monitor types only The attribute to observe 
for the monitor bean. |  | String
+| *observedAttribute* (consumer) | The attribute to observe for the monitor 
bean (monitor types only). |  | String
 | *exceptionHandler* (consumer) | To let the consumer use a custom 
ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this 
options is not in use. By default the consumer will deal with exceptions, that 
will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer 
creates an exchange. |  | ExchangePattern
 | *executorService* (advanced) | To use a custom shared thread pool for the 
consumers. By default each consume has their own thread-pool to process and 
route notifications. |  | ExecutorService
@@ -68,19 +68,19 @@ with the following path and query parameters:
 | *reconnectOnConnection Failure* (advanced) | If true the consumer will 
attempt to reconnect to the JMX server when any connection failure occurs. The 
consumer will attempt to re-establish the JMX connection every 'x' seconds 
until the connection is made-- where 'x' is the configured reconnectionDelay | 
false | boolean
 | *synchronous* (advanced) | Sets whether synchronous processing should be 
strictly used, or Camel is allowed to use asynchronous processing (if 
supported). | false | boolean
 | *testConnectionOnStartup* (advanced) | If true the consumer will throw an 
exception if unable to establish the JMX connection upon startup. If false, the 
consumer will attempt to establish the JMX connection every 'x' seconds until 
the connection is made -- where 'x' is the configured reconnectionDelay | true 
| boolean
-| *initThreshold* (counter) | counter monitor only Initial threshold for the 
monitor. The value must exceed this before notifications are fired. |  | int
-| *modulus* (counter) | counter monitor only The value at which the counter is 
reset to zero |  | int
-| *offset* (counter) | counter monitor only The amount to increment the 
threshold after it's been exceeded. |  | int
-| *differenceMode* (gauge) | counter gauge monitor only If true, then the 
value reported in the notification is the difference from the threshold as 
opposed to the value itself. | false | boolean
-| *notifyHigh* (gauge) | gauge monitor only If true, the gauge will fire a 
notification when the high threshold is exceeded | false | boolean
-| *notifyLow* (gauge) | gauge monitor only If true, the gauge will fire a 
notification when the low threshold is exceeded | false | boolean
-| *thresholdHigh* (gauge) | gauge monitor only Value for the gauge's high 
threshold |  | Double
-| *thresholdLow* (gauge) | gauge monitor only Value for the gauge's low 
threshold |  | Double
+| *initThreshold* (counter) | Initial threshold for the monitor. The value 
must exceed this before notifications are fired (counter monitor only). |  | int
+| *modulus* (counter) | The value at which the counter is reset to zero 
(counter monitor only). |  | int
+| *offset* (counter) | The amount to increment the threshold after it's been 
exceeded (counter monitor only). |  | int
+| *differenceMode* (gauge) | If true, then the value reported in the 
notification is the difference from the threshold as opposed to the value 
itself (counter and gauge monitor only). | false | boolean
+| *notifyHigh* (gauge) | If true, the gauge will fire a notification when the 
high threshold is exceeded (gauge monitor only). | false | boolean
+| *notifyLow* (gauge) | If true, the gauge will fire a notification when the 
low threshold is exceeded (gauge monitor only). | false | boolean
+| *thresholdHigh* (gauge) | Value for the gauge's high threshold (gauge 
monitor only). |  | Double
+| *thresholdLow* (gauge) | Value for the gauge's low threshold (gauge monitor 
only). |  | Double
 | *password* (security) | Credentials for making a remote connection |  | 
String
 | *user* (security) | Credentials for making a remote connection |  | String
-| *notifyDiffer* (string) | string monitor only If true, the string monitor 
will fire a notification when the string attribute differs from the string to 
compare. | false | boolean
-| *notifyMatch* (string) | string monitor only If true, the string monitor 
will fire a notification when the string attribute matches the string to 
compare. | false | boolean
-| *stringToCompare* (string) | string monitor only Value for the string 
monitor's string to compare. |  | String
+| *notifyDiffer* (string) | If true, the string monitor will fire a 
notification when the string attribute differs from the string to compare 
(string monitor only). | false | boolean
+| *notifyMatch* (string) | If true, the string monitor will fire a 
notification when the string attribute matches the string to compare (string 
monitor only). | false | boolean
+| *stringToCompare* (string) | Value for the string monitor's string to 
compare (string monitor only). |  | String
 |===
 // endpoint options: END
 
diff --git 
a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
 
b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
index 58757a5..9833774 100644
--- 
a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
+++ 
b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
@@ -67,85 +67,97 @@ public class JMXEndpoint extends DefaultEndpoint {
     private String serverURL;
 
     /**
-     * [monitor types only] The attribute to observe for the monitor bean.
+     * The domain for the mbean you're connecting to
+     */
+    @UriParam @Metadata(required = "true")
+    private String objectDomain;
+
+    /**
+     * The name key for the mbean you're connecting to. This value is mutually 
exclusive with the object properties that get passed.
+     */
+    @UriParam
+    private String objectName;
+
+    /**
+     * The attribute to observe for the monitor bean (monitor types only).
      */
     @UriParam
     private String observedAttribute;
 
     /**
-     * [monitor types only] The frequency to poll the bean to check the 
monitor.
+     * The frequency to poll the bean to check the monitor (monitor types 
only).
      */
     @UriParam(defaultValue = "10000")
     private long granularityPeriod = 10000;
 
     /**
-     * [monitor types only] The type of monitor to create. One of string, 
gauge, counter.
+     * The type of monitor to create. One of string, gauge, counter (monitor 
types only).
      */
     @UriParam(enums = "counter,gauge,string")
     private String monitorType;
 
     /**
-     * [counter monitor only] Initial threshold for the monitor. The value 
must exceed this before notifications are fired.
+     * Initial threshold for the monitor. The value must exceed this before 
notifications are fired (counter monitor only).
      */
     @UriParam(label = "counter")
     private int initThreshold;
 
     /**
-     * [counter monitor only] The amount to increment the threshold after it's 
been exceeded.
+     * The amount to increment the threshold after it's been exceeded (counter 
monitor only).
      */
     @UriParam(label = "counter")
     private int offset;
 
     /**
-     * [counter monitor only] The value at which the counter is reset to zero
+     * The value at which the counter is reset to zero (counter monitor only).
      */
     @UriParam(label = "counter")
     private int modulus;
 
     /**
-     * [counter + gauge monitor only] If true, then the value reported in the 
notification is the difference from the threshold as opposed to the value 
itself.
+     * If true, then the value reported in the notification is the difference 
from the threshold as opposed to the value itself (counter and gauge monitor 
only).
      */
     @UriParam(label = "counter,gauge")
     private boolean differenceMode;
 
     /**
-     * [gauge monitor only] If true, the gauge will fire a notification when 
the high threshold is exceeded
+     * If true, the gauge will fire a notification when the high threshold is 
exceeded (gauge monitor only).
      */
     @UriParam(label = "gauge")
     private boolean notifyHigh;
 
     /**
-     * [gauge monitor only] If true, the gauge will fire a notification when 
the low threshold is exceeded
+     * If true, the gauge will fire a notification when the low threshold is 
exceeded (gauge monitor only).
      */
     @UriParam(label = "gauge")
     private boolean notifyLow;
 
     /**
-     * [gauge monitor only] Value for the gauge's high threshold
+     * Value for the gauge's high threshold (gauge monitor only).
      */
     @UriParam(label = "gauge")
     private Double thresholdHigh;
 
     /**
-     * [gauge monitor only] Value for the gauge's low threshold
+     * Value for the gauge's low threshold (gauge monitor only).
      */
     @UriParam(label = "gauge")
     private Double thresholdLow;
 
     /**
-     * [string monitor only] If true, the string monitor will fire a 
notification when the string attribute differs from the string to compare.
+     * If true, the string monitor will fire a notification when the string 
attribute differs from the string to compare (string monitor only).
      */
     @UriParam(label = "string")
     private boolean notifyDiffer;
 
     /**
-     * [string monitor only] If true, the string monitor will fire a 
notification when the string attribute matches the string to compare.
+     * If true, the string monitor will fire a notification when the string 
attribute matches the string to compare (string monitor only).
      */
     @UriParam(label = "string")
     private boolean notifyMatch;
 
     /**
-     * [string monitor only] Value for the string monitor's string to compare.
+     * Value for the string monitor's string to compare (string monitor only).
      */
     @UriParam(label = "string")
     private String stringToCompare;
@@ -169,18 +181,6 @@ public class JMXEndpoint extends DefaultEndpoint {
     private String password;
 
     /**
-     * The domain for the mbean you're connecting to
-     */
-    @UriParam @Metadata(required = "true")
-    private String objectDomain;
-
-    /**
-     * The name key for the mbean you're connecting to. This value is mutually 
exclusive with the object properties that get passed.
-     */
-    @UriParam
-    private String objectName;
-
-    /**
      * Reference to a bean that implements the NotificationFilter.
      */
     @UriParam(label = "advanced")
@@ -196,10 +196,9 @@ public class JMXEndpoint extends DefaultEndpoint {
      * If true the consumer will throw an exception if unable to establish the 
JMX connection upon startup.  If false, the consumer will attempt
      * to establish the JMX connection every 'x' seconds until the connection 
is made -- where 'x' is the configured  reconnectionDelay
      */
-    @UriParam(defaultValue = "true", label = "advanced")
+    @UriParam(label = "advanced", defaultValue = "true")
     private boolean testConnectionOnStartup = true;
     
-    
     /**
      * If true the consumer will attempt to reconnect to the JMX server when 
any connection failure occurs.  The consumer will attempt
      * to re-establish the JMX connection every 'x' seconds until the 
connection is made-- where 'x' is the configured  reconnectionDelay
@@ -210,7 +209,7 @@ public class JMXEndpoint extends DefaultEndpoint {
     /**
      * The number of seconds to wait before attempting to retry establishment 
of the initial connection or attempt to reconnect a lost connection
      */
-    @UriParam(defaultValue = "10", label = "advanced")
+    @UriParam(label = "advanced", defaultValue = "10")
     private int reconnectDelay = 10;
 
     /**
diff --git 
a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXMonitorConsumer.java
 
b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXMonitorConsumer.java
index 28955a7..b3ac8ff 100644
--- 
a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXMonitorConsumer.java
+++ 
b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXMonitorConsumer.java
@@ -37,7 +37,6 @@ import org.apache.camel.Processor;
  * monitor object and attribute referenced by the endpoint. The only 
  * difference here is the act of adding and removing the notification
  * listener.
- *
  */
 public class JMXMonitorConsumer extends JMXConsumer {
     
@@ -51,7 +50,7 @@ public class JMXMonitorConsumer extends JMXConsumer {
     @Override
     protected void addNotificationListener() throws Exception {
         
-        JMXEndpoint ep = (JMXEndpoint) getEndpoint();
+        JMXEndpoint ep = getEndpoint();
         // create the monitor bean
         Monitor bean = null;
         if (ep.getMonitorType().equals("counter")) {
@@ -80,6 +79,8 @@ public class JMXMonitorConsumer extends JMXConsumer {
             sm.setNotifyMatch(ep.isNotifyMatch());
             sm.setStringToCompare(ep.getStringToCompare());
             bean = sm;
+        } else {
+            throw new IllegalArgumentException("Unsupported monitortype: " + 
ep.getMonitorType());
         }
         
         bean.addObservedObject(ep.getJMXObjectName());

Reply via email to