Java Code Examples for org.jboss.as.controller.AttributeDefinition#resolveModelAttribute()
The following examples show how to use
org.jboss.as.controller.AttributeDefinition#resolveModelAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AuthenticationFactoryDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static Set<String> getConfiguredMechanismNames(AttributeDefinition mechanismConfigurationAttribute, OperationContext context, ModelNode model) throws OperationFailedException { ModelNode mechanismConfiguration = mechanismConfigurationAttribute.resolveModelAttribute(context, model); if ( ! mechanismConfiguration.isDefined()) { return Collections.emptySet(); } Set<String> mechanismNames = new LinkedHashSet<>(); for (ModelNode current : mechanismConfiguration.asList()) { final String mechanismName = MECHANISM_NAME.resolveModelAttribute(context, current).asStringOrNull(); if (mechanismName == null) { return Collections.emptySet(); } mechanismNames.add(mechanismName); } return mechanismNames; }
Example 2
Source File: ManagedServerBootCmdFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private String asStringIfDefined(ModelNode model, AttributeDefinition attribute, ExpressionResolver resolver) throws OperationFailedException { ModelNode value = attribute.resolveModelAttribute(resolver, model); if (value.isDefined()) { return value.asString(); } return null; }
Example 3
Source File: CredentialReference.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void rollbackCredentialStoreUpdate(AttributeDefinition credentialReferenceAD, OperationContext context, final Resource resource) { try { ModelNode value = credentialReferenceAD.resolveModelAttribute(context, resource.getModel()); if (value.isDefined()) { String store = credentialReferencePartAsStringIfDefined(value, CredentialReference.STORE); String alias = credentialReferencePartAsStringIfDefined(value, CredentialReference.ALIAS); rollbackCredentialStoreUpdate(credentialReferenceAD, context, store, alias); } } catch (OperationFailedException e) { throw new RuntimeException(e); } }
Example 4
Source File: AuthenticationFactoryDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static List<ResolvedMechanismConfiguration> getResolvedMechanismConfiguration(AttributeDefinition mechanismConfigurationAttribute, ServiceBuilder<?> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException { ModelNode mechanismConfiguration = mechanismConfigurationAttribute.resolveModelAttribute(context, model); if (mechanismConfiguration.isDefined() == false) { return Collections.emptyList(); } List<ModelNode> mechanismConfigurations = mechanismConfiguration.asList(); List<ResolvedMechanismConfiguration> resolvedMechanismConfigurations = new ArrayList<>(mechanismConfigurations.size()); for (ModelNode currentMechanismConfiguration : mechanismConfigurations) { final String mechanismName = MECHANISM_NAME.resolveModelAttribute(context, currentMechanismConfiguration).asStringOrNull(); final String hostName = HOST_NAME.resolveModelAttribute(context, currentMechanismConfiguration).asStringOrNull(); final String protocol = PROTOCOL.resolveModelAttribute(context, currentMechanismConfiguration).asStringOrNull(); Predicate<MechanismInformation> selectionPredicate = null; if (mechanismName != null) { selectionPredicate = i -> mechanismName.equalsIgnoreCase(i.getMechanismName()); } if (hostName != null) { Predicate<MechanismInformation> hostPredicate = i -> hostName.equalsIgnoreCase(i.getHostName()); selectionPredicate = selectionPredicate != null ? selectionPredicate.and(hostPredicate) : hostPredicate; } if (protocol != null) { Predicate<MechanismInformation> protocolPredicate = i -> protocol.equalsIgnoreCase(i.getProtocol()); selectionPredicate = selectionPredicate != null ? selectionPredicate.and(protocolPredicate) : protocolPredicate; } if (selectionPredicate == null) { selectionPredicate = i -> true; } ResolvedMechanismConfiguration resolvedMechanismConfiguration = new ResolvedMechanismConfiguration(selectionPredicate); injectPrincipalTransformer(BASE_PRE_REALM_PRINCIPAL_TRANSFORMER, serviceBuilder, context, currentMechanismConfiguration, resolvedMechanismConfiguration.preRealmPrincipalTranformer); injectPrincipalTransformer(BASE_POST_REALM_PRINCIPAL_TRANSFORMER, serviceBuilder, context, currentMechanismConfiguration, resolvedMechanismConfiguration.postRealmPrincipalTransformer); injectPrincipalTransformer(BASE_FINAL_PRINCIPAL_TRANSFORMER, serviceBuilder, context, currentMechanismConfiguration, resolvedMechanismConfiguration.finalPrincipalTransformer); injectRealmMapper(BASE_REALM_MAPPER, serviceBuilder, context, currentMechanismConfiguration, resolvedMechanismConfiguration.realmMapper); injectSecurityFactory(BASE_CREDENTIAL_SECURITY_FACTORY, serviceBuilder, context, currentMechanismConfiguration, resolvedMechanismConfiguration.securityFactory); if (currentMechanismConfiguration.hasDefined(ElytronDescriptionConstants.MECHANISM_REALM_CONFIGURATIONS)) { for (ModelNode currentMechanismRealm : currentMechanismConfiguration.require(ElytronDescriptionConstants.MECHANISM_REALM_CONFIGURATIONS).asList()) { String realmName = REALM_NAME.resolveModelAttribute(context, currentMechanismRealm).asString(); ResolvedMechanismRealmConfiguration resolvedMechanismRealmConfiguration = new ResolvedMechanismRealmConfiguration(); injectPrincipalTransformer(BASE_PRE_REALM_PRINCIPAL_TRANSFORMER, serviceBuilder, context, currentMechanismRealm, resolvedMechanismRealmConfiguration.preRealmPrincipalTranformer); injectPrincipalTransformer(BASE_POST_REALM_PRINCIPAL_TRANSFORMER, serviceBuilder, context, currentMechanismRealm, resolvedMechanismRealmConfiguration.postRealmPrincipalTransformer); injectPrincipalTransformer(BASE_FINAL_PRINCIPAL_TRANSFORMER, serviceBuilder, context, currentMechanismRealm, resolvedMechanismRealmConfiguration.finalPrincipalTransformer); injectRealmMapper(BASE_REALM_MAPPER, serviceBuilder, context, currentMechanismRealm, resolvedMechanismRealmConfiguration.realmMapper); resolvedMechanismConfiguration.mechanismRealms.put(realmName, resolvedMechanismRealmConfiguration); } } resolvedMechanismConfigurations.add(resolvedMechanismConfiguration); } return resolvedMechanismConfigurations; }
Example 5
Source File: StructuredFormatterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@SuppressWarnings({"OverlyStrongTypeCast", "StatementWithEmptyBody"}) @Override public void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException { String keyOverrides = null; if (model.hasDefined(KEY_OVERRIDES.getName())) { keyOverrides = modelValueToMetaData(KEY_OVERRIDES.resolveModelAttribute(context, model)); } final String name = context.getCurrentAddressValue(); if (name.endsWith(PatternFormatterResourceDefinition.DEFAULT_FORMATTER_SUFFIX)) { throw LoggingLogger.ROOT_LOGGER.illegalFormatterName(); } FormatterConfiguration configuration = logContextConfiguration.getFormatterConfiguration(name); final String className = type.getName(); if (configuration == null) { LoggingLogger.ROOT_LOGGER.tracef("Adding formatter '%s' at '%s'", name, context.getCurrentAddress()); if (keyOverrides == null) { configuration = logContextConfiguration.addFormatterConfiguration(null, className, name); } else { configuration = logContextConfiguration.addFormatterConfiguration(null, className, name, "keyOverrides"); configuration.setPropertyValueString("keyOverrides", keyOverrides); } } else if (isSamePropertyValue(configuration, "keyOverrides", keyOverrides)) { LoggingLogger.ROOT_LOGGER.tracef("Removing then adding formatter '%s' at '%s'", name, context.getCurrentAddress()); logContextConfiguration.removeFormatterConfiguration(name); configuration = logContextConfiguration.addFormatterConfiguration(null, className, name, "keyOverrides"); configuration.setPropertyValueString("keyOverrides", keyOverrides); } // Process the attributes for (AttributeDefinition attribute : attributes) { if (attribute == META_DATA) { final String metaData = modelValueToMetaData(META_DATA.resolveModelAttribute(context, model)); if (metaData != null) { if (isSamePropertyValue(configuration, "metaData", metaData)) { configuration.setPropertyValueString("metaData", metaData); } } else { configuration.removeProperty("metaData"); } } else if (attribute == KEY_OVERRIDES) { // Ignore the key-overrides as it was already taken care of } else { if (attribute instanceof PropertyAttributeDefinition) { ((PropertyAttributeDefinition) attribute).setPropertyValue(context, model, configuration); } else { final ModelNode value = attribute.resolveModelAttribute(context, model); if (value.isDefined()) { if (isSamePropertyValue(configuration, attribute.getName(), value.asString())) { configuration.setPropertyValueString(attribute.getName(), value.asString()); } } else { configuration.removeProperty(attribute.getName()); } } } } }
Example 6
Source File: ManagementInterfaceAddStepHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected String asStringIfDefined(OperationContext context, AttributeDefinition attribute, ModelNode model) throws OperationFailedException { ModelNode attributeValue = attribute.resolveModelAttribute(context, model); return attributeValue.isDefined() ? attributeValue.asString() : null; }