[jboss-cvs] JBossAS SVN: r84826 - in projects/jboss-man/branches/Branch_2_1: managed/src/main/java/org/jboss/managed/api/annotation and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 26 16:34:19 EST 2009
Author: scott.stark at jboss.org
Date: 2009-02-26 16:34:19 -0500 (Thu, 26 Feb 2009)
New Revision: 84826
Modified:
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/annotation/ManagementObject.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectPopulator.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ClassLoadingMXBeanMO.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/GarbageCollectorMXBeanMO.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ManagementFactoryUtils.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryMXBeanMO.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryManagerMXBeanMO.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryPoolMXBeanMO.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/OperatingSystemMXBeanMO.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/RuntimeMXBeanMO.java
projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ThreadMXBeanMO.java
projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/test/PlatformMBeanUnitTestCase.java
projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/AbstractMetaType.java
projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/ArrayMetaType.java
projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/MetaType.java
projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/SimpleMetaType.java
projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java
projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java
projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.java
projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.java
projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java
projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java
Log:
JBMAN-59, Need a primitive notion added to SimpleMetaType
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/ManagedOperation.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -79,6 +79,12 @@
public ManagedParameter[] getParameters();
/**
+ * Get the operation signature
+ * @return
+ */
+ public String[] getReflectionSignature();
+
+ /**
* Invoke the operation given its parameter values.
*
* @param param the varags for the operation parameters.
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/annotation/ManagementObject.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/annotation/ManagementObject.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/api/annotation/ManagementObject.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -57,7 +57,7 @@
/** The metadata attachment name for the ManagedObject */
String attachmentName() default AnnotationDefaults.EMPTY_STRING;
/** Is this a runtime extension of another ManagedObject. This
- * is used to tie together
+ * is used to tie together runtime components with metadata
*/
boolean isRuntime() default false;
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/ManagedOperationImpl.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -54,7 +54,7 @@
this.description = description;
this.impact = impact;
this.name = name;
- this.parameters = parameters;
+ this.setParameters(parameters);
this.returnType = returnType;
}
@@ -96,6 +96,8 @@
public void setParameters(ManagedParameter[] parameters)
{
this.parameters = parameters;
+ if(this.parameters == null)
+ this.parameters = new ManagedParameter[0];
}
public MetaType getReturnType()
@@ -108,6 +110,17 @@
this.returnType = returnType;
}
+
+ public String[] getReflectionSignature()
+ {
+ String[] signature = new String[parameters.length];
+ for(int i=0; i < parameters.length; i++)
+ {
+ signature[i] = parameters[i].getMetaType().getTypeName();
+ }
+ return signature;
+ }
+
/**
* This does not have a meaningful implementation because the target
* is unknown. A runtime aspect that understand the context of this
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -775,6 +775,9 @@
ManagedObjectImpl result = new ManagedObjectImpl(name, properties);
result.setAnnotations(moAnnotations);
+ // Set the component name to name if this is a runtime MO with a name specified
+ if (isRuntime && name.equals(classInfo.getName()) == false)
+ result.setComponentName(name);
if (nameType != null)
result.setNameType(nameType);
if (attachmentName != null)
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectPopulator.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectPopulator.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectPopulator.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -245,8 +245,9 @@
}
if (componentName == null)
componentName = icf.getComponentName(null, null, object, null);
- // set it, even if it's null
- managedObject.setComponentName(componentName);
+ // set it, even if it's null, but not if its already been set
+ if (managedObject.getComponentName() == null)
+ managedObject.setComponentName(componentName);
}
private static <X extends Annotation> X getAnnotation(Class<X> clazz, Map<String, Annotation> annotations,
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ClassLoadingMXBeanMO.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ClassLoadingMXBeanMO.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ClassLoadingMXBeanMO.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -36,6 +36,7 @@
* @version $Revision:$
*/
@ManagementObject(name=ManagementFactory.CLASS_LOADING_MXBEAN_NAME,
+ isRuntime=true,
componentType=@ManagementComponent(type="MBean", subtype="Platform"),
targetInterface=ClassLoadingMXBean.class)
public class ClassLoadingMXBeanMO implements ClassLoadingMXBean
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/GarbageCollectorMXBeanMO.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/GarbageCollectorMXBeanMO.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/GarbageCollectorMXBeanMO.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -39,6 +39,7 @@
* @version $Revision$
*/
@ManagementObject(
+ isRuntime=true,
componentType=@ManagementComponent(type="MBean", subtype="Platform"),
targetInterface=GarbageCollectorMXBean.class)
public class GarbageCollectorMXBeanMO implements GarbageCollectorMXBean
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ManagementFactoryUtils.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ManagementFactoryUtils.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ManagementFactoryUtils.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -54,6 +54,7 @@
import org.jboss.metatype.api.types.ArrayMetaType;
import org.jboss.metatype.api.types.CompositeMetaType;
import org.jboss.metatype.api.types.EnumMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.ArrayValue;
@@ -243,7 +244,7 @@
return ti;
}
- private static OpenType getOpenType(MetaType type) throws OpenDataException
+ static OpenType getOpenType(MetaType type) throws OpenDataException
{
OpenType openType = null;
if(type instanceof SimpleMetaType)
@@ -259,29 +260,33 @@
return openType;
}
- private static OpenType getOpenType(SimpleMetaType type)
+ static OpenType getOpenType(SimpleMetaType type)
{
OpenType openType = null;
- if(type == SimpleMetaType.BOOLEAN)
+ if(type.equalsIgnorePrimitive(SimpleMetaType.BOOLEAN))
openType = SimpleType.BOOLEAN;
- else if(type == SimpleMetaType.LONG)
+ else if(type.equalsIgnorePrimitive(SimpleMetaType.BYTE))
+ openType = SimpleType.BYTE;
+ else if(type.equalsIgnorePrimitive(SimpleMetaType.CHARACTER))
+ openType = SimpleType.CHARACTER;
+ else if(type.equalsIgnorePrimitive(SimpleMetaType.LONG))
openType = SimpleType.LONG;
- else if(type == SimpleMetaType.INTEGER)
+ else if(type.equalsIgnorePrimitive(SimpleMetaType.INTEGER))
openType = SimpleType.INTEGER;
- else if(type == SimpleMetaType.SHORT)
+ else if(type.equalsIgnorePrimitive(SimpleMetaType.SHORT))
openType = SimpleType.SHORT;
- else if(type == SimpleMetaType.STRING)
+ else if(type.equalsIgnorePrimitive(SimpleMetaType.STRING))
openType = SimpleType.STRING;
return openType;
}
- private static ArrayType getOpenType(ArrayMetaType type) throws OpenDataException
+ static ArrayType getOpenType(ArrayMetaType type) throws OpenDataException
{
int dimension = type.getDimension();
OpenType elementType = getOpenType(type.getElementType());
ArrayType openType = new ArrayType(dimension, elementType);
return openType;
}
- private static CompositeType getOpenType(CompositeMetaType type)
+ static CompositeType getOpenType(CompositeMetaType type)
throws OpenDataException
{
String[] items = new String[type.itemSet().size()];
@@ -301,7 +306,7 @@
return ct;
}
- private static Object getOpenValue(MetaValue mv) throws OpenDataException
+ static Object getOpenValue(MetaValue mv) throws OpenDataException
{
Object openValue = null;
if(mv instanceof SimpleValue)
@@ -356,5 +361,68 @@
throw new OpenDataException("Unhandled MetaValue: "+mv);
}
return openValue;
- }
+ }
+
+ static MetaType getMetaType(OpenType type)
+ throws Exception
+ {
+ MetaType metaType = null;
+ if(type instanceof SimpleType)
+ metaType = getMetaType(SimpleType.class.cast(type));
+ else if(type instanceof CompositeType)
+ metaType = getMetaType(CompositeType.class.cast(type));
+ else if(type instanceof ArrayType)
+ metaType = getMetaType(ArrayType.class.cast(type));
+ else
+ throw new Exception("Unhandled OpenType: "+type);
+ return metaType;
+ }
+ static SimpleMetaType getMetaType(SimpleType type)
+ {
+ SimpleMetaType metaType = null;
+ if(type == SimpleType.BOOLEAN)
+ metaType = SimpleMetaType.BOOLEAN;
+ else if(type == SimpleType.BYTE)
+ metaType = SimpleMetaType.BYTE;
+ else if(type == SimpleType.CHARACTER)
+ metaType = SimpleMetaType.CHARACTER;
+ else if(type == SimpleType.LONG)
+ metaType = SimpleMetaType.LONG;
+ else if(type == SimpleType.INTEGER)
+ metaType = SimpleMetaType.INTEGER;
+ else if(type == SimpleType.SHORT)
+ metaType = SimpleMetaType.SHORT;
+ else if(type == SimpleType.STRING)
+ metaType = SimpleMetaType.STRING;
+ return metaType;
+ }
+ static ArrayMetaType getMetaType(ArrayType type)
+ throws Exception
+ {
+ int dimension = type.getDimension();
+ OpenType elementType = type.getElementOpenType();
+ MetaType elementMetaType = getMetaType(elementType);
+ ArrayMetaType metaType = new ArrayMetaType(dimension, elementMetaType);
+ return metaType;
+ }
+ static CompositeMetaType getMetaType(CompositeType type)
+ throws Exception
+ {
+ String[] itemNames = new String[type.keySet().size()];
+ String[] itemDescriptions = new String[itemNames.length];
+ MetaType[] itemTypes = new MetaType[itemNames.length];
+ type.keySet().toArray(itemNames);
+ for(int n = 0; n < itemNames.length; n ++)
+ {
+ String itemName = itemNames[n];
+ itemDescriptions[n] = type.getDescription(itemName);
+ OpenType ot = type.getType(itemName);
+ itemTypes[n] = getMetaType(ot);
+ }
+
+ String typeName = type.getTypeName();
+ String description = type.getDescription();
+ CompositeMetaType cmt = new ImmutableCompositeMetaType(typeName, description, itemNames, itemDescriptions, itemTypes);
+ return cmt;
+ }
}
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryMXBeanMO.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryMXBeanMO.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryMXBeanMO.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -38,6 +38,7 @@
* @version $Revision:$
*/
@ManagementObject(name=ManagementFactory.MEMORY_MXBEAN_NAME,
+ isRuntime=true,
componentType=@ManagementComponent(type="MBean", subtype="Platform"),
targetInterface=MemoryMXBean.class)
public class MemoryMXBeanMO implements MemoryMXBean
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryManagerMXBeanMO.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryManagerMXBeanMO.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryManagerMXBeanMO.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -37,6 +37,7 @@
* @version $Revision:$
*/
@ManagementObject(
+ isRuntime=true,
componentType=@ManagementComponent(type="MBean", subtype="Platform"),
targetInterface=MemoryManagerMXBean.class)
public class MemoryManagerMXBeanMO implements MemoryManagerMXBean
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryPoolMXBeanMO.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryPoolMXBeanMO.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/MemoryPoolMXBeanMO.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -40,6 +40,7 @@
* @version $Revision:$
*/
@ManagementObject(
+ isRuntime=true,
componentType=@ManagementComponent(type="MBean", subtype="Platform"),
targetInterface=MemoryPoolMXBean.class)
public class MemoryPoolMXBeanMO implements MemoryPoolMXBean
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/OperatingSystemMXBeanMO.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/OperatingSystemMXBeanMO.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/OperatingSystemMXBeanMO.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -36,6 +36,7 @@
* @version $Revision:$
*/
@ManagementObject(name=ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME,
+ isRuntime=true,
componentType=@ManagementComponent(type="MBean", subtype="Platform"),
targetInterface=OperatingSystemMXBean.class)
public class OperatingSystemMXBeanMO implements OperatingSystemMXBean
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/RuntimeMXBeanMO.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/RuntimeMXBeanMO.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/RuntimeMXBeanMO.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -38,6 +38,7 @@
* @version $Revision:$
*/
@ManagementObject(name=ManagementFactory.RUNTIME_MXBEAN_NAME,
+ isRuntime=true,
componentType=@ManagementComponent(type="MBean", subtype="Platform"),
targetInterface=RuntimeMXBean.class)
public class RuntimeMXBeanMO implements RuntimeMXBean
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ThreadMXBeanMO.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ThreadMXBeanMO.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/jmx/ThreadMXBeanMO.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -38,6 +38,7 @@
* @version $Revision:$
*/
@ManagementObject(name=ManagementFactory.THREAD_MXBEAN_NAME,
+ isRuntime=true,
componentType=@ManagementComponent(type="MBean", subtype="Platform"),
targetInterface=ThreadMXBean.class)
public class ThreadMXBeanMO implements ThreadMXBean
Modified: projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/test/PlatformMBeanUnitTestCase.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/test/PlatformMBeanUnitTestCase.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/managed/src/test/java/org/jboss/test/managed/factory/test/PlatformMBeanUnitTestCase.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -31,12 +31,19 @@
import java.lang.management.RuntimeMXBean;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
+import java.lang.reflect.Method;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
import junit.framework.Test;
@@ -48,6 +55,7 @@
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.managed.api.factory.ManagedObjectFactory;
import org.jboss.managed.plugins.ManagedOperationMatcher;
+import org.jboss.managed.plugins.jmx.CompositeDataMetaValueBuilder;
import org.jboss.managed.plugins.jmx.ManagementFactoryUtils;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.CompositeValue;
@@ -99,13 +107,14 @@
assertNotNull(mo);
assertEquals(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, mo.getName());
validateComponentType(mo);
+ assertEquals(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, mo.getComponentName());
Map<String, ManagedProperty> props = mo.getProperties();
assertNotNull(props);
// totalLoadedClassCount
ManagedProperty totalLoadedClassCount = props.get("totalLoadedClassCount");
assertNotNull(totalLoadedClassCount);
- assertEquals(SimpleMetaType.LONG, totalLoadedClassCount.getMetaType());
+ assertEquals(SimpleMetaType.LONG_PRIMITIVE, totalLoadedClassCount.getMetaType());
assertEquals("the total number of classes loaded.", totalLoadedClassCount.getDescription());
SimpleValue totalLoadedClassCountSV = SimpleValue.class.cast(totalLoadedClassCount.getValue());
assertNotNull(totalLoadedClassCountSV);
@@ -115,7 +124,7 @@
// loadedClassCount
ManagedProperty loadedClassCount = props.get("loadedClassCount");
assertNotNull(loadedClassCount);
- assertEquals(SimpleMetaType.INTEGER, loadedClassCount.getMetaType());
+ assertEquals(SimpleMetaType.INTEGER_PRIMITIVE, loadedClassCount.getMetaType());
assertEquals("the number of currently loaded classes.", loadedClassCount.getDescription());
SimpleValue loadedClassCountSV = SimpleValue.class.cast(loadedClassCount.getValue());
assertNotNull(loadedClassCountSV);
@@ -124,7 +133,7 @@
// unloadedClassCount
ManagedProperty unloadedClassCount = props.get("unloadedClassCount");
assertNotNull(unloadedClassCount);
- assertEquals(SimpleMetaType.LONG, unloadedClassCount.getMetaType());
+ assertEquals(SimpleMetaType.LONG_PRIMITIVE, unloadedClassCount.getMetaType());
assertEquals("the total number of unloaded classes.", unloadedClassCount.getDescription());
SimpleValue unloadedClassCountSV = SimpleValue.class.cast(unloadedClassCount.getValue());
assertNotNull(unloadedClassCountSV);
@@ -132,7 +141,7 @@
// verbose
ManagedProperty verbose = props.get("verbose");
assertNotNull(verbose);
- assertEquals(SimpleMetaType.BOOLEAN, verbose.getMetaType());
+ assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, verbose.getMetaType());
assertEquals("the verbose output flag for the class loading system.", verbose.getDescription());
SimpleValue verboseSV = SimpleValue.class.cast(verbose.getValue());
assertNotNull(verboseSV);
@@ -187,7 +196,7 @@
// verbose
ManagedProperty verbose = props.get("verbose");
assertNotNull(verbose);
- assertEquals(SimpleMetaType.BOOLEAN, verbose.getMetaType());
+ assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, verbose.getMetaType());
assertEquals("the verbose output flag for the memory system.", verbose.getDescription());
SimpleValue verboseSV = SimpleValue.class.cast(verbose.getValue());
assertNotNull(verboseSV);
@@ -218,7 +227,13 @@
// Test ThreadInfo MetaValue wrap/unwrap
MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
+ CompositeDataMetaValueBuilder builder = new CompositeDataMetaValueBuilder();
+ builder.setMetaValueFactory(metaValueFactory);
+ metaValueFactory.setBuilder(CompositeData.class, builder);
+ metaValueFactory.setBuilder(CompositeDataSupport.class, builder);
+
MetaValue threadInfoMV = metaValueFactory.create(threadInfo);
+ log.debug("ThreadInfo.MV: "+threadInfoMV);
assertTrue(threadInfoMV instanceof CompositeValue);
CompositeValue tiCV = CompositeValue.class.cast(threadInfoMV);
ThreadInfo threadInfo2 = ManagementFactoryUtils.unwrapThreadInfo(tiCV);
@@ -291,11 +306,67 @@
assertEquals("Ops count is 8", 8, ops.size());
ManagedOperation getThreadInfo = ManagedOperationMatcher.findOperation(ops,
- "getThreadInfo", SimpleMetaType.LONG, SimpleMetaType.INTEGER);
+ "getThreadInfo", SimpleMetaType.LONG_PRIMITIVE, SimpleMetaType.INTEGER_PRIMITIVE);
assertNotNull("getThreadInfo", getThreadInfo);
log.debug(getThreadInfo);
+ String[] getThreadInfoSig = getThreadInfo.getReflectionSignature();
+ String[] getThreadInfoSigExpected = {"long", "int"};
+ assertEquals(Arrays.asList(getThreadInfoSigExpected), Arrays.asList(getThreadInfoSig));
+ ManagedOperation resetPeakThreadCount = ManagedOperationMatcher.findOperation(ops,
+ "resetPeakThreadCount");
+ assertNotNull("resetPeakThreadCount", resetPeakThreadCount);
+ assertEquals(0, resetPeakThreadCount.getReflectionSignature().length);
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ ObjectName tname = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
+ MBeanInfo tinfo = server.getMBeanInfo(tname);
+ MBeanOperationInfo[] tops = tinfo.getOperations();
+ assertEquals(8, tops.length);
+ for(MBeanOperationInfo op : tops)
+ {
+ MBeanParameterInfo[] params = op.getSignature();
+ String sig = "";
+ if(params != null)
+ {
+ for(MBeanParameterInfo param : params)
+ {
+ if(sig.length() > 0)
+ sig += ",";
+ sig += param.getType();
+ }
+ }
+ log.debug(op.getName()+"("+sig+")");
+ }
+ Object[] params = {threadID};
+ String[] signature = {"long"};
+ Object result = server.invoke(tname, "getThreadInfo", params, signature);
+ threadInfo = mbean.getThreadInfo(threadID);
+ log.debug("getThreadInfo()-OpenType: "+result);
+ assertTrue(result instanceof CompositeDataSupport);
+ MetaValue resultMV = metaValueFactory.create(result);
+ assertTrue(resultMV instanceof CompositeValue);
+ CompositeValue resultCV = (CompositeValue) resultMV;
+ log.debug("getThreadInfo()-MetaType: "+resultCV);
+ ThreadInfo resultTI = ManagementFactoryUtils.unwrapThreadInfo(resultCV);
+ threadInfo2 = resultTI;
+ assertEquals(threadInfo.getLockOwnerName(), threadInfo2.getLockOwnerName());
+ assertEquals(threadInfo.getThreadName(), threadInfo2.getThreadName());
+ assertEquals(threadInfo.isInNative(), threadInfo2.isInNative());
+ assertEquals(threadInfo.getBlockedCount(), threadInfo2.getBlockedCount());
+ assertEquals(threadInfo.getBlockedTime(), threadInfo2.getBlockedTime());
+ assertEquals(threadInfo.getLockOwnerId(), threadInfo2.getLockOwnerId());
+ assertEquals(threadInfo.getThreadId(), threadInfo2.getThreadId());
+ assertEquals(threadInfo.getThreadState(), threadInfo2.getThreadState());
+ assertEquals(threadInfo.getWaitedCount(), threadInfo2.getWaitedCount());
+ assertEquals(threadInfo.getWaitedTime(), threadInfo2.getWaitedTime());
+ st = threadInfo.getStackTrace();
+ st2 = threadInfo2.getStackTrace();
+ for(int n = 0; n < st.length; n ++)
+ {
+ assertEquals(st[n], st2[n]);
+ }
+
}
public void testRuntimeMXBean()
@@ -436,4 +507,16 @@
assertEquals("Platform", mc.subtype());
}
+ static class X
+ {
+ public int m0(int i)
+ {
+ return 0;
+ }
+ public Integer m1(Integer i)
+ {
+ return 0;
+ }
+ }
+
}
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/AbstractMetaType.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/AbstractMetaType.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/AbstractMetaType.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -138,6 +138,11 @@
return false;
}
+ public boolean isPrimitive()
+ {
+ return false;
+ }
+
public boolean isGeneric()
{
return false;
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/ArrayMetaType.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/ArrayMetaType.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/ArrayMetaType.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -111,6 +111,8 @@
{
if (typeName.equals(typeDescr[PRIMITIVE_WRAPPER_NAME_INDEX]))
return (String) typeDescr[PRIMITIVE_TYPE_ENCODING_INDEX];
+ else if(typeName.equals(typeDescr[PRIMITIVE_TYPE_NAME_INDEX]))
+ return (String) typeDescr[PRIMITIVE_TYPE_ENCODING_INDEX];
}
return null;
}
@@ -127,6 +129,8 @@
{
if (typeName.equals(typeDescr[PRIMITIVE_WRAPPER_NAME_INDEX]))
return (String) typeDescr[PRIMITIVE_TYPE_NAME_INDEX];
+ else if(typeName.equals(typeDescr[PRIMITIVE_TYPE_NAME_INDEX]))
+ return (String) typeDescr[PRIMITIVE_TYPE_NAME_INDEX];
}
return null;
}
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/MetaType.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/MetaType.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/MetaType.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -82,6 +82,14 @@
Long.class.getName(),
Float.class.getName(),
Double.class.getName(),
+ boolean.class.getName(),
+ char.class.getName(),
+ byte.class.getName(),
+ short.class.getName(),
+ int.class.getName(),
+ long.class.getName(),
+ float.class.getName(),
+ double.class.getName(),
String.class.getName(),
Date.class.getName(),
BigDecimal.class.getName(),
@@ -148,6 +156,12 @@
boolean isSimple();
/**
+ * Retrieve whether the class name of the type is a java primitive type.
+ * @return
+ */
+ boolean isPrimitive();
+
+ /**
* Retrieve whether the class name of the type is generic
*
* @return true when it is generic or false otherwise
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/SimpleMetaType.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/SimpleMetaType.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/types/SimpleMetaType.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -68,30 +68,38 @@
/** The simple type for java.lang.Boolean */
public static final SimpleMetaType BOOLEAN;
+ public static final SimpleMetaType BOOLEAN_PRIMITIVE;
/** The simple type for java.lang.Byte */
public static final SimpleMetaType BYTE;
+ public static final SimpleMetaType BYTE_PRIMITIVE;
/** The simple type for java.lang.Character */
public static final SimpleMetaType CHARACTER;
+ public static final SimpleMetaType CHARACTER_PRIMITIVE;
/** The simple type for java.lang.Date */
public static final SimpleMetaType DATE;
/** The simple type for java.lang.Double */
public static final SimpleMetaType DOUBLE;
+ public static final SimpleMetaType DOUBLE_PRIMITIVE;
/** The simple type for java.lang.Float */
public static final SimpleMetaType FLOAT;
+ public static final SimpleMetaType FLOAT_PRIMITIVE;
/** The simple type for java.lang.Integer */
public static final SimpleMetaType INTEGER;
+ public static final SimpleMetaType INTEGER_PRIMITIVE;
/** The simple type for java.lang.Long */
public static final SimpleMetaType LONG;
+ public static final SimpleMetaType LONG_PRIMITIVE;
/** The simple type for java.lang.Short */
public static final SimpleMetaType SHORT;
+ public static final SimpleMetaType SHORT_PRIMITIVE;
/** The simple type for java.lang.String */
public static final SimpleMetaType STRING;
@@ -104,20 +112,30 @@
/** The comparator */
private transient Comparator comparator;
+ /** */
+ private transient char primitiveType;
static
{
BIGDECIMAL = new SimpleMetaType(BigDecimal.class, BigDecimalComparator.INSTANCE);
BIGINTEGER = new SimpleMetaType(BigInteger.class, BigIntegerComparator.INSTANCE);
- BOOLEAN = new SimpleMetaType(Boolean.class, BooleanComparator.INSTANCE);
- BYTE = new SimpleMetaType(Byte.class, ByteComparator.INSTANCE);
- CHARACTER = new SimpleMetaType(Character.class, CharacterComparator.INSTANCE);
+ BOOLEAN = new SimpleMetaType(Boolean.class, BooleanComparator.INSTANCE, 'Z');
+ BOOLEAN_PRIMITIVE = new SimpleMetaType(boolean.class, BooleanComparator.INSTANCE, 'Z');
+ BYTE = new SimpleMetaType(Byte.class, ByteComparator.INSTANCE, 'B');
+ BYTE_PRIMITIVE = new SimpleMetaType(byte.class, ByteComparator.INSTANCE, 'B');
+ CHARACTER = new SimpleMetaType(Character.class, CharacterComparator.INSTANCE, 'C');
+ CHARACTER_PRIMITIVE = new SimpleMetaType(char.class, CharacterComparator.INSTANCE, 'C');
DATE = new SimpleMetaType(Date.class, DateComparator.INSTANCE);
- DOUBLE = new SimpleMetaType(Double.class, DoubleComparator.INSTANCE);
- FLOAT = new SimpleMetaType(Float.class, FloatComparator.INSTANCE);
- INTEGER = new SimpleMetaType(Integer.class, IntegerComparator.INSTANCE);
- LONG = new SimpleMetaType(Long.class, LongComparator.INSTANCE);
- SHORT = new SimpleMetaType(Short.class, ShortComparator.INSTANCE);
+ DOUBLE = new SimpleMetaType(Double.class, DoubleComparator.INSTANCE, 'D');
+ DOUBLE_PRIMITIVE = new SimpleMetaType(double.class, DoubleComparator.INSTANCE, 'D');
+ FLOAT = new SimpleMetaType(Float.class, FloatComparator.INSTANCE, 'F');
+ FLOAT_PRIMITIVE = new SimpleMetaType(float.class, FloatComparator.INSTANCE, 'F');
+ INTEGER = new SimpleMetaType(Integer.class, IntegerComparator.INSTANCE, 'I');
+ INTEGER_PRIMITIVE = new SimpleMetaType(int.class, IntegerComparator.INSTANCE, 'I');
+ LONG = new SimpleMetaType(Long.class, LongComparator.INSTANCE, 'J');
+ LONG_PRIMITIVE = new SimpleMetaType(long.class, LongComparator.INSTANCE, 'J');
+ SHORT = new SimpleMetaType(Short.class, ShortComparator.INSTANCE, 'S');
+ SHORT_PRIMITIVE = new SimpleMetaType(short.class, ShortComparator.INSTANCE, 'S');
STRING = new SimpleMetaType(String.class, StringComparator.INSTANCE);
NAMEDOBJECT = new SimpleMetaType(Name.class, NamedComparator.INSTANCE);
VOID = new SimpleMetaType(Void.class, null);
@@ -152,22 +170,38 @@
throw new IllegalArgumentException("Null class name");
if (className.equals(STRING.getClassName()))
return STRING;
- if (className.equals(INTEGER.getClassName()) || className.equals(Integer.TYPE.getName()))
+ if (className.equals(INTEGER.getClassName()))
return INTEGER;
- if (className.equals(BOOLEAN.getClassName()) || className.equals(Boolean.TYPE.getName()))
+ if (className.equals(Integer.TYPE.getName()))
+ return INTEGER_PRIMITIVE;
+ if (className.equals(BOOLEAN.getClassName()))
return BOOLEAN;
- if (className.equals(LONG.getClassName()) || className.equals(Long.TYPE.getName()))
+ if (className.equals(Boolean.TYPE.getName()))
+ return BOOLEAN_PRIMITIVE;
+ if (className.equals(LONG.getClassName()))
return LONG;
- if (className.equals(BYTE.getClassName()) || className.equals(Byte.TYPE.getName()))
+ if ( className.equals(Long.TYPE.getName()))
+ return LONG_PRIMITIVE;
+ if (className.equals(BYTE.getClassName()))
return BYTE;
- if (className.equals(CHARACTER.getClassName()) || className.equals(Character.TYPE.getName()))
+ if (className.equals(Byte.TYPE.getName()))
+ return BYTE_PRIMITIVE;
+ if (className.equals(CHARACTER.getClassName()))
return CHARACTER;
- if (className.equals(DOUBLE.getClassName()) || className.equals(Double.TYPE.getName()))
+ if (className.equals(Character.TYPE.getName()))
+ return CHARACTER_PRIMITIVE;
+ if (className.equals(DOUBLE.getClassName()))
return DOUBLE;
- if (className.equals(FLOAT.getClassName()) || className.equals(Float.TYPE.getName()))
+ if (className.equals(Double.TYPE.getName()))
+ return DOUBLE_PRIMITIVE;
+ if (className.equals(FLOAT.getClassName()))
return FLOAT;
- if (className.equals(SHORT.getClassName()) || className.equals(Short.TYPE.getName()))
+ if(className.equals(Float.TYPE.getName()))
+ return FLOAT_PRIMITIVE;
+ if (className.equals(SHORT.getClassName()))
return SHORT;
+ if (className.equals(Short.TYPE.getName()))
+ return SHORT_PRIMITIVE;
if (className.equals(BIGDECIMAL.getClassName()))
return BIGDECIMAL;
if (className.equals(BIGINTEGER.getClassName()))
@@ -206,8 +240,13 @@
*/
private <T> SimpleMetaType(Class<T> clazz, Comparator<T> comparator)
{
+ this(clazz, comparator, '\0');
+ }
+ private <T> SimpleMetaType(Class<T> clazz, Comparator<T> comparator, char primitiveType)
+ {
this(clazz.getName());
this.comparator = comparator;
+ this.primitiveType = primitiveType;
}
/**
@@ -236,6 +275,13 @@
}
@Override
+ public boolean isPrimitive()
+ {
+ return primitiveType != '\0'
+ && this.getTypeName().startsWith("java.lang") == false;
+ }
+
+ @Override
public boolean isValue(Object obj)
{
if (obj == null || obj instanceof SimpleValue == false)
@@ -269,6 +315,18 @@
}
/**
+ *
+ * @return
+ */
+ public boolean equalsIgnorePrimitive(Object obj)
+ {
+ if (obj == null || obj instanceof SimpleMetaType == false)
+ return false;
+ SimpleMetaType other = (SimpleMetaType) obj;
+ return this.primitiveType == other.primitiveType;
+ }
+
+ /**
* Resolve to the singletons
* @return the singletons
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/api/values/SimpleValueSupport.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -57,9 +57,45 @@
if (object == null)
return null;
String className = object.getClass().getName();
+ return wrap(object, className);
+ }
+ private static SimpleValue wrap(Serializable object, String className)
+ {
SimpleMetaType metaType = SimpleMetaType.resolve(className);
return new SimpleValueSupport(metaType, object);
}
+ public static SimpleValue wrap(boolean value)
+ {
+ return wrap(value, boolean.class.getName());
+ }
+ public static SimpleValue wrap(byte value)
+ {
+ return wrap(value, byte.class.getName());
+ }
+ public static SimpleValue wrap(char value)
+ {
+ return wrap(value, char.class.getName());
+ }
+ public static SimpleValue wrap(short value)
+ {
+ return wrap(value, short.class.getName());
+ }
+ public static SimpleValue wrap(int value)
+ {
+ return wrap(value, int.class.getName());
+ }
+ public static SimpleValue wrap(long value)
+ {
+ return wrap(value, long.class.getName());
+ }
+ public static SimpleValue wrap(float value)
+ {
+ return wrap(value, float.class.getName());
+ }
+ public static SimpleValue wrap(double value)
+ {
+ return wrap(value, double.class.getName());
+ }
/**
* Create a new SimpleValueSupport.
@@ -112,7 +148,11 @@
SimpleValue other = (SimpleValue) obj;
if (metaType.equals(other.getMetaType()) == false)
- return false;
+ {
+ // Check equivalent types
+ if (metaType.equalsIgnorePrimitive(other.getMetaType()) == false)
+ return false;
+ }
Object otherValue = other.getValue();
if (value == null && otherValue == null)
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/main/java/org/jboss/metatype/plugins/types/DefaultMetaTypeFactory.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -289,7 +289,8 @@
componentType = ((ArrayInfo) componentType).getComponentType();
}
MetaType componentMetaType = resolve(componentType);
- return new ArrayMetaType(dimension, componentMetaType, componentType.isPrimitive());
+ boolean isPrimitive = componentType.isPrimitive();
+ return new ArrayMetaType(dimension, componentMetaType, isPrimitive);
}
/**
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/ArrayMetaTypeFactoryUnitTestCase.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -79,6 +79,20 @@
MetaType result = resolve(array.getClass());
ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class);
+ ArrayMetaType expected = new ArrayMetaType(1, SimpleMetaType.CHARACTER_PRIMITIVE);
+ testArray(expected, actual);
+ }
+ public void testCharacterArray()
+ throws Exception
+ {
+ Character[] array = {Character.valueOf('H'),
+ Character.valueOf('e'),
+ Character.valueOf('l'),
+ Character.valueOf('l'),
+ Character.valueOf('o')};
+ MetaType result = resolve(array.getClass());
+
+ ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class);
ArrayMetaType expected = new ArrayMetaType(1, SimpleMetaType.CHARACTER);
testArray(expected, actual);
}
@@ -89,7 +103,7 @@
char[][] array = {{'H', 'e', 'l', 'l', 'o'}};
MetaType result = resolve(array.getClass());
ArrayMetaType actual = assertInstanceOf(result, ArrayMetaType.class);
- ArrayMetaType expected = new ArrayMetaType(2, SimpleMetaType.CHARACTER);
+ ArrayMetaType expected = new ArrayMetaType(2, SimpleMetaType.CHARACTER_PRIMITIVE);
testArray(expected, actual);
}
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/factory/test/SimpleMetaTypeFactoryUnitTestCase.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -63,22 +63,22 @@
SimpleMetaType.BIGDECIMAL,
SimpleMetaType.BIGINTEGER,
SimpleMetaType.BOOLEAN,
- SimpleMetaType.BOOLEAN,
+ SimpleMetaType.BOOLEAN_PRIMITIVE,
SimpleMetaType.BYTE,
- SimpleMetaType.BYTE,
+ SimpleMetaType.BYTE_PRIMITIVE,
SimpleMetaType.CHARACTER,
- SimpleMetaType.CHARACTER,
+ SimpleMetaType.CHARACTER_PRIMITIVE,
SimpleMetaType.DATE,
SimpleMetaType.DOUBLE,
- SimpleMetaType.DOUBLE,
+ SimpleMetaType.DOUBLE_PRIMITIVE,
SimpleMetaType.FLOAT,
- SimpleMetaType.FLOAT,
+ SimpleMetaType.FLOAT_PRIMITIVE,
SimpleMetaType.INTEGER,
- SimpleMetaType.INTEGER,
+ SimpleMetaType.INTEGER_PRIMITIVE,
SimpleMetaType.LONG,
- SimpleMetaType.LONG,
+ SimpleMetaType.LONG_PRIMITIVE,
SimpleMetaType.SHORT,
- SimpleMetaType.SHORT,
+ SimpleMetaType.SHORT_PRIMITIVE,
SimpleMetaType.STRING,
SimpleMetaType.VOID
};
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/test/MetaTypeUnitTestCase.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -76,7 +76,7 @@
public void testAllowedClasses() throws Exception
{
List<String> allowedClassNames = MetaType.ALLOWED_CLASSNAMES;
- assertEquals(21, allowedClassNames.size());
+ assertEquals(29, allowedClassNames.size());
checkMetaType(allowedClassNames, Void.class);
checkMetaType(allowedClassNames, Boolean.class);
checkMetaType(allowedClassNames, Character.class);
@@ -98,6 +98,14 @@
checkMetaType(allowedClassNames, CompositeValue.class);
checkMetaType(allowedClassNames, TableValue.class);
checkMetaType(allowedClassNames, Properties.class);
+ checkMetaType(allowedClassNames, boolean.class);
+ checkMetaType(allowedClassNames, byte.class);
+ checkMetaType(allowedClassNames, char.class);
+ checkMetaType(allowedClassNames, float.class);
+ checkMetaType(allowedClassNames, double.class);
+ checkMetaType(allowedClassNames, int.class);
+ checkMetaType(allowedClassNames, long.class);
+ checkMetaType(allowedClassNames, short.class);
}
/**
Modified: projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java
===================================================================
--- projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java 2009-02-26 21:27:48 UTC (rev 84825)
+++ projects/jboss-man/branches/Branch_2_1/metatype/src/test/java/org/jboss/test/metatype/types/test/SimpleMetaTypeUnitTestCase.java 2009-02-26 21:34:19 UTC (rev 84826)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.metatype.types.test;
+import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
@@ -267,4 +268,153 @@
assertTrue("Should resolve to same object after serialization " + types[i], types[i] == result);
}
}
+
+ public void testBytePrimitives()
+ throws Exception
+ {
+ assertEquals(SimpleMetaType.BYTE_PRIMITIVE, SimpleMetaType.isSimpleType(byte.class.getName()));
+ SimpleMetaType byteType = SimpleMetaType.resolve("byte");
+ assertNotNull(byteType);
+ assertEquals(SimpleMetaType.BYTE_PRIMITIVE, byteType);
+ assertTrue(byteType.isPrimitive());
+ Serializable one = (byte) 1;
+ log.debug("one.class: "+one.getClass());
+ SimpleValue byte1p = SimpleValueSupport.wrap((byte)1);
+ SimpleValue byte1p2 = SimpleValueSupport.wrap((byte)1);
+ assertEquals(SimpleMetaType.BYTE_PRIMITIVE, byte1p.getMetaType());
+ SimpleValue byte1 = SimpleValueSupport.wrap(one);
+ assertEquals(SimpleMetaType.BYTE, byte1.getMetaType());
+ assertEquals(byte1, byte1p);
+ assertEquals(byte1p, byte1p2);
+
+ SimpleValue byte2p = SimpleValueSupport.wrap((byte)2);
+ assertFalse(byte1p.equals(byte2p));
+ }
+ public void testShortPrimitives()
+ throws Exception
+ {
+ assertEquals(SimpleMetaType.SHORT_PRIMITIVE, SimpleMetaType.isSimpleType(short.class.getName()));
+ SimpleMetaType shortType = SimpleMetaType.resolve("short");
+ assertNotNull(shortType);
+ assertEquals(SimpleMetaType.SHORT_PRIMITIVE, shortType);
+ assertTrue(shortType.isPrimitive());
+ Serializable one = (short) 1;
+ log.debug("one.class: "+one.getClass());
+ SimpleValue short1p = SimpleValueSupport.wrap((short)1);
+ SimpleValue short1p2 = SimpleValueSupport.wrap((short)1);
+ assertEquals(SimpleMetaType.SHORT_PRIMITIVE, short1p.getMetaType());
+ SimpleValue short1 = SimpleValueSupport.wrap(one);
+ assertEquals(SimpleMetaType.SHORT, short1.getMetaType());
+ assertEquals(short1, short1p);
+ assertEquals(short1p, short1p2);
+
+ SimpleValue short2p = SimpleValueSupport.wrap((short)2);
+ assertFalse(short1p.equals(short2p));
+ }
+ public void testIntPrimitives()
+ throws Exception
+ {
+ assertEquals(SimpleMetaType.INTEGER_PRIMITIVE, SimpleMetaType.isSimpleType(int.class.getName()));
+ SimpleMetaType intType = SimpleMetaType.resolve("int");
+ assertNotNull(intType);
+ assertEquals(SimpleMetaType.INTEGER_PRIMITIVE, intType);
+ assertTrue(intType.isPrimitive());
+ Serializable one = (int) 1;
+ log.debug("one.class: "+one.getClass());
+ SimpleValue int1p = SimpleValueSupport.wrap((int)1);
+ SimpleValue int1p2 = SimpleValueSupport.wrap((int)1);
+ assertEquals(SimpleMetaType.INTEGER_PRIMITIVE, int1p.getMetaType());
+ SimpleValue int1 = SimpleValueSupport.wrap(one);
+ assertEquals(SimpleMetaType.INTEGER, int1.getMetaType());
+ assertEquals(int1, int1p);
+ assertEquals(int1p, int1p2);
+
+ SimpleValue int2p = SimpleValueSupport.wrap((int)2);
+ assertFalse(int1p.equals(int2p));
+ }
+ public void testLongPrimitives()
+ throws Exception
+ {
+ assertEquals(SimpleMetaType.LONG_PRIMITIVE, SimpleMetaType.isSimpleType(long.class.getName()));
+ SimpleMetaType longType = SimpleMetaType.resolve("long");
+ assertNotNull(longType);
+ assertEquals(SimpleMetaType.LONG_PRIMITIVE, longType);
+ assertTrue(longType.isPrimitive());
+ Serializable one = (long) 1;
+ log.debug("one.class: "+one.getClass());
+ SimpleValue long1p = SimpleValueSupport.wrap((long)1);
+ SimpleValue long1p2 = SimpleValueSupport.wrap((long)1);
+ assertEquals(SimpleMetaType.LONG_PRIMITIVE, long1p.getMetaType());
+ SimpleValue long1 = SimpleValueSupport.wrap(one);
+ assertEquals(SimpleMetaType.LONG, long1.getMetaType());
+ assertEquals(long1, long1p);
+ assertEquals(long1p, long1p2);
+
+ SimpleValue long2p = SimpleValueSupport.wrap((long)2);
+ assertFalse(long1p.equals(long2p));
+ }
+ public void testFloatPrimitives()
+ throws Exception
+ {
+ assertEquals(SimpleMetaType.FLOAT_PRIMITIVE, SimpleMetaType.isSimpleType(float.class.getName()));
+ SimpleMetaType floatType = SimpleMetaType.resolve("float");
+ assertNotNull(floatType);
+ assertTrue(SimpleMetaType.FLOAT_PRIMITIVE == floatType);
+ assertEquals(SimpleMetaType.FLOAT_PRIMITIVE, floatType);
+ assertTrue(floatType.isPrimitive());
+ Serializable pi = 3.14f;
+ log.debug("pi.class: "+pi.getClass());
+ SimpleValue float1p = SimpleValueSupport.wrap(3.14f);
+ SimpleValue float1p2 = SimpleValueSupport.wrap(3.14f);
+ assertEquals(SimpleMetaType.FLOAT_PRIMITIVE, float1p.getMetaType());
+ SimpleValue float1 = SimpleValueSupport.wrap(pi);
+ assertEquals(SimpleMetaType.FLOAT, float1.getMetaType());
+ assertEquals(float1, float1p);
+ assertEquals(float1p, float1p2);
+
+ SimpleValue float2p = SimpleValueSupport.wrap(3.24f);
+ assertFalse(float1p.equals(float2p));
+ }
+ public void testDoublePrimitives()
+ throws Exception
+ {
+ assertEquals(SimpleMetaType.DOUBLE_PRIMITIVE, SimpleMetaType.isSimpleType(double.class.getName()));
+ SimpleMetaType doubleType = SimpleMetaType.resolve("double");
+ assertNotNull(doubleType);
+ assertEquals(SimpleMetaType.DOUBLE_PRIMITIVE, doubleType);
+ assertTrue(doubleType.isPrimitive());
+ Serializable pi = 3.14;
+ log.debug("pi.class: "+pi.getClass());
+ SimpleValue double1p = SimpleValueSupport.wrap(3.14);
+ SimpleValue double1p2 = SimpleValueSupport.wrap(3.14);
+ assertEquals(SimpleMetaType.DOUBLE_PRIMITIVE, double1p.getMetaType());
+ SimpleValue double1 = SimpleValueSupport.wrap(pi);
+ assertEquals(SimpleMetaType.DOUBLE, double1.getMetaType());
+ assertEquals(double1, double1p);
+ assertEquals(double1p, double1p2);
+
+ SimpleValue double2p = SimpleValueSupport.wrap(3.24);
+ assertFalse(double1p.equals(double2p));
+ }
+ public void testBooleanPrimitives()
+ throws Exception
+ {
+ assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, SimpleMetaType.isSimpleType(boolean.class.getName()));
+ SimpleMetaType booleanType = SimpleMetaType.resolve("boolean");
+ assertNotNull(booleanType);
+ assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, booleanType);
+ assertTrue(booleanType.isPrimitive());
+ Serializable b = true;;
+ log.debug("b.class: "+b.getClass());
+ SimpleValue boolean1p = SimpleValueSupport.wrap(true);
+ SimpleValue boolean1p2 = SimpleValueSupport.wrap(true);
+ assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, boolean1p.getMetaType());
+ SimpleValue boolean1 = SimpleValueSupport.wrap(b);
+ assertEquals(SimpleMetaType.BOOLEAN, boolean1.getMetaType());
+ assertEquals(boolean1, boolean1p);
+ assertEquals(boolean1p, boolean1p2);
+
+ SimpleValue boolean2p = SimpleValueSupport.wrap(false);
+ assertFalse(boolean1p.equals(boolean2p));
+ }
}
More information about the jboss-cvs-commits
mailing list