use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class JacORBSubsystemAdd method populateModel.
@Override
protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
final ModelNode model = resource.getModel();
for (AttributeDefinition attr : attributes) {
attr.validateAndSet(operation, model);
}
ConfigValidator.validateConfig(context, TransformUtils.transformModel(model));
final boolean adminOnly = context.getRunningMode() == RunningMode.ADMIN_ONLY;
final boolean hostController = context.getProcessType().equals(ProcessType.HOST_CONTROLLER);
// valid
if (adminOnly || !hostController) {
final List<String> unsupportedProperites = TransformUtils.validateDeprecatedProperites(model);
if (!unsupportedProperites.isEmpty()) {
if (adminOnly) {
final String warning = JacORBLogger.ROOT_LOGGER.cannotEmulatePropertiesWarning(unsupportedProperites);
JacORBLogger.ROOT_LOGGER.warn(warning);
} else {
throw JacORBLogger.ROOT_LOGGER.cannotEmulateProperties(unsupportedProperites);
}
}
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class AlternativeAttributeCheckHandler method checkAlternativeAttribute.
private void checkAlternativeAttribute(OperationContext context, String attributeName, boolean alternativeMustBeSet) throws OperationFailedException {
if (attributeDefinitions.containsKey(attributeName)) {
AttributeDefinition attr = attributeDefinitions.get(attributeName);
final Resource resource = context.readResource(EMPTY_ADDRESS);
if (alternativeMustBeSet) {
if (!attr.hasAlternative(resource.getModel())) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.undefineAttributeWithoutAlternative(attributeName));
}
} else {
if (attr.hasAlternative(resource.getModel())) {
throw new OperationFailedException(MessagingLogger.ROOT_LOGGER.altAttributeAlreadyDefined(attributeName));
}
}
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class WebSubsystemParser method writeContent.
/**
* {@inheritDoc}
*/
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
ModelNode node = context.getModelNode();
WebDefinition.DEFAULT_VIRTUAL_SERVER.marshallAsAttribute(node, true, writer);
WebDefinition.INSTANCE_ID.marshallAsAttribute(node, false, writer);
WebDefinition.NATIVE.marshallAsAttribute(node, true, writer);
WebDefinition.DEFAULT_SESSION_TIMEOUT.marshallAsAttribute(node, false, writer);
if (node.hasDefined(CONFIGURATION)) {
writeContainerConfig(writer, node.get(CONFIGURATION));
}
if (node.hasDefined(CONNECTOR)) {
for (final Property connector : node.get(CONNECTOR).asPropertyList()) {
final ModelNode config = connector.getValue();
writer.writeStartElement(Element.CONNECTOR.getLocalName());
writer.writeAttribute(NAME, connector.getName());
List<AttributeDefinition> connectorAttributes = new ArrayList<>(Arrays.asList(WebConnectorDefinition.CONNECTOR_ATTRIBUTES));
if (config.hasDefined(Constants.PROXY_BINDING)) {
connectorAttributes.remove(WebConnectorDefinition.PROXY_PORT);
connectorAttributes.remove(WebConnectorDefinition.PROXY_NAME);
} else {
connectorAttributes.remove(WebConnectorDefinition.PROXY_BINDING);
}
if (config.hasDefined(Constants.REDIRECT_BINDING)) {
connectorAttributes.remove(WebConnectorDefinition.REDIRECT_PORT);
} else {
connectorAttributes.remove(WebConnectorDefinition.REDIRECT_BINDING);
}
for (AttributeDefinition attr : connectorAttributes) {
if (attr instanceof SimpleAttributeDefinition) {
((SimpleAttributeDefinition) attr).marshallAsAttribute(config, true, writer);
}
}
if (config.get(SSL_PATH.getKey(), SSL_PATH.getValue()).isDefined()) {
ModelNode sslConfig = config.get(SSL_PATH.getKey(), SSL_PATH.getValue());
writer.writeStartElement(Element.SSL.getLocalName());
WebSSLDefinition.NAME.marshallAsAttribute(sslConfig, writer);
for (SimpleAttributeDefinition attr : WebSSLDefinition.SSL_ATTRIBUTES) {
attr.marshallAsAttribute(sslConfig, false, writer);
}
writer.writeEndElement();
}
if (config.hasDefined(VIRTUAL_SERVER)) {
for (final ModelNode virtualServer : config.get(VIRTUAL_SERVER).asList()) {
writer.writeEmptyElement(VIRTUAL_SERVER);
writer.writeAttribute(NAME, virtualServer.asString());
}
}
writer.writeEndElement();
}
}
if (node.hasDefined(VIRTUAL_SERVER)) {
for (final Property host : node.get(VIRTUAL_SERVER).asPropertyList()) {
final ModelNode config = host.getValue();
writer.writeStartElement(Element.VIRTUAL_SERVER.getLocalName());
writer.writeAttribute(NAME, host.getName());
WebVirtualHostDefinition.ENABLE_WELCOME_ROOT.marshallAsAttribute(config, true, writer);
WebVirtualHostDefinition.DEFAULT_WEB_MODULE.marshallAsAttribute(config, true, writer);
if (config.hasDefined(ALIAS)) {
for (final ModelNode alias : config.get(ALIAS).asList()) {
writer.writeEmptyElement(ALIAS);
writer.writeAttribute(NAME, alias.asString());
}
}
if (config.get(ACCESS_LOG_PATH.getKey(), ACCESS_LOG_PATH.getValue()).isDefined()) {
ModelNode accessLog = config.get(ACCESS_LOG_PATH.getKey(), ACCESS_LOG_PATH.getValue());
writer.writeStartElement(Element.ACCESS_LOG.getLocalName());
for (SimpleAttributeDefinition attr : WebAccessLogDefinition.ACCESS_LOG_ATTRIBUTES) {
attr.marshallAsAttribute(accessLog, false, writer);
}
if (accessLog.get(DIRECTORY_PATH.getKey(), DIRECTORY_PATH.getValue()).isDefined()) {
ModelNode directory = accessLog.get(DIRECTORY_PATH.getKey(), DIRECTORY_PATH.getValue());
String name = Element.DIRECTORY.getLocalName();
boolean startwritten = false;
startwritten = writeAttribute(writer, WebAccessLogDirectoryDefinition.PATH, directory, startwritten, name);
startwritten = writeAttribute(writer, WebAccessLogDirectoryDefinition.RELATIVE_TO, directory, startwritten, name);
if (startwritten) {
writer.writeEndElement();
}
}
writer.writeEndElement();
}
if (config.hasDefined(REWRITE)) {
for (final ModelNode rewritenode : config.get(REWRITE).asList()) {
Property prop = rewritenode.asProperty();
ModelNode rewrite = prop.getValue();
writer.writeStartElement(REWRITE);
writer.writeAttribute(NAME, prop.getName());
WebReWriteDefinition.PATTERN.marshallAsAttribute(rewrite, false, writer);
WebReWriteDefinition.SUBSTITUTION.marshallAsAttribute(rewrite, false, writer);
WebReWriteDefinition.FLAGS.marshallAsAttribute(rewrite, false, writer);
if (rewrite.hasDefined(CONDITION)) {
for (final ModelNode conditionnode : rewrite.get(CONDITION).asList()) {
Property conditionProp = conditionnode.asProperty();
ModelNode condition = conditionProp.getValue();
writer.writeStartElement(CONDITION);
writer.writeAttribute(NAME, conditionProp.getName());
WebReWriteConditionDefinition.TEST.marshallAsAttribute(condition, false, writer);
WebReWriteConditionDefinition.PATTERN.marshallAsAttribute(condition, false, writer);
WebReWriteConditionDefinition.FLAGS.marshallAsAttribute(condition, false, writer);
writer.writeEndElement();
}
}
writer.writeEndElement();
}
}
if (config.get(SSO_PATH.getKey(), SSO_PATH.getValue()).isDefined()) {
final ModelNode sso;
sso = config.get(SSO_PATH.getKey(), SSO_PATH.getValue());
writer.writeStartElement(SSO);
for (SimpleAttributeDefinition attr : WebSSODefinition.SSO_ATTRIBUTES) {
attr.marshallAsAttribute(sso, false, writer);
}
writer.writeEndElement();
}
// End of the VIRTUAL_SERVER
writer.writeEndElement();
}
if (node.hasDefined(VALVE)) {
for (final Property valve : node.get(VALVE).asPropertyList()) {
final ModelNode config = valve.getValue();
writer.writeStartElement(Element.VALVE.getLocalName());
writer.writeAttribute(NAME, valve.getName());
for (AttributeDefinition attr : WebValveDefinition.ATTRIBUTES) {
if (attr instanceof SimpleAttributeDefinition) {
((SimpleAttributeDefinition) attr).marshallAsAttribute(config, false, writer);
}
}
if (config.hasDefined(PARAM)) {
for (final Property entry : config.get(PARAM).asPropertyList()) {
writer.writeEmptyElement(Element.PARAM.getLocalName());
writer.writeAttribute(Attribute.PARAM_NAME.getLocalName(), entry.getName());
writer.writeAttribute(Attribute.PARAM_VALUE.getLocalName(), entry.getValue().asString());
}
}
writer.writeEndElement();
}
}
}
writer.writeEndElement();
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class JMSBridgeDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
CredentialReferenceWriteAttributeHandler credentialReferenceWriteAttributeHandler = new CredentialReferenceWriteAttributeHandler(SOURCE_CREDENTIAL_REFERENCE, TARGET_CREDENTIAL_REFERENCE);
for (AttributeDefinition attr : ATTRIBUTES) {
if (attr.equals(SOURCE_CREDENTIAL_REFERENCE) || attr.equals(TARGET_CREDENTIAL_REFERENCE)) {
registry.registerReadWriteAttribute(attr, null, credentialReferenceWriteAttributeHandler);
} else {
registry.registerReadWriteAttribute(attr, null, reloadRequiredWriteAttributeHandler);
}
}
for (AttributeDefinition attr : READONLY_ATTRIBUTES) {
registry.registerReadOnlyAttribute(attr, JMSBridgeHandler.INSTANCE);
}
for (AttributeDefinition attr : METRICS) {
registry.registerMetric(attr, JMSBridgeHandler.READ_ONLY_INSTANCE);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class PooledConnectionFactoryDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
Collection<AttributeDefinition> definitions = getAttributes();
ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(definitions);
CredentialReferenceWriteAttributeHandler credentialReferenceWriteAttributeHandler = new CredentialReferenceWriteAttributeHandler(CREDENTIAL_REFERENCE);
for (AttributeDefinition attr : definitions) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
if (deployed) {
registry.registerReadOnlyAttribute(attr, PooledConnectionFactoryConfigurationRuntimeHandler.INSTANCE);
} else {
if (attr.equals(CREDENTIAL_REFERENCE)) {
registry.registerReadWriteAttribute(attr, null, credentialReferenceWriteAttributeHandler);
} else {
registry.registerReadWriteAttribute(attr, null, reloadRequiredWriteAttributeHandler);
}
}
}
}
}
Aggregations