Fix FELIX-2633 Rename JMX annotations
The @Conifug annotation is now @JmxBean which make more sense.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1023215 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/handler/jmx/metadata.xml b/ipojo/handler/jmx/metadata.xml
index ed20e9b..67b6b38 100644
--- a/ipojo/handler/jmx/metadata.xml
+++ b/ipojo/handler/jmx/metadata.xml
@@ -17,6 +17,6 @@
under the License.
-->
<ipojo>
-<handler classname="org.apache.felix.ipojo.handlers.jmx.MBeanHandler" name="config" namespace="org.apache.felix.ipojo.handlers.jmx">
-</handler>
+<handler classname="org.apache.felix.ipojo.handlers.jmx.MBeanHandler" name="config" namespace="org.apache.felix.ipojo.handlers.jmx" />
+<handler classname="org.apache.felix.ipojo.handlers.jmx.MBeanHandler" name="JMXBean" namespace="org.apache.felix.ipojo.handlers.jmx" />
</ipojo>
\ No newline at end of file
diff --git a/ipojo/handler/jmx/obr.xml b/ipojo/handler/jmx/obr.xml
index df0b21c..310c385 100644
--- a/ipojo/handler/jmx/obr.xml
+++ b/ipojo/handler/jmx/obr.xml
@@ -22,4 +22,9 @@
<p n="namespace" v="org.apache.felix.ipojo.handlers.jmx"/>
<p n="type" v="primitive"/>
</capability>
+ <capability name="ipojo.handler">
+ <p n="name" v="JMXBean"/>
+ <p n="namespace" v="org.apache.felix.ipojo.handlers.jmx"/>
+ <p n="type" v="primitive"/>
+ </capability>
</obr>
\ No newline at end of file
diff --git a/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanImpl.java b/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanImpl.java
index dc3e8c1..d2fe8f2 100644
--- a/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanImpl.java
+++ b/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanImpl.java
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -393,7 +393,8 @@
long timeStamp = System.currentTimeMillis();
- if (newValue.equals(oldValue)) {
+ if ((newValue == null && oldValue == null)
+ || (newValue != null && newValue.equals(oldValue))) {
return;
}
m_sequenceNumber++;
diff --git a/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java b/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
index efffc22..9bbd354 100644
--- a/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
+++ b/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
@@ -76,6 +76,11 @@
private static final String JMX_CONFIG_ELT = "config";
/**
+ * The name of the global configuration element.
+ */
+ private static final String JMX_CONFIG_ALT_ELT = "JmxBean";
+
+ /**
* The name of the component object full name attribute.
*/
private static final String JMX_OBJ_NAME_ELT = "objectName";
@@ -103,7 +108,7 @@
/**
* The alternative name of a method element.
*/
- private static final String JMX_METHOD_ELT_ALT = "method";
+ private static final String JMX_METHOD_ELT_ALT = "JmxMethod";
/**
* The name of the property or method name attribute.
@@ -123,7 +128,7 @@
/**
* The alternative name of a property element.
*/
- private static final String JMX_PROPERTY_ELT_ALT = "property";
+ private static final String JMX_PROPERTY_ELT_ALT = "JmxProperty";
/**
* The name of the field attribute.
@@ -222,9 +227,12 @@
// Build the hashmap
Element[] mbeans = metadata.getElements(JMX_CONFIG_ELT, m_namespace);
+ if (mbeans == null || mbeans.length == 0) {
+ mbeans = metadata.getElements(JMX_CONFIG_ALT_ELT, m_namespace);
+ }
if (mbeans.length != 1) {
- error("A component must have at most one " + JMX_CONFIG_ELT + ".");
+ error("A component must have exactly one " + JMX_CONFIG_ELT + " or " + JMX_CONFIG_ALT_ELT + " element.");
error("The JMX handler configuration is ignored.");
return;
}
@@ -532,6 +540,21 @@
PropertyField propertyField = (PropertyField) m_jmxConfigFieldMap
.getPropertyFromField(fieldName);
if (propertyField != null) {
+ // Do we have a value to inject ?
+ Object v = propertyField.getValue();
+ if (v == null) {
+ String type = propertyField.getType();
+ if ("boolean".equals(type)) { v = Boolean.FALSE; }
+ else if ("byte".equals(type)) { v = new Byte((byte) 0); }
+ else if ("short".equals(type)) { v = new Short((short) 0); }
+ else if ("int".equals(type)) { v = new Integer(0); }
+ else if ("long".equals(type)) { v = new Long(0); }
+ else if ("float".equals(type)) { v = new Float(0); }
+ else if ("double".equals(type)) { v =new Double(0); }
+ else if ("char".equals(type)) { v = new Character((char) 0); }
+
+ return v;
+ }
m_instanceManager.onSet(pojo, fieldName, propertyField.getValue());
return propertyField.getValue();
}