You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2003/07/22 18:03:19 UTC
cvs commit: jakarta-commons/modeler/src/java/org/apache/commons/modeler/modules MbeansDescriptorsIntrospectionSource.java
dims 2003/07/22 09:03:19
Modified: modeler STATUS.html
modeler/src/java/org/apache/commons/modeler/modules
MbeansDescriptorsIntrospectionSource.java
Log:
- Added myself to STATUS.html
- Introspection now allows all primitives listed in the "open mbeans" spec as method parameters
- Introspection now allows javabeans as method parameters.
Revision Changes Path
1.3 +6 -1 jakarta-commons/modeler/STATUS.html
Index: STATUS.html
===================================================================
RCS file: /home/cvs/jakarta-commons/modeler/STATUS.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- STATUS.html 19 Apr 2003 16:53:59 -0000 1.2
+++ STATUS.html 22 Jul 2003 16:03:18 -0000 1.3
@@ -62,5 +62,10 @@
<li><a href="mailto:costin at apache.org">Costin Manolache</a></li>
</ul>
+<p>The following individuals have submitted patches for this component.</p>
+<ul>
+<li><a href="mailto:dims at yahoo.com">Davanum Srinivas</a></li>
+</ul>
+
</body>
</html>
1.10 +88 -22 jakarta-commons/modeler/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsIntrospectionSource.java
Index: MbeansDescriptorsIntrospectionSource.java
===================================================================
RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/modules/MbeansDescriptorsIntrospectionSource.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MbeansDescriptorsIntrospectionSource.java 20 Jul 2003 07:35:12 -0000 1.9
+++ MbeansDescriptorsIntrospectionSource.java 22 Jul 2003 16:03:19 -0000 1.10
@@ -1,14 +1,5 @@
package org.apache.commons.modeler.modules;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-
-import javax.management.ObjectName;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.modeler.AttributeInfo;
@@ -17,6 +8,16 @@
import org.apache.commons.modeler.ParameterInfo;
import org.apache.commons.modeler.Registry;
+import javax.management.ObjectName;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+
public class MbeansDescriptorsIntrospectionSource extends ModelerSource
{
@@ -88,21 +89,86 @@
private static ObjectName objNameArray[]=new ObjectName[0];
// createMBean == registerClass + registerMBean
- private boolean supportedType( Class ret ) {
- return ret == String.class ||
- ret == Integer.class ||
- ret == Integer.TYPE ||
- ret == Long.class ||
- ret == Long.TYPE ||
- ret == java.io.File.class ||
- ret == Boolean.class ||
- ret == Boolean.TYPE ||
- ret == strArray.getClass() ||
- ret == ObjectName.class ||
- ret == objNameArray.getClass()
- ;
+ private static Class[] supportedTypes = new Class[] {
+ Boolean.class,
+ Boolean.TYPE,
+ Byte.class,
+ Byte.TYPE,
+ Character.class,
+ Character.TYPE,
+ Short.class,
+ Short.TYPE,
+ Integer.class,
+ Integer.TYPE,
+ Long.class,
+ Long.TYPE,
+ Float.class,
+ Float.TYPE,
+ Double.class,
+ Double.TYPE,
+ String.class,
+ strArray.getClass(),
+ BigDecimal.class,
+ BigInteger.class,
+ ObjectName.class,
+ objNameArray.getClass(),
+ java.io.File.class,
+ };
+
+ /**
+ * Check if this class is one of the supported types.
+ * @param ret
+ * @return true if the class is a supported type.
+ */
+ private boolean supportedType(Class ret) {
+ for (int i = 0; i < supportedTypes.length; i++) {
+ if (ret == supportedTypes[i]) {
+ return true;
+ }
+ }
+ if (isBeanCompatible(ret)) {
+ return true;
+ }
+ return false;
}
+ /**
+ * Check if this class conforms to JavaBeans specifications.
+ * @param javaType
+ * @return
+ */
+ protected boolean isBeanCompatible(Class javaType) {
+ // Must be a non-primitive and non array
+ if (javaType.isArray() || javaType.isPrimitive()) {
+ return false;
+ }
+
+ // Anything in the java or javax package that
+ // does not have a defined mapping is excluded.
+ if (javaType.getName().startsWith("java.") ||
+ javaType.getName().startsWith("javax.")) {
+ return false;
+ }
+
+ try {
+ javaType.getConstructor(new Class[]{});
+ } catch (java.lang.NoSuchMethodException e) {
+ return false;
+ }
+
+ // Make sure superclass is compatible
+ Class superClass = javaType.getSuperclass();
+ if (superClass != null &&
+ superClass != java.lang.Object.class &&
+ superClass != java.lang.Exception.class &&
+ superClass != java.lang.Throwable.class) {
+ if (!isBeanCompatible(superClass)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
/** Process the methods and extract 'attributes', methods, etc
*
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org