@Override public void registerOperations(ManagementResourceRegistration resourceRegistration) { super.registerOperations(resourceRegistration); resourceRegistration.registerOperationHandler( GET_PROVIDER_POINTS, (context, operation) -> { final ModelNode model = new ModelNode(); NAME.validateAndSet(operation, model); final String name = NAME.resolveModelAttribute(context, model).asString(); CapabilityId id = new CapabilityId( name, CapabilityScope.GLOBAL); // for possible capabilities it is always global Set<PathAddress> providerPoints = capabilityRegistry.getPossibleProviderPoints(id); for (PathAddress point : providerPoints) { context.getResult().add(point.toCLIStyleString()); } }); resourceRegistration.registerOperationHandler( GET_CAPABILITY, (context, operation) -> { final ModelNode model = new ModelNode(); NAME.validateAndSet(operation, model); SCOPE.validateAndSet(operation, model); final String name = NAME.resolveModelAttribute(context, model).asString(); final CapabilityScope scope; if (model.hasDefined(SCOPE.getName())) { String scopeName = SCOPE.resolveModelAttribute(context, model).asString(); scope = CapabilityScope.Factory.forName(scopeName); } else { scope = CapabilityScope.GLOBAL; } CapabilityId id = new CapabilityId(name, scope); CapabilityRegistration reg = capabilityRegistry.getCapability(id); if (reg != null) { ModelNode result = context.getResult(); populateCapabilityRegistration(reg, result); } }); resourceRegistration.registerOperationHandler( SUGGEST_CAPABILITIES, (context, operation) -> { final String name = NAME.resolveModelAttribute(context, operation).asString(); PathAddress address = PathAddress.pathAddress(DEPENDENT_ADDRESS.resolveModelAttribute(context, operation)); CapabilityScope dependentScope = CapabilityScope.Factory.create(context.getProcessType(), address); Set<String> capabilities = capabilityRegistry.getDynamicCapabilityNames(name, dependentScope); for (String capability : capabilities) { context.getResult().add(capability); } }); }
@Override public String toString() { return pathAddress.toCLIStyleString(); }