@Override public void execute(OperationContext context, ModelNode legacyOperation) { String value = legacyOperation.get(ALIAS.getName()).asString(); ModelNode operation = Operations.createListAddOperation(context.getCurrentAddress(), Attribute.ALIASES, value); context.addStep(operation, ListOperations.LIST_ADD_HANDLER, context.getCurrentStage()); } };
@Override public void execute(OperationContext context, ModelNode legacyOperation) throws OperationFailedException { String value = legacyOperation.get(ALIAS.getName()).asString(); ModelNode operation = Operations.createListRemoveOperation(context.getCurrentAddress(), Attribute.ALIASES, value); context.addStep(operation, ListOperations.LIST_REMOVE_HANDLER, context.getCurrentStage()); } };
@Override protected void recreateParentService(final OperationContext context, final PathAddress parentAddress, final ModelNode parentModel) throws OperationFailedException { switch(context.getCurrentStage()){ case RUNTIME: // service installation in another step: when interruption is thrown then it is handled by RollbackHandler // declared in RestartParentResourceHandlerBase context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { RemotingProfileAdd.INSTANCE.installServices(context, parentAddress, parentModel); } }, OperationContext.Stage.RUNTIME); break; case DONE: // executed from RollbackHandler - service is being installed using correct configuration RemotingProfileAdd.INSTANCE.installServices(context, parentAddress, parentModel); break; } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress().append(BinaryTableResourceDefinition.PATH); ModelNode readResourceOperation = Util.createOperation(ModelDescriptionConstants.READ_RESOURCE_OPERATION, address); operation.get(ModelDescriptionConstants.ATTRIBUTES_ONLY).set(true); context.addStep(readResourceOperation, new ReadResourceHandler(), context.getCurrentStage()); } };
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = context.getCurrentAddress().append(StringTableResourceDefinition.PATH); ModelNode readResourceOperation = Util.createOperation(ModelDescriptionConstants.READ_RESOURCE_OPERATION, address); operation.get(ModelDescriptionConstants.ATTRIBUTES_ONLY).set(true); context.addStep(readResourceOperation, new ReadResourceHandler(), context.getCurrentStage()); } };
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); context.createResource(PathAddress.EMPTY_ADDRESS); String name = context.getCurrentAddressValue(); String value = operation.get(VALUE.getName()).asString(); PathAddress storeAddress = context.getCurrentAddress().getParent(); ModelNode putOperation = Operations.createMapPutOperation(storeAddress, StoreResourceDefinition.Attribute.PROPERTIES, name, value); context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, context.getCurrentStage()); } };
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); context.addResource(PathAddress.EMPTY_ADDRESS, PlaceholderResource.INSTANCE); String name = context.getCurrentAddressValue(); String value = operation.get(VALUE.getName()).asString(); PathAddress protocolAddress = context.getCurrentAddress().getParent(); ModelNode putOperation = Operations.createMapPutOperation(protocolAddress, AbstractProtocolResourceDefinition.Attribute.PROPERTIES, name, value); context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, 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()); } } } };
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); PathAddress storeAddress = context.getCurrentAddress().getParent(); String key = context.getCurrentAddressValue(); String value = Operations.getAttributeValue(operation).asString(); ModelNode putOperation = Operations.createMapPutOperation(storeAddress, StoreResourceDefinition.Attribute.PROPERTIES, key, value); context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, context.getCurrentStage()); } };
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); PathAddress protocolAddress = context.getCurrentAddress().getParent(); String key = context.getCurrentAddressValue(); String value = Operations.getAttributeValue(operation).asString(); ModelNode putOperation = Operations.createMapPutOperation(protocolAddress, AbstractProtocolResourceDefinition.Attribute.PROPERTIES, key, value); context.addStep(putOperation, MapOperations.MAP_PUT_HANDLER, 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 public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); PathAddress protocolAddress = context.getCurrentAddress().getParent(); String key = context.getCurrentAddressValue(); ModelNode getOperation = Operations.createMapGetOperation(protocolAddress, AbstractProtocolResourceDefinition.Attribute.PROPERTIES, key); context.addStep(getOperation, MapOperations.MAP_GET_HANDLER, context.getCurrentStage()); } };
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); PathAddress storeAddress = context.getCurrentAddress().getParent(); String key = context.getCurrentAddressValue(); ModelNode getOperation = Operations.createMapGetOperation(storeAddress, StoreResourceDefinition.Attribute.PROPERTIES, key); context.addStep(getOperation, MapOperations.MAP_GET_HANDLER, context.getCurrentStage()); } };
@Override public OperationStepHandler apply(OperationStepHandler handler) { return (context, operation) -> { if (operation.hasDefined(this.attribute.getName())) { // Translate deprecated table attribute into separate add table operation ModelNode addTableOperation = Util.createAddOperation(context.getCurrentAddress().append(this.path)); ModelNode parameters = operation.get(this.attribute.getName()); for (Property parameter : parameters.asPropertyList()) { addTableOperation.get(parameter.getName()).set(parameter.getValue()); } context.addStep(addTableOperation, context.getResourceRegistration().getOperationHandler(PathAddress.pathAddress(this.path), ModelDescriptionConstants.ADD), context.getCurrentStage()); } handler.execute(context, operation); }; }
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); context.removeResource(PathAddress.EMPTY_ADDRESS); String name = context.getCurrentAddressValue(); PathAddress protocolAddress = context.getCurrentAddress().getParent(); ModelNode putOperation = Operations.createMapRemoveOperation(protocolAddress, AbstractProtocolResourceDefinition.Attribute.PROPERTIES, name); context.addStep(putOperation, MapOperations.MAP_REMOVE_HANDLER, context.getCurrentStage()); } };
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); context.removeResource(PathAddress.EMPTY_ADDRESS); String name = context.getCurrentAddressValue(); PathAddress storeAddress = context.getCurrentAddress().getParent(); ModelNode putOperation = Operations.createMapRemoveOperation(storeAddress, StoreResourceDefinition.Attribute.PROPERTIES, name); context.addStep(putOperation, MapOperations.MAP_REMOVE_HANDLER, context.getCurrentStage()); } };
@Override public void execute(OperationContext context, ModelNode operation) { operationDeprecated(context, operation); PathAddress address = context.getCurrentAddress(); String protocol = operation.require(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).asString(); PathElement protocolPath = ProtocolResourceDefinition.pathElement(protocol); PathAddress protocolAddress = address.append(protocolPath); ModelNode removeOperation = Util.createRemoveOperation(protocolAddress); context.addStep(removeOperation, context.getResourceRegistration().getOperationHandler(PathAddress.pathAddress(protocolPath), ModelDescriptionConstants.REMOVE), context.getCurrentStage()); } };
@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 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()); } } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { if (context.getCurrentStage() == OperationContext.Stage.MODEL) { context.addStep(this::executeRuntime, OperationContext.Stage.RUNTIME); } else { executeRuntime(context, operation); } }