/** * Returns the address of the specified operation * @param operation an operation * @return a path address */ public static PathAddress getPathAddress(ModelNode operation) { return PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String name = address.getLastElement().getValue(); context.removeService(RemotingProfileService.BASE_SERVICE_NAME.append(name)); }
/** * Resolves runtime name of model resource. * @param context - operation context in which handler is invoked * @param address - deployment address * @return runtime name of module. Value which is returned is never null. */ protected static String resolveRuntimeName(final OperationContext context, final PathElement address){ final ModelNode runtimeName = context.readResourceFromRoot(PathAddress.pathAddress(address),false).getModel() .get(ModelDescriptionConstants.RUNTIME_NAME); return runtimeName.asString(); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { operationDeprecated(context, operation); PathAddress address = translateProxyPath(context); String type = operation.require(LoadMetricResourceDefinition.Attribute.TYPE.getName()).asString(); PathAddress metricPath = PathAddress.pathAddress(DynamicLoadProviderResourceDefinition.LEGACY_PATH, LoadMetricResourceDefinition.pathElement(type)); PathAddress metricPathAddress = address.append(metricPath); ModelNode metricOperation = Util.createAddOperation(metricPathAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(metricPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { metricOperation.get(name).set(operation.get(name)); } } context.addStep(metricOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
@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 protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { String opName = operation.require(ModelDescriptionConstants.OP).asString(); PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final T dataSource = getDataSourceConfig(address); if (ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION.equals(opName)) { final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString(); executeReadAttribute(attributeName, context, dataSource, address); } else { throw unknownOperation(opName); } }
private boolean checkJtsEnabled(final OperationContext context) { try { final ModelNode jtsNode = context.readResourceFromRoot(PathAddress.pathAddress("subsystem", "transactions"), false) .getModel().get("jts"); return jtsNode.isDefined() ? jtsNode.asBoolean() : false; } catch (NoSuchResourceException ex) { return false; } } }
} catch (InstanceNotFoundException e) { final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final PathElement element = address.getLastElement();
private static ServiceName componentServiceName(final OperationContext context, final ModelNode operation) { final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final String parent; final String module; int i = 2; if (address.getElement(1).getKey().equals(ModelDescriptionConstants.SUBDEPLOYMENT)) { parent = resolveRuntimeName(context,address.getElement(0)); module = address.getElement(1).getValue(); i++; } else { parent = null; module = resolveRuntimeName(context,address.getElement(0)); } final String component = address.getElement(i).getValue(); final ServiceName deploymentUnitServiceName; if (parent == null) { deploymentUnitServiceName = Services.deploymentUnitName(module); } else { deploymentUnitServiceName = Services.deploymentUnitName(parent, module); } // Hmm, don't like the START bit return BasicComponent.serviceNameOf(deploymentUnitServiceName, component).append("START"); }
@Override public OperationStepHandler apply(OperationStepHandler handler) { return (context, operation) -> { if (this.legacy.test(operation)) { PathElement path = context.getCurrentAddress().getLastElement(); // This is a legacy add operation - process it using the generic handler OperationStepHandler genericHandler = context.getResourceRegistration().getParent().getOperationHandler(PathAddress.pathAddress(ProtocolResourceDefinition.WILDCARD_PATH), ModelDescriptionConstants.ADD); Operations.setPathAddress(operation, context.getCurrentAddress().getParent().append(GenericProtocolResourceDefinition.pathElement(path.getValue()))); // Process this step first to preserve protocol order context.addStep(operation, genericHandler, OperationContext.Stage.MODEL, true); } else { handler.execute(context, operation); } }; } }
private void installManagementModel(final DataSource ds, final DeploymentUnit deploymentUnit, final PathAddress addr) { XMLDataSourceRuntimeHandler.INSTANCE.registerDataSource(addr, ds); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, addr.getLastElement()); if (ds.getConnectionProperties() != null) { for (final Map.Entry<String, String> prop : ds.getConnectionProperties().entrySet()) { PathAddress registration = PathAddress.pathAddress(addr.getLastElement(), PathElement.pathElement(CONNECTION_PROPERTIES, prop.getKey())); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, registration); } } }
@Override public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) { PathAddress target = this.getTargetAddress(); List<PathElement> result = new ArrayList<>(address.size()); for (int i = 0; i < address.size(); ++i) { PathElement element = address.getElement(i); if (i < target.size()) { PathElement targetElement = target.getElement(i); result.add(targetElement.isWildcard() ? PathElement.pathElement(targetElement.getKey(), element.getValue()) : targetElement); } else { result.add(element); } } return PathAddress.pathAddress(result); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue(); installRuntimeServices(context, name, model); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { operationDeprecated(context, operation); PathAddress address = translateProxyPath(context); String type = operation.require(CustomLoadMetricResourceDefinition.Attribute.CLASS.getName()).asString(); PathAddress metricPath = PathAddress.pathAddress(DynamicLoadProviderResourceDefinition.LEGACY_PATH, LoadMetricResourceDefinition.pathElement(type)); PathAddress metricPathAddress = address.append(metricPath); ModelNode metricOperation = Util.createAddOperation(metricPathAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(metricPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { metricOperation.get(name).set(operation.get(name)); } } context.addStep(metricOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
final ModelNode eeSubSystem = Util.createAddOperation(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM)); case GLOBAL_MODULES: { final ModelNode model = parseGlobalModules(reader); eeSubSystem.get(GlobalModulesDefinition.GLOBAL_MODULES).set(model); break;
/** * Resolves runtime name of model resource. * @param context - operation context in which handler is invoked * @param address - deployment address * @return runtime name of module. Value which is returned is never null. */ protected String resolveRuntimeName(final OperationContext context, final PathElement address){ final ModelNode runtimeName = context.readResourceFromRoot(PathAddress.pathAddress(address),false).getModel() .get(ModelDescriptionConstants.RUNTIME_NAME); return runtimeName.asString(); } }
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { String opName = operation.require(ModelDescriptionConstants.OP).asString(); boolean forWrite = isForWrite(opName); PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final ServiceName serviceName = getComponentConfiguration(context,address); T component = getComponent(serviceName, address, context, forWrite); if (ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION.equals(opName)) { final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString(); executeReadAttribute(attributeName, context, component, address); } else if (ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION.equals(opName)) { final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString(); executeWriteAttribute(attributeName, context, operation, component, address); } else { executeAgainstComponent(context, operation, component, opName, address); } }
@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()); } } } };
T getComponent(OperationContext context, ModelNode operation) throws OperationFailedException{ PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final ServiceName serviceName = getComponentConfiguration(context,address); T component = getComponent(serviceName, address, context, false); return component; }
private void installManagementModel(final XaDataSource ds, final DeploymentUnit deploymentUnit, final PathAddress addr) { XMLXaDataSourceRuntimeHandler.INSTANCE.registerDataSource(addr, ds); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, addr.getLastElement()); if (ds.getXaDataSourceProperty() != null) { for (final Map.Entry<String, String> prop : ds.getXaDataSourceProperty().entrySet()) { PathAddress registration = PathAddress.pathAddress(addr.getLastElement(), PathElement.pathElement(XA_CONNECTION_PROPERTIES, prop.getKey())); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, registration); } } }