Search in sources :

Example 1 with ObjectTypeAttributeDefinition

use of org.jboss.as.controller.ObjectTypeAttributeDefinition in project camunda-bpm-platform by camunda.

the class CustomMarshaller method getValueTypes.

/**
 * Obtain the 'valueTypes' of the ObjectTypeAttributeDefinition through reflection because they are private in Wildfly 8.
 */
public static AttributeDefinition[] getValueTypes(Object instance, Class clazz) {
    try {
        if (ObjectTypeAttributeDefinition.class.isAssignableFrom(clazz)) {
            Field valueTypesField = clazz.getDeclaredField("valueTypes");
            valueTypesField.setAccessible(true);
            Object value = valueTypesField.get(instance);
            if (value != null) {
                if (AttributeDefinition[].class.isAssignableFrom(value.getClass())) {
                    return (AttributeDefinition[]) value;
                }
            }
            return (AttributeDefinition[]) value;
        }
    } catch (Exception e) {
        throw new RuntimeException("Unable to get valueTypes.", e);
    }
    return null;
}
Also used : Field(java.lang.reflect.Field) ObjectListAttributeDefinition(org.jboss.as.controller.ObjectListAttributeDefinition) ObjectTypeAttributeDefinition(org.jboss.as.controller.ObjectTypeAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) XMLStreamException(javax.xml.stream.XMLStreamException)

Aggregations

Field (java.lang.reflect.Field)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)1 ObjectListAttributeDefinition (org.jboss.as.controller.ObjectListAttributeDefinition)1 ObjectTypeAttributeDefinition (org.jboss.as.controller.ObjectTypeAttributeDefinition)1