@Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); ModelNode model = resource.getModel(); // The super implementation assumes that the capability name is a simple extension of the base name - we do not. // Only register capabilities when allowed by the associated predicate for (Map.Entry<Capability, Predicate<ModelNode>> entry : this.descriptor.getCapabilities().entrySet()) { if (entry.getValue().test(model)) { context.registerCapability(entry.getKey().resolve(address)); } } ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); for (String attributeName : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeDefinition attribute = registration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getAttributeDefinition(); if (attribute.hasCapabilityRequirements()) { attribute.addCapabilityRequirements(context, resource, model.get(attributeName)); } } for (CapabilityReferenceRecorder recorder : context.getResourceRegistration().getRequirements()) { recorder.addCapabilityRequirements(context, resource, null); } }
@Override protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); if (removeInCurrentStep(resource)) { // We need to remove capabilities *before* removing the resource, since the capability reference resolution might involve reading the resource PathAddress address = context.getCurrentAddress(); for (Map.Entry<Capability, Predicate<ModelNode>> entry : this.descriptor.getCapabilities().entrySet()) { if (entry.getValue().test(model)) { context.deregisterCapability(entry.getKey().resolve(address).getName()); } } ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); for (String attributeName : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeDefinition attribute = registration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getAttributeDefinition(); if (attribute.hasCapabilityRequirements()) { attribute.removeCapabilityRequirements(context, resource, model.get(attributeName)); } } for (CapabilityReferenceRecorder recorder : registration.getRequirements()) { recorder.removeCapabilityRequirements(context, resource, null); } if (this.requiresRuntime(context)) { for (RuntimeResourceRegistration runtimeRegistration : this.descriptor.getRuntimeResourceRegistrations()) { runtimeRegistration.unregister(context); } } } super.performRemove(context, operation, model); }
for (String attributeName : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeAccess attribute = registration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); AttributeDefinition definition = attribute.getAttributeDefinition(); if ((attribute.getStorageType() == AttributeAccess.Storage.CONFIGURATION) && !translations.containsKey(definition)) { definition.validateAndSet(operation, model);
public AttributeDefinition getAttributeDefinition() { return attributeAccess == null ? null : attributeAccess.getAttributeDefinition(); }
public AttributeDefinition getAttributeDefinition() { return attributeAccess == null ? null : attributeAccess.getAttributeDefinition(); }
public AttributeDefinition getAttributeDefinition() { return attributeAccess == null ? null : attributeAccess.getAttributeDefinition(); }
private static AttributeDefinition getAttributeDefinition(String name, final Map<String, AttributeAccess> attributes) { AttributeAccess aa = attributes.get(name); return aa == null ? null : aa.getAttributeDefinition(); }
private static AttributeDefinition getAttributeDefinition(String name, final Map<String, AttributeAccess> attributes) { AttributeAccess aa = attributes.get(name); return aa == null ? null : aa.getAttributeDefinition(); }
/** * Register operations associated with this resource. * * @param resourceRegistration a {@link org.jboss.as.controller.registry.ManagementResourceRegistration} created from this definition */ @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeAccess attr : attributes.values()) { resourceRegistration.registerReadOnlyAttribute(attr.getAttributeDefinition(), null); } }
/** * Register operations associated with this resource. * * @param resourceRegistration a {@link org.jboss.as.controller.registry.ManagementResourceRegistration} created from this definition */ @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeAccess attr : attributes.values()) { resourceRegistration.registerReadOnlyAttribute(attr.getAttributeDefinition(), null); } }
/** * Register operations associated with this resource. * * @param resourceRegistration a {@link org.jboss.as.controller.registry.ManagementResourceRegistration} created from this definition */ @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeAccess attr : attributes.values()) { resourceRegistration.registerReadOnlyAttribute(attr.getAttributeDefinition(), null); } }
/** * Register operations associated with this resource. * * @param resourceRegistration a {@link org.jboss.as.controller.registry.ManagementResourceRegistration} created from this definition */ @Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeAccess attr : attributes.values()) { resourceRegistration.registerReadOnlyAttribute(attr.getAttributeDefinition(), null); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode result = context.getResult().setEmptyList(); final ImmutableManagementResourceRegistration registry = context.getResourceRegistration(); final Set<String> attributeNames = registry != null ? registry.getAttributeNames(PathAddress.EMPTY_ADDRESS) : Collections.<String>emptySet(); TreeSet<String> groupNames = new TreeSet<String>(); for (final String attributeName : attributeNames) { final AttributeAccess attribute = registry.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); if (attribute.getAttributeDefinition().getAttributeGroup() != null) { groupNames.add(attribute.getAttributeDefinition().getAttributeGroup()); } } for (String groupName : groupNames) { result.add(groupName); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode result = context.getResult().setEmptyList(); final ImmutableManagementResourceRegistration registry = context.getResourceRegistration(); final Set<String> attributeNames = registry != null ? registry.getAttributeNames(PathAddress.EMPTY_ADDRESS) : Collections.<String>emptySet(); TreeSet<String> groupNames = new TreeSet<String>(); for (final String attributeName : attributeNames) { final AttributeAccess attribute = registry.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); if (attribute.getAttributeDefinition().getAttributeGroup() != null) { groupNames.add(attribute.getAttributeDefinition().getAttributeGroup()); } } for (String groupName : groupNames) { result.add(groupName); } } }
private ModelNode getAttributeDescription(String attributeName, ImmutableManagementResourceRegistration registration, Map<String, AttributeAccess> attributes) { AttributeAccess aa = attributes.get(attributeName); AttributeDefinition ad = aa.getAttributeDefinition(); ModelNode desc; if (ad != null) { if (!COMPLEX_TYPES.contains(ad.getType())) { desc = ad.getNoTextDescription(false); } else { // the simple no-text description is not enough to get value-type; ask for the full desc ModelNode wrapped = new ModelNode(); ad.addResourceAttributeDescription(wrapped, NonResolvingResourceDescriptionResolver.INSTANCE, null, NonResolvingResourceDescriptionResolver.INSTANCE.getResourceBundle(null)); desc = wrapped.get(ATTRIBUTES, attributeName); } } else { // We shouldn't be getting here any more, but just in case desc = registration.getModelDescription(PathAddress.EMPTY_ADDRESS).getModelDescription(null).get(ATTRIBUTES, attributeName); } return desc; }
@Override protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); ModelNode model = resource.getModel(); // The super implementation assumes that the capability name is a simple extension of the base name - we do not. // Only register capabilities when allowed by the associated predicate for (Map.Entry<Capability, Predicate<ModelNode>> entry : this.descriptor.getCapabilities().entrySet()) { if (entry.getValue().test(model)) { context.registerCapability(entry.getKey().resolve(address)); } } ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); for (String attributeName : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeDefinition attribute = registration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getAttributeDefinition(); if (attribute.hasCapabilityRequirements()) { attribute.addCapabilityRequirements(context, resource, model.get(attributeName)); } } for (CapabilityReferenceRecorder recorder : context.getResourceRegistration().getRequirements()) { recorder.addCapabilityRequirements(context, resource, null); } }
private boolean isAddableAttribute(String attrName, ImmutableManagementResourceRegistration resourceRegistration) { AttributeAccess attributeAccess = resourceRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attrName); if (attributeAccess == null) { return false; } if (attributeAccess.getStorageType() == AttributeAccess.Storage.CONFIGURATION && attributeAccess.getAccessType() == AttributeAccess.AccessType.READ_WRITE) { AttributeDefinition ad = attributeAccess.getAttributeDefinition(); if (ad == null) { return false; } if (ad.isRequired() || ad.isNullSignificant()) { // must be set, presence of a default means not setting is the same as setting, // or the AD is specifically configured that null is significant return true; } } return false; }
private boolean isAddableAttribute(String attrName, ImmutableManagementResourceRegistration resourceRegistration) { AttributeAccess attributeAccess = resourceRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attrName); if (attributeAccess == null) { return false; } if (attributeAccess.getStorageType() == AttributeAccess.Storage.CONFIGURATION && attributeAccess.getAccessType() == AttributeAccess.AccessType.READ_WRITE) { AttributeDefinition ad = attributeAccess.getAttributeDefinition(); if (ad == null) { return false; } if (ad.isRequired() || ad.isNullSignificant()) { // must be set, presence of a default means not setting is the same as setting, // or the AD is specifically configured that null is significant return true; } } return false; }
protected void recordCapabilitiesAndRequirements(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { Set<RuntimeCapability> capabilitySet = capabilities.isEmpty() ? context.getResourceRegistration().getCapabilities() : capabilities; for (RuntimeCapability capability : capabilitySet) { if (capability.isDynamicallyNamed()) { context.deregisterCapability(capability.getDynamicName(context.getCurrentAddress())); } else { context.deregisterCapability(capability.getName()); } } ModelNode model = resource.getModel(); ImmutableManagementResourceRegistration mrr = context.getResourceRegistration(); for (String attr : mrr.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeAccess aa = mrr.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attr); if (aa != null) { AttributeDefinition ad = aa.getAttributeDefinition(); if (ad != null && (model.hasDefined(ad.getName()) || ad.hasCapabilityRequirements())) { ad.removeCapabilityRequirements(context, resource, model.get(ad.getName())); } } } } }
private boolean isAddableAttribute(String attrName, ImmutableManagementResourceRegistration resourceRegistration) { AttributeAccess attributeAccess = resourceRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attrName); if (attributeAccess == null) { return isRequiredConfigFromDescription(attrName, resourceRegistration); } if (attributeAccess.getStorageType() == AttributeAccess.Storage.CONFIGURATION && attributeAccess.getAccessType() == AttributeAccess.AccessType.READ_WRITE) { AttributeDefinition ad = attributeAccess.getAttributeDefinition(); if (ad == null) { return isRequiredConfigFromDescription(attrName, resourceRegistration); } if (!ad.isAllowNull() || (ad.getDefaultValue() != null && ad.getDefaultValue().isDefined()) || ad.isNullSignificant()) { // must be set, presence of a default means not setting is the same as setting, // or the AD is specifically configured that null is significant return true; } } return false; }