@SuppressWarnings("deprecation") @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress().append(BinaryTableResourceDefinition.PATH); ModelNode table = Operations.getAttributeValue(operation); for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(BinaryTableResourceDefinition.Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.DeprecatedAttribute.class)) { for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) { ModelNode writeAttributeOperation = Operations.createWriteAttributeOperation(address, attribute, table.get(attribute.getName())); context.addStep(writeAttributeOperation, context.getResourceRegistration().getAttributeAccess(PathAddress.pathAddress(BinaryTableResourceDefinition.PATH), attribute.getName()).getWriteHandler(), context.getCurrentStage()); } } } };
@SuppressWarnings("deprecation") @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress().append(StringTableResourceDefinition.PATH); ModelNode table = Operations.getAttributeValue(operation); for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(StringTableResourceDefinition.Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.DeprecatedAttribute.class)) { for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) { ModelNode writeAttributeOperation = Operations.createWriteAttributeOperation(address, attribute, table.get(attribute.getName())); context.addStep(writeAttributeOperation, context.getResourceRegistration().getAttributeAccess(PathAddress.pathAddress(StringTableResourceDefinition.PATH), attribute.getName()).getWriteHandler(), context.getCurrentStage()); } } } };
@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 public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress currentAddress = context.getCurrentAddress(); PathAddress targetAddress = this.translation.getPathAddressTransformation().apply(currentAddress); Attribute targetAttribute = this.translation.getTargetAttribute(); ModelNode targetOperation = Operations.createReadAttributeOperation(targetAddress, targetAttribute); ImmutableManagementResourceRegistration targetRegistration = this.translation.getResourceRegistrationTransformation().apply(context.getResourceRegistration()); OperationStepHandler readAttributeHandler = targetRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, targetAttribute.getName()).getReadHandler(); OperationStepHandler readTranslatedAttributeHandler = new ReadTranslatedAttributeStepHandler(readAttributeHandler, targetAttribute, this.translation.getReadTranslator()); // If targetOperation applies to the current resource, we can execute in the current step if (targetAddress == currentAddress) { readTranslatedAttributeHandler.execute(context, targetOperation); } else { context.addStep(targetOperation, readTranslatedAttributeHandler, context.getCurrentStage(), true); } }
@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); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode value = context.resolveExpressions(Operations.getAttributeValue(operation)); ModelNode targetValue = this.translation.getWriteTranslator().translate(context, value); Attribute targetAttribute = this.translation.getTargetAttribute(); PathAddress currentAddress = context.getCurrentAddress(); PathAddress targetAddress = this.translation.getPathAddressTransformation().apply(currentAddress); ModelNode targetOperation = Operations.createWriteAttributeOperation(targetAddress, targetAttribute, targetValue); ImmutableManagementResourceRegistration targetRegistration = this.translation.getResourceRegistrationTransformation().apply(context.getResourceRegistration()); OperationStepHandler writeAttributeHandler = targetRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, targetAttribute.getName()).getWriteHandler(); if (targetAddress == currentAddress) { writeAttributeHandler.execute(context, targetOperation); } else { context.addStep(targetOperation, writeAttributeHandler, context.getCurrentStage()); } } }
ModelNode writeAttributeOperation = Operations.createWriteAttributeOperation(targetAddress, targetAttribute, targetValue); ImmutableManagementResourceRegistration targetRegistration = translation.getResourceRegistrationTransformation().apply(context.getResourceRegistration()); OperationStepHandler writeAttributeHandler = targetRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, targetAttribute.getName()).getWriteHandler(); context.addStep(writeAttributeOperation, writeAttributeHandler, OperationContext.Stage.MODEL); ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); 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)) {
@Override public AttributeAccess getAttributeAccess(PathAddress address, String attributeName) { return delegate.getAttributeAccess(address, attributeName); }
@Override public AttributeAccess getAttributeAccess(PathAddress address, String attributeName) { return delegate.getAttributeAccess(address, attributeName); }
@Override public AttributeAccess getAttributeAccess(PathAddress address, String attributeName) { return delegate.getAttributeAccess(address, attributeName); }
@Override public AttributeAccess getAttributeAccess(PathAddress address, String attributeName) { return delegate.getAttributeAccess(address, attributeName); }
static boolean containsEnhancedSyntax(String attributeName, ImmutableManagementResourceRegistration registry) { return registry.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName) == null && ENHANCED_SYNTAX_PATTERN.matcher(attributeName).matches(); }
static boolean containsEnhancedSyntax(String attributeName, ImmutableManagementResourceRegistration registry) { return registry.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName) == null && ENHANCED_SYNTAX_PATTERN.matcher(attributeName).matches(); }
private TargetAttribute createTargetAttribute(AuthorizationResponseImpl authResp, String attributeName, boolean isDefaultResponse) { ModelNode model = authResp.targetResource.getResource().getModel(); ModelNode currentValue; if (isDefaultResponse) { //Just use an empty model node to avoid using vault expressions currentValue = new ModelNode(); } else { currentValue = model.has(attributeName) ? model.get(attributeName) : new ModelNode(); } AttributeAccess attributeAccess = authResp.targetResource.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); return new TargetAttribute(attributeName, attributeAccess, currentValue, authResp.targetResource); }
private TargetAttribute createTargetAttribute(AuthorizationResponseImpl authResp, String attributeName, boolean isDefaultResponse) { ModelNode model = authResp.targetResource.getResource().getModel(); ModelNode currentValue; if (isDefaultResponse) { //Just use an empty model node to avoid using vault expressions currentValue = new ModelNode(); } else { currentValue = model.has(attributeName) ? model.get(attributeName) : new ModelNode(); } AttributeAccess attributeAccess = authResp.targetResource.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); return new TargetAttribute(attributeName, attributeAccess, currentValue, authResp.targetResource); }
private TargetAttribute createTargetAttribute(AuthorizationResponseImpl authResp, String attributeName, boolean isDefaultResponse) { ModelNode model = authResp.targetResource.getResource().getModel(); ModelNode currentValue; if (isDefaultResponse) { //Just use an empty model node to avoid using vault expressions currentValue = new ModelNode(); } else { currentValue = model.has(attributeName) ? model.get(attributeName) : new ModelNode(); } AttributeAccess attributeAccess = authResp.targetResource.getResourceRegistration().getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName); return new TargetAttribute(attributeName, attributeAccess, currentValue, authResp.targetResource); }
@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); } } }
@SuppressWarnings("deprecation") @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress().append(StringTableResourceDefinition.PATH); ModelNode table = Operations.getAttributeValue(operation); for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(StringTableResourceDefinition.Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.DeprecatedAttribute.class)) { for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) { ModelNode writeAttributeOperation = Operations.createWriteAttributeOperation(address, attribute, table.get(attribute.getName())); context.addStep(writeAttributeOperation, context.getResourceRegistration().getAttributeAccess(PathAddress.pathAddress(StringTableResourceDefinition.PATH), attribute.getName()).getWriteHandler(), context.getCurrentStage()); } } } };
@SuppressWarnings("deprecation") @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress().append(BinaryTableResourceDefinition.PATH); ModelNode table = Operations.getAttributeValue(operation); for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(BinaryTableResourceDefinition.Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.DeprecatedAttribute.class)) { for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) { ModelNode writeAttributeOperation = Operations.createWriteAttributeOperation(address, attribute, table.get(attribute.getName())); context.addStep(writeAttributeOperation, context.getResourceRegistration().getAttributeAccess(PathAddress.pathAddress(BinaryTableResourceDefinition.PATH), attribute.getName()).getWriteHandler(), context.getCurrentStage()); } } } };
private OpenMBeanAttributeInfo getAttribute(String name) { final String escapedName = NameConverter.convertToCamelCase(name); ModelNode attribute = providedDescription.require(ATTRIBUTES).require(name); AttributeAccess access = resourceRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name); final boolean writable = standalone && (access != null && access.getAccessType() == AccessType.READ_WRITE); return new OpenMBeanAttributeInfoSupport( escapedName, getDescription(attribute), converters.convertToMBeanType(attribute), true, writable, false, createAttributeDescriptor(attribute)); }