/** * Creates a new describe handler. * <p/> * If the comparator is <b>not</b> {@code null} the {@link ImmutableManagementResourceRegistration#getChildAddresses(org.jboss.as.controller.PathAddress)} * child addresses} from the registration are placed in a sorted collection. This allows the result to order the * add operations for the subsystem resources. * <p/> * If the comparator is {@code null} the order for the {@link ImmutableManagementResourceRegistration#getChildAddresses(org.jboss.as.controller.PathAddress)} * child addresses} is not guaranteed. * * @param comparator the comparator used to sort the child addresses */ public static GenericSubsystemDescribeHandler create(final Comparator<PathElement> comparator) { return new GenericSubsystemDescribeHandler(comparator); }
children.addAll(defaultChildren); result.add(createAddOperation(orderedChildTypesAttachment, address, resource, children)); for(final PathElement element : children) { final Resource child = resource.getChild(element); final ModelNode childAddress = address.clone(); childAddress.add(element.getKey(), element.getValue()); describe(orderedChildTypesAttachment, child, childAddress, result, childRegistration);
@Override protected void describe(Resource resource, ModelNode address, ModelNode result, ImmutableManagementResourceRegistration registration) { super.describe(resource, address, result, registration); if (address.asList().size() == 2 && (address.asList().get(1).hasDefined(DATA_SOURCE) || address.asList().get(1).hasDefined(XA_DATASOURCE))) { result.add(createEnableOperation(address, resource.getModel())); } }
protected ModelNode createAddOperation(final OrderedChildTypesAttachment orderedChildTypesAttachment, final ModelNode address, final Resource resource, final Set<PathElement> children) { ModelNode addOp = createAddOperation(address, resource.getModel(), children); if (orderedChildTypesAttachment != null) { orderedChildTypesAttachment.addOrderedChildResourceTypes(PathAddress.pathAddress(address), resource); } return addOp; }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.getAttachment(SERVER_LAUNCH_KEY) != null) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.unsupportedLegacyExtension(extensionName)); } super.execute(context, operation); } }
children.addAll(defaultChildren); result.add(createAddOperation(orderedChildTypesAttachment, address, resource, children)); for(final PathElement element : children) { final Resource child = resource.getChild(element); final ModelNode childAddress = address.clone(); childAddress.add(element.getKey(), element.getValue()); describe(orderedChildTypesAttachment, child, childAddress, result, childRegistration);
@Override protected void describe(OrderedChildTypesAttachment orderedChildTypesAttachment, Resource resource, ModelNode address, ModelNode result, ImmutableManagementResourceRegistration registration) { // Don't describe the configuration=endpoint resource. It's just an alias for // a set of attributes on its parent and the parent description covers those. PathElement pe = registration.getPathAddress().getLastElement(); if (!pe.equals(RemotingEndpointResource.ENDPOINT_PATH)) { super.describe(orderedChildTypesAttachment, resource, address, result, registration); } } }
protected ModelNode createAddOperation(final OrderedChildTypesAttachment orderedChildTypesAttachment, final ModelNode address, final Resource resource, final Set<PathElement> children) { ModelNode addOp = createAddOperation(address, resource.getModel(), children); if (orderedChildTypesAttachment != null) { orderedChildTypesAttachment.addOrderedChildResourceTypes(PathAddress.pathAddress(address), resource); } return addOp; }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (context.getAttachment(SERVER_LAUNCH_KEY) != null) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.unsupportedLegacyExtension(extensionName)); } super.execute(context, operation); } }
protected void describe(final Resource resource, final ModelNode address, ModelNode result, final ImmutableManagementResourceRegistration registration) { if(resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) { return; } final Set<PathElement> children; if (comparator == null) { children = registration.getChildAddresses(PathAddress.EMPTY_ADDRESS); } else { children = new TreeSet<PathElement>(comparator); children.addAll(registration.getChildAddresses(PathAddress.EMPTY_ADDRESS)); } result.add(createAddOperation(address, resource.getModel(), children)); for(final PathElement element : children) { if(element.isMultiTarget()) { final String childType = element.getKey(); for(final Resource.ResourceEntry entry : resource.getChildren(childType)) { final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(childType, entry.getName()))); final ModelNode childAddress = address.clone(); childAddress.add(childType, entry.getName()); describe(entry, childAddress, result, childRegistration); } } else { final Resource child = resource.getChild(element); final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(element)); final ModelNode childAddress = address.clone(); childAddress.add(element.getKey(), element.getValue()); describe(child, childAddress, result, childRegistration); } } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode address; final PathAddress pa = PathAddress.pathAddress(PathAddress.pathAddress(operation.require(OP_ADDR))); if (pa.size() > 0) { address = new ModelNode().add(pa.getLastElement().getKey(), pa.getLastElement().getValue()); } else { address = new ModelNode().setEmptyList(); } final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode result = context.getResult(); describe(resource, address, result, context.getResourceRegistration()); context.stepCompleted(); }
/** * Creates a new describe handler. * <p/> * If the comparator is <b>not</b> {@code null} as the handler describes children of a resource the order in which * those children are described is determined using the comparator. This allows the result to order the * add operations for the child resources. * <p/> * If the comparator is {@code null} the order for the child resources is not guaranteed, other than that all * children of a given type will be processed in the order of child names returned by {@link Resource#getChildren(String)} * invoked on the parent. * * @param comparator the comparator used to sort the child addresses */ public static GenericSubsystemDescribeHandler create(final Comparator<PathElement> comparator) { return new GenericSubsystemDescribeHandler(comparator); }
protected void describe(final Resource resource, final ModelNode address, ModelNode result, final ImmutableManagementResourceRegistration registration) { if(resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) { return; } final Set<PathElement> children; if (comparator == null) { children = registration.getChildAddresses(PathAddress.EMPTY_ADDRESS); } else { children = new TreeSet<PathElement>(comparator); children.addAll(registration.getChildAddresses(PathAddress.EMPTY_ADDRESS)); } result.add(createAddOperation(address, resource.getModel(), children)); for(final PathElement element : children) { if(element.isMultiTarget()) { final String childType = element.getKey(); for(final Resource.ResourceEntry entry : resource.getChildren(childType)) { final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(childType, entry.getName()))); final ModelNode childAddress = address.clone(); childAddress.add(childType, entry.getName()); describe(entry, childAddress, result, childRegistration); } } else { final Resource child = resource.getChild(element); final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(element)); final ModelNode childAddress = address.clone(); childAddress.add(element.getKey(), element.getValue()); describe(child, childAddress, result, childRegistration); } } }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode address; final PathAddress pa = context.getCurrentAddress(); AuthorizationResult authResult = context.authorize(operation, DESCRIBE_EFFECTS); if (authResult.getDecision() != AuthorizationResult.Decision.PERMIT) { throw ControllerLogger.ROOT_LOGGER.unauthorized(operation.require(OP).asString(), pa, authResult.getExplanation()); } if (pa.size() > 0) { address = new ModelNode().add(pa.getLastElement().getKey(), pa.getLastElement().getValue()); } else { address = new ModelNode().setEmptyList(); } final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode result = context.getResult(); describe(context.getAttachment(OrderedChildTypesAttachment.KEY), resource, address, result, context.getResourceRegistration()); }
/** * Creates a new describe handler. * <p/> * If the comparator is <b>not</b> {@code null} the {@link ImmutableManagementResourceRegistration#getChildAddresses(org.jboss.as.controller.PathAddress)} * child addresses} from the registration are placed in a sorted collection. This allows the result to order the * add operations for the subsystem resources. * <p/> * If the comparator is {@code null} the order for the {@link ImmutableManagementResourceRegistration#getChildAddresses(org.jboss.as.controller.PathAddress)} * child addresses} is not guaranteed. * * @param comparator the comparator used to sort the child addresses */ public static GenericSubsystemDescribeHandler create(final Comparator<PathElement> comparator) { return new GenericSubsystemDescribeHandler(comparator); }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode address; final PathAddress pa = context.getCurrentAddress(); AuthorizationResult authResult = context.authorize(operation, DESCRIBE_EFFECTS); if (authResult.getDecision() != AuthorizationResult.Decision.PERMIT) { throw ControllerLogger.ROOT_LOGGER.unauthorized(operation.require(OP).asString(), pa, authResult.getExplanation()); } if (pa.size() > 0) { address = new ModelNode().add(pa.getLastElement().getKey(), pa.getLastElement().getValue()); } else { address = new ModelNode().setEmptyList(); } final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode result = context.getResult(); describe(context.getAttachment(OrderedChildTypesAttachment.KEY), resource, address, result, context.getResourceRegistration()); }
/** * Creates a new describe handler. * <p/> * If the comparator is <b>not</b> {@code null} as the handler describes children of a resource the order in which * those children are described is determined using the comparator. This allows the result to order the * add operations for the child resources. * <p/> * If the comparator is {@code null} the order for the child resources is not guaranteed, other than that all * children of a given type will be processed in the order of child names returned by {@link Resource#getChildren(String)} * invoked on the parent. * * @param comparator the comparator used to sort the child addresses */ public static GenericSubsystemDescribeHandler create(final Comparator<PathElement> comparator) { return new GenericSubsystemDescribeHandler(comparator); }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode address; final PathAddress pa = PathAddress.pathAddress(PathAddress.pathAddress(operation.require(OP_ADDR))); AuthorizationResult authResult = context.authorize(operation, DESCRIBE_EFFECTS); if (authResult.getDecision() != AuthorizationResult.Decision.PERMIT) { throw ControllerMessages.MESSAGES.unauthorized(operation.require(OP).asString(), pa, authResult.getExplanation()); } if (pa.size() > 0) { address = new ModelNode().add(pa.getLastElement().getKey(), pa.getLastElement().getValue()); } else { address = new ModelNode().setEmptyList(); } final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode result = context.getResult(); describe(resource, address, result, context.getResourceRegistration()); context.stepCompleted(); }