Java Code Examples for org.jboss.as.controller.registry.Resource#ResourceEntry
The following examples show how to use
org.jboss.as.controller.registry.Resource#ResourceEntry .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperationContextImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Resource getAuthorizationResource(PathAddress address) { Resource model = this.managementModel.getRootResource(); for (PathElement element : address) { // Allow wildcard navigation for the last element if (element.isWildcard()) { model = Resource.Factory.create(); final Set<Resource.ResourceEntry> children = model.getChildren(element.getKey()); for (final Resource.ResourceEntry entry : children) { model.registerChild(entry.getPathElement(), entry); } } else { model = model.getChild(element); if (model == null) { return Resource.Factory.create(); } } } return model; }
Example 2
Source File: HostDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void initModelServices(final OperationContext context, final PathAddress hostAddress, final Resource rootResource) { // Create the management resources Resource management = context.createResource(hostAddress.append(PathElement.pathElement(CORE_SERVICE, MANAGEMENT))); if (modelControllerResource != null) { management.registerChild(PathElement.pathElement(SERVICE, MANAGEMENT_OPERATIONS), modelControllerResource); } //Create the empty host-environment resource context.addResource(hostAddress.append(PathElement.pathElement(CORE_SERVICE, HOST_ENVIRONMENT)), PlaceholderResource.INSTANCE); //Create the empty module-loading resource rootResource.registerChild(PathElement.pathElement(ModelDescriptionConstants.CORE_SERVICE, ModelDescriptionConstants.MODULE_LOADING), PlaceholderResource.INSTANCE); //Create the empty capability registry resource rootResource.registerChild(PathElement.pathElement(ModelDescriptionConstants.CORE_SERVICE, ModelDescriptionConstants.CAPABILITY_REGISTRY), PlaceholderResource.INSTANCE); // Wire in the platform mbean resources. We're bypassing the context.createResource API here because // we want to use our own resource type. But it's ok as the createResource calls above have taken the lock rootResource.registerChild(PlatformMBeanConstants.ROOT_PATH, new RootPlatformMBeanResource()); // Wire in the ignored-resources resource Resource.ResourceEntry ignoredRoot = ignoredDomainResourceRegistry.getRootResource(); rootResource.registerChild(ignoredRoot.getPathElement(), ignoredRoot); // Create the empty discovery options resource context.addResource(hostAddress.append(PathElement.pathElement(CORE_SERVICE, DISCOVERY_OPTIONS)), new DiscoveryOptionsResource()); }
Example 3
Source File: DeploymentRemoveHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
protected void checkCanRemove(OperationContext context, ModelNode operation) throws OperationFailedException { final String deploymentName = PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement().getValue(); final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); if(root.hasChild(PathElement.pathElement(SERVER_GROUP))) { final List<String> badGroups = new ArrayList<String>(); for(final Resource.ResourceEntry entry : root.getChildren(SERVER_GROUP)) { if(entry.hasChild(PathElement.pathElement(DEPLOYMENT, deploymentName))) { badGroups.add(entry.getName()); } } if (badGroups.size() > 0) { throw new OperationFailedException(DomainControllerLogger.ROOT_LOGGER.cannotRemoveDeploymentInUse(deploymentName, badGroups)); } } }
Example 4
Source File: ReadMasterDomainModelUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void describe(final PathAddress base, final Resource resource, List<ModelNode> nodes, boolean isRuntimeChange) { if (resource.isProxy() || resource.isRuntime()) { return; // ignore runtime and proxies } else if (base.size() >= 1 && base.getElement(0).getKey().equals(ModelDescriptionConstants.HOST)) { return; // ignore hosts } if (base.size() == 1) { newRootResources.add(base.getLastElement()); } final ModelNode description = new ModelNode(); description.get(DOMAIN_RESOURCE_ADDRESS).set(base.toModelNode()); description.get(DOMAIN_RESOURCE_MODEL).set(resource.getModel()); Set<String> orderedChildren = resource.getOrderedChildTypes(); if (orderedChildren.size() > 0) { ModelNode orderedChildTypes = description.get(DOMAIN_RESOURCE_PROPERTIES, ORDERED_CHILD_TYPES_PROPERTY); for (String type : orderedChildren) { orderedChildTypes.add(type); } } nodes.add(description); for (final String childType : resource.getChildTypes()) { for (final Resource.ResourceEntry entry : resource.getChildren(childType)) { describe(base.append(entry.getPathElement()), entry, nodes, isRuntimeChange); } } }
Example 5
Source File: ReadMasterDomainModelUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static void processHostModel(final RequiredConfigurationHolder holder, final Resource domain, final Resource hostModel, ExtensionRegistry extensionRegistry) { final Set<String> serverGroups = holder.serverGroups; for (final Resource.ResourceEntry entry : hostModel.getChildren(SERVER_CONFIG)) { final ModelNode model = entry.getModel(); final String serverGroup = model.get(GROUP).asString(); if (!serverGroups.contains(serverGroup)) { serverGroups.add(serverGroup); } if (model.hasDefined(SOCKET_BINDING_GROUP)) { final String socketBindingGroup = model.get(SOCKET_BINDING_GROUP).asString(); processSocketBindingGroup(domain, socketBindingGroup, holder); } // Always process the server group, since it may be different between the current vs. original model processServerGroup(holder, serverGroup, domain, extensionRegistry); } }
Example 6
Source File: ReadConfigAsFeaturesOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void describeChildren(final Resource resource, final ImmutableManagementResourceRegistration registration, final PathAddress address, OperationContext context, final AtomicReference<ModelNode> failureRef, final ModelNode results, ModelNode operation, Boolean nest) { for(String childType : resource.getChildTypes()) { for(Resource.ResourceEntry entry : resource.getChildren(childType)) { if(addressFilter != null && !addressFilter.accepts(address.append(entry.getPathElement()))) { continue; } final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.EMPTY_ADDRESS.append(entry.getPathElement())); if(childRegistration == null) { ControllerLogger.ROOT_LOGGER.debugf("Couldn't find a registration for %s at %s for resource %s at %s", entry.getPathElement().toString(), registration.getPathAddress().toCLIStyleString(), resource, address.toCLIStyleString()); continue; } if(childRegistration.isRuntimeOnly() || childRegistration.isRemote() || childRegistration.isAlias()) { continue; } describeChildResource(entry, registration, address, context, failureRef, results, operation, nest); } } }
Example 7
Source File: HttpConnectorAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = context.getCurrentAddress(); final String connectorName = address.getLastElement().getValue(); PathAddress parentAddress = address.getParent(); Resource parent = context.readResourceFromRoot(parentAddress, false); Resource resource = context.readResourceFromRoot(address, false); ModelNode resourceRef = resource.getModel().get(CommonAttributes.CONNECTOR_REF); boolean listenerAlreadyExists = false; for(Resource.ResourceEntry child: parent.getChildren(CommonAttributes.HTTP_CONNECTOR)) { if(!connectorName.equals(child.getName())) { Resource childResource = context.readResourceFromRoot(PathAddress.pathAddress(parentAddress, child.getPathElement()), false); if(childResource.getModel().get(CommonAttributes.CONNECTOR_REF).equals(resourceRef)) { listenerAlreadyExists = true; break; } } } if(listenerAlreadyExists) { throw ControllerLogger.ROOT_LOGGER.alreadyDefinedAttribute(CommonAttributes.HTTP_CONNECTOR, resourceRef.asString(), CommonAttributes.CONNECTOR_REF); } }
Example 8
Source File: IncludingResourceCapabilityScope.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static Set<String> getIncludes(Resource.ResourceEntry resource) { Set<String> result; ModelNode model = resource.getModel(); if (model.hasDefined(INCLUDES)) { result = new HashSet<>(); for (ModelNode node : model.get(INCLUDES).asList()) { result.add(node.asString()); } } else { result = Collections.emptySet(); } return result; }
Example 9
Source File: ManagedDMRContentTypeResource.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public Set<Resource.ResourceEntry> getChildren(String childType) { if (!hasChildren(childType)) { return Collections.emptySet(); } else { Set<Resource.ResourceEntry> result = new HashSet<ResourceEntry>(); synchronized (content) { for (String name : content.keySet()) { result.add(getChildEntry(name)); } } return result; } }
Example 10
Source File: AbstractPlatformMBeanResource.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public Set<Resource.ResourceEntry> getChildren(String childType) { if (!hasChildren(childType)) { return Collections.emptySet(); } else { Set<Resource.ResourceEntry> result = new LinkedHashSet<ResourceEntry>(); for (String name : getChildrenNames()) { result.add(getChildEntry(name)); } return result; } }
Example 11
Source File: OrderedChildResourceSyncModelTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testComplexInsertOrderedChildrenModelSync() throws Exception { //Complex test ModelNode originalModel = readResourceRecursive(); Resource rootResource = createMasterDcResources(); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "grape", 1); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "lemon", 1); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "pear", 0); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "cherry"); ModelNode master = Resource.Tools.readModel(rootResource); executeTriggerSyncOperation(rootResource); ModelNode currentModel = readResourceRecursive(); Assert.assertNotEquals(originalModel, currentModel); compare(findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey()).keys(), "pear", "apple", "lemon", "grape", "orange", "cherry"); compareSubsystemModels(master, currentModel); Resource subsystemResource = findSubsystemResource(rootResource); subsystemResource.removeChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "pear")); subsystemResource.removeChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "apple")); subsystemResource.removeChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "lemon")); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "kiwi", 1); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "melon", 100); for (Resource.ResourceEntry child : subsystemResource.getChildren(ORDERED_CHILD.getKey())) { child.getModel().get(ATTR.getName()).set(child.getModel().get(ATTR.getName()).asString() + "$" + child.getName()); } master = Resource.Tools.readModel(rootResource); executeTriggerSyncOperation(rootResource); currentModel = readResourceRecursive(); Assert.assertNotEquals(originalModel, currentModel); compare(findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey()).keys(), "grape", "kiwi", "orange", "cherry", "melon"); compareSubsystemModels(master, currentModel); }
Example 12
Source File: ResourceTransformationContextImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void processChildren(final Resource resource) throws OperationFailedException { final Set<String> types = resource.getChildTypes(); for (final String type : types) { for (final Resource.ResourceEntry child : resource.getChildren(type)) { processChild(child.getPathElement(), child); } } }
Example 13
Source File: TransformationRule.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public Set<ResourceEntry> getChildren(String childType) { Set<ResourceEntry> children = delegate.getChildren(childType); if (children != null) { Set<ResourceEntry> protectedChildren = new LinkedHashSet<Resource.ResourceEntry>(); for (ResourceEntry entry : children) { protectedChildren.add(new ProtectedModelResourceEntry(entry)); } return protectedChildren; } return null; }
Example 14
Source File: ModelControllerImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
Resource.ResourceEntry getModelControllerResource() { return modelControllerResource; }
Example 15
Source File: OperationContextImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
Resource.ResourceEntry getActiveOperationResource() { return activeOperationResource; }
Example 16
Source File: AbstractOperationTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static void hack(final Resource rootResource, final String type) { rootResource.registerChild(PathElement.pathElement(type, "hack"), Resource.Factory.create()); for (Resource.ResourceEntry entry : rootResource.getChildren(type)) { rootResource.removeChild(entry.getPathElement()); } }
Example 17
Source File: OrderedChildMoreLevelsResourceSyncModelTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testComplexInsertOrderedChildrenModelSync() throws Exception { //Complex test ModelNode originalModel = readResourceRecursive(); Resource rootResource = createMasterDcResources(); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "grape", 1); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "lemon", 1); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "pear", 0); Resource cherry = createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "cherry"); createChildResource(cherry, EXTRA_CHILD.getKey(), "compot", 1); createChildResource(cherry, EXTRA_CHILD.getKey(), "cake", 1); createChildResource(cherry, EXTRA_CHILD.getKey(), "pancake", 0); createChildResource(cherry, EXTRA_CHILD.getKey(), "cider", -1); Resource apple = findSubsystemResource(rootResource).getChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "apple")); createChildResource(apple, EXTRA_CHILD.getKey(), "compot", 1); createChildResource(apple, EXTRA_CHILD.getKey(), "cake", 1); createChildResource(apple, EXTRA_CHILD.getKey(), "pancake", 0); createChildResource(apple, EXTRA_CHILD.getKey(), "cider", -1); ModelNode master = Resource.Tools.readModel(rootResource); executeTriggerSyncOperation(rootResource); ModelNode currentModel = readResourceRecursive(); Assert.assertNotEquals(originalModel, currentModel); compare(findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey()).keys(), "pear", "apple", "lemon", "grape", "orange", "cherry"); Set<String> appleKeys = findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey(), "apple", EXTRA_CHILD.getKey()).keys(); compare(appleKeys, "pancake", "jam", "cake", "compot", "juice", "cider"); Set<String> cherryKeys = findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey(), "cherry", EXTRA_CHILD.getKey()).keys(); compare(cherryKeys, "pancake", "jam", "cake", "compot", "juice", "cider"); compareSubsystemModels(master, currentModel); Resource subsystemResource = findSubsystemResource(rootResource); subsystemResource.removeChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "pear")); subsystemResource.removeChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "apple")); subsystemResource.removeChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "lemon")); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "kiwi", 1); createAndRegisterSubsystemChildFromRoot(rootResource, ORDERED_CHILD.getKey(), "melon", 100); Resource orange = findSubsystemResource(rootResource).getChild(PathElement.pathElement(ORDERED_CHILD.getKey(), "orange")); orange.removeChild(PathElement.pathElement(EXTRA_CHILD.getKey(), "juice")); createChildResource(orange, EXTRA_CHILD.getKey(), "marmelade", 0); for (Resource.ResourceEntry child : subsystemResource.getChildren(ORDERED_CHILD.getKey())) { child.getModel().get(ATTR.getName()).set(child.getModel().get(ATTR.getName()).asString() + "$" + child.getName()); for (Resource.ResourceEntry extraChild : child.getChildren(EXTRA_CHILD.getKey())) { extraChild.getModel().get(ATTR.getName()).set(extraChild.getModel().get(ATTR.getName()).asString() + "$" + extraChild.getName()); } } master = Resource.Tools.readModel(rootResource); executeTriggerSyncOperation(rootResource); currentModel = readResourceRecursive(); Assert.assertNotEquals(originalModel, currentModel); compare(findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey()).keys(), "grape", "kiwi", "orange", "cherry", "melon"); cherryKeys = findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey(), "cherry", EXTRA_CHILD.getKey()).keys(); compare(cherryKeys, "pancake", "jam", "cake", "compot", "juice", "cider"); Set<String> orangeKeys = findSubsystemResource(currentModel).get(ORDERED_CHILD.getKey(), "orange", EXTRA_CHILD.getKey()).keys(); compare(orangeKeys, "marmelade", "jam"); // <-- The order in current model is wrong compareSubsystemModels(master, currentModel); }
Example 18
Source File: IgnoredDomainResourceRegistry.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public Resource.ResourceEntry getRootResource() { IgnoredDomainResourceRoot root = new IgnoredDomainResourceRoot(this); this.rootResource = root; return root; }
Example 19
Source File: AccessConstraintAppliesToResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static Resource.ResourceEntry createResource(AccessConstraintUtilization constraintUtilization) { return new AccessConstraintAppliesToResource(constraintUtilization); }
Example 20
Source File: AbstractClassificationResource.java From wildfly-core with GNU Lesser General Public License v2.1 | votes |
public abstract Set<Resource.ResourceEntry> getChildren(String childType);