use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class EESubsystemXmlPersister method writeManagedScheduledExecutorServices.
private void writeManagedScheduledExecutorServices(final XMLExtendedStreamWriter writer, final ModelNode subModel) throws XMLStreamException {
writer.writeStartElement(Element.MANAGED_SCHEDULED_EXECUTOR_SERVICES.getLocalName());
for (Property property : subModel.asPropertyList()) {
writer.writeStartElement(Element.MANAGED_SCHEDULED_EXECUTOR_SERVICE.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
for (SimpleAttributeDefinition ad : ManagedScheduledExecutorServiceResourceDefinition.ATTRIBUTES) {
ad.marshallAsAttribute(property.getValue(), writer);
}
writer.writeEndElement();
}
writer.writeEndElement();
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class DataSourceDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
if (deployed) {
for (final SimpleAttributeDefinition attribute : DATASOURCE_ATTRIBUTE) {
SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLDataSourceRuntimeHandler.INSTANCE);
}
for (final PropertiesAttributeDefinition attribute : DATASOURCE_PROPERTIES_ATTRIBUTES) {
PropertiesAttributeDefinition runtimeAttribute = new PropertiesAttributeDefinition.Builder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLDataSourceRuntimeHandler.INSTANCE);
}
} else {
ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(DATASOURCE_ATTRIBUTE);
CredentialReferenceWriteAttributeHandler credentialReferenceWriteAttributeHandler = new CredentialReferenceWriteAttributeHandler(CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE);
for (final SimpleAttributeDefinition attribute : DATASOURCE_ATTRIBUTE) {
if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
} else if (attribute.getName().equals(ENLISTMENT_TRACE.getName())) {
resourceRegistration.registerReadWriteAttribute(attribute, null, new EnlistmentTraceAttributeWriteHandler());
} else if (attribute.getName().equals(CREDENTIAL_REFERENCE.getName()) || attribute.getName().equals(RECOVERY_CREDENTIAL_REFERENCE.getName())) {
resourceRegistration.registerReadWriteAttribute(attribute, null, credentialReferenceWriteAttributeHandler);
} else {
resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredWriteAttributeHandler);
}
}
ReloadRequiredWriteAttributeHandler reloadRequiredPropertiesWriteHandler = new ReloadRequiredWriteAttributeHandler(DATASOURCE_PROPERTIES_ATTRIBUTES);
for (final PropertiesAttributeDefinition attribute : DATASOURCE_PROPERTIES_ATTRIBUTES) {
if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
} else {
resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredPropertiesWriteHandler);
}
}
}
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class ConnectionPropertyDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
if (deployed) {
SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(Constants.CONNECTION_PROPERTY_VALUE).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLDataSourceRuntimeHandler.INSTANCE);
} else {
resourceRegistration.registerReadOnlyAttribute(Constants.CONNECTION_PROPERTY_VALUE, null);
}
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class AbstractFederationSubsystemReader method parseConfig.
/**
* Reads a element from the stream considering the parameters.
*
* @param reader XMLExtendedStreamReader instance from which the elements are read.
* @param xmlElement Name of the Model Element to be parsed.
* @param key Name of the attribute to be used to as the key for the model.
* @param addOperations List of operations.
* @param lastNode Parent ModelNode instance.
* @param attributes AttributeDefinition instances to be used to extract the attributes and populate the resulting model.
*
* @return A ModelNode instance populated.
*
* @throws javax.xml.stream.XMLStreamException
*/
protected ModelNode parseConfig(XMLExtendedStreamReader reader, ModelElement xmlElement, String key, ModelNode lastNode, List<SimpleAttributeDefinition> attributes, List<ModelNode> addOperations) throws XMLStreamException {
if (!reader.getLocalName().equals(xmlElement.getName())) {
return null;
}
ModelNode modelNode = Util.getEmptyOperation(ADD, null);
int attributeCount = reader.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
String attributeLocalName = reader.getAttributeLocalName(i);
if (ModelElement.forName(attributeLocalName) == null) {
throw unexpectedAttribute(reader, i);
}
}
for (SimpleAttributeDefinition simpleAttributeDefinition : attributes) {
String attributeValue = reader.getAttributeValue("", simpleAttributeDefinition.getXmlName());
simpleAttributeDefinition.parseAndSetParameter(attributeValue, modelNode, reader);
}
String name = xmlElement.getName();
if (key != null) {
name = key;
if (modelNode.hasDefined(key)) {
name = modelNode.get(key).asString();
} else {
String attributeValue = reader.getAttributeValue("", key);
if (attributeValue != null) {
name = attributeValue;
}
}
}
modelNode.get(ModelDescriptionConstants.OP_ADDR).set(lastNode.clone().get(OP_ADDR).add(xmlElement.getName(), name));
addOperations.add(modelNode);
return modelNode;
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class AbstractIDMSubsystemReader method parseConfig.
/**
* Reads a element from the stream considering the parameters.
*
* @param reader XMLExtendedStreamReader instance from which the elements are read.
* @param xmlElement Name of the Model Element to be parsed.
* @param key Name of the attribute to be used to as the key for the model.
* @param addOperations List of operations.
* @param lastNode Parent ModelNode instance.
* @param attributes AttributeDefinition instances to be used to extract the attributes and populate the resulting model.
*
* @return A ModelNode instance populated.
*
* @throws javax.xml.stream.XMLStreamException
*/
protected ModelNode parseConfig(XMLExtendedStreamReader reader, ModelElement xmlElement, String key, ModelNode lastNode, List<SimpleAttributeDefinition> attributes, List<ModelNode> addOperations) throws XMLStreamException {
if (!reader.getLocalName().equals(xmlElement.getName())) {
return null;
}
ModelNode modelNode = Util.getEmptyOperation(ADD, null);
int attributeCount = reader.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
String attributeLocalName = reader.getAttributeLocalName(i);
if (ModelElement.forName(attributeLocalName) == null) {
throw unexpectedAttribute(reader, i);
}
}
for (SimpleAttributeDefinition simpleAttributeDefinition : attributes) {
simpleAttributeDefinition.parseAndSetParameter(reader.getAttributeValue("", simpleAttributeDefinition.getXmlName()), modelNode, reader);
}
String name = xmlElement.getName();
if (key != null) {
name = key;
if (modelNode.hasDefined(key)) {
name = modelNode.get(key).asString();
} else {
String attributeValue = reader.getAttributeValue("", key);
if (attributeValue != null) {
name = attributeValue;
}
}
}
modelNode.get(ModelDescriptionConstants.OP_ADDR).set(lastNode.clone().get(OP_ADDR).add(xmlElement.getName(), name));
addOperations.add(modelNode);
return modelNode;
}
Aggregations