code: 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()));
                  }
              }
          }
          assert mrr.getRequirements() != null;
          for (CapabilityReferenceRecorder recorder : mrr.getRequirements()) {
              recorder.removeCapabilityRequirements(context, resource, null);
          }
      }
docs: Record any new {@link org.jboss.as.controller.capability.RuntimeCapability capabilities} that are no longer available as
  a result of this operation, as well as any requirements for other capabilities that no longer exist. This method is
  invoked during {@link org.jboss.as.controller.OperationContext.Stage#MODEL}.
  <p>
  Any changes made by this method will automatically be discarded if the operation rolls back.
  </p>
  <p>
  This default implementation deregisters any capabilities passed to the constructor.
  </p>
  
  @param context the context. Will not be {@code null}
  @param operation the operation that is executing Will not be {@code null}
  @param resource the resource that will be removed. Will <strong>not</strong> reflect any updates made by
  {@link #performRemove(OperationContext, org.jboss.dmr.ModelNode, org.jboss.dmr.ModelNode)} as this method
  is invoked before that method is. Will not be {@code null}