use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class JcaWorkManagerDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
super.registerAttributes(resourceRegistration);
for (final WmParameters parameter : WmParameters.values()) {
AttributeDefinition ad = parameter.getAttribute();
resourceRegistration.registerReadOnlyAttribute(ad, ReadResourceNameOperationStepHandler.INSTANCE);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class IIOPSubsystemAdd method getResourceProperties.
private void getResourceProperties(final Properties properties, PersistentResourceDefinition resource, OperationContext context, ModelNode model) throws OperationFailedException {
for (AttributeDefinition attrDefinition : resource.getAttributes()) {
if (attrDefinition instanceof PropertiesAttributeDefinition) {
PropertiesAttributeDefinition pad = (PropertiesAttributeDefinition) attrDefinition;
ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
if (resolvedModelAttribute.isDefined()) {
for (final Property prop : resolvedModelAttribute.asPropertyList()) {
properties.setProperty(prop.getName(), prop.getValue().asString());
}
}
continue;
}
ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
//FIXME
if (resolvedModelAttribute.isDefined()) {
String name = attrDefinition.getName();
String value = resolvedModelAttribute.asString();
String openjdkProperty = PropertiesMap.PROPS_MAP.get(name);
if (openjdkProperty != null) {
name = openjdkProperty;
}
properties.setProperty(name, value);
}
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class IDMConfigAddStepHandler method configureModelValidators.
private void configureModelValidators(ModelValidationStepHandler[] modelValidators) {
List<AttributeDefinition> alternativeAttributes = new ArrayList<AttributeDefinition>();
for (AttributeDefinition attribute : this.attributes) {
if (attribute.getAlternatives() != null && attribute.getAlternatives().length > 0) {
alternativeAttributes.add(attribute);
}
}
if (!alternativeAttributes.isEmpty()) {
this.modelValidators.add(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()]), isAlternativesRequired()));
}
if (modelValidators != null) {
this.modelValidators.addAll(Arrays.asList(modelValidators));
}
this.modelValidators.add(new ModelValidationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final PathAddress address = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
Resource resource = context.readResourceFromRoot(address);
final ModelNode parentModel = Resource.Tools.readModel(resource);
PartitionManagerAddHandler.INSTANCE.validateModel(context, address.getLastElement().getValue(), parentModel);
context.stepCompleted();
}
});
}
use of org.jboss.as.controller.AttributeDefinition in project camunda-bpm-platform by camunda.
the class CustomMarshaller method getValueType.
/**
* Obtain the 'valueType' of the ObjectListAttributeDefinition through reflection because they are private in Wildfly 8.
*/
public static AttributeDefinition getValueType(Object instance, Class clazz) {
try {
Field valueTypesField = clazz.getDeclaredField("valueType");
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 valueType.", e);
}
}
use of org.jboss.as.controller.AttributeDefinition 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;
}
Aggregations