/** * @param childType * @return * @see org.jboss.as.controller.registry.Resource#hasChildren(java.lang.String) */ public boolean hasChildren(String childType) { return delegate.hasChildren(childType); }
@Override public boolean hasChildren(String childType) { return delegate.hasChildren(childType); }
@Override public boolean hasChildren(String childType) { return delegate.hasChildren(childType); }
@Override public boolean hasChildren(final String childType) { if (BALANCER.equals(childType)) { return !getChildrenNames(BALANCER).isEmpty(); } return delegate.hasChildren(childType); }
@Override public boolean hasChildren(final String childType) { if (BatchJobExecutionResourceDefinition.EXECUTION.equals(childType)) { return !getChildrenNames(BatchJobExecutionResourceDefinition.EXECUTION).isEmpty(); } return delegate.hasChildren(childType); }
@Override public DiscardPolicy checkResource(TransformationContext context, PathAddress address) { Resource resource = context.readResourceFromRoot(address.getParent()); if (resource.hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()) && resource.getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()).size() > 1) { return DiscardPolicy.REJECT_AND_WARN; } return DiscardPolicy.NEVER; } }
@Override public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) { if (value.isDefined()) { PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); String poolName = value.asString(); for (String type : Arrays.asList("data-source", "xa-data-source")) { if (subsystem.hasChildren(type)) { for (Resource.ResourceEntry entry : subsystem.getChildren(type)) { if (entry.getName().equals(poolName)) { value.set(entry.getModel().get("jndi-name")); return; } } } } } } };
@Override public AttributeValueTranslator getWriteTranslator() { return (context, value) -> { String jndiName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { if (subsystem.hasChildren(type)) { for (Resource.ResourceEntry entry : subsystem.getChildren(type)) { ModelNode model = entry.getModel(); if (model.get("jndi-name").asString().equals(jndiName)) { return new ModelNode(entry.getName()); } } } } throw InfinispanLogger.ROOT_LOGGER.dataSourceJndiNameNotFound(jndiName); }; } };
if (subsystemResource.hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) { Set<String> adapterNames = new HashSet<>(); Set<LoadMetric> enabledMetrics = new HashSet<>();
@Override public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) { PathAddress rebuiltAddress = PathAddress.EMPTY_ADDRESS; for (PathElement pathElement : aliasAddress) { if (pathElement.equals(LEGACY_PATH)) { try { if (aliasContext.readResourceFromRoot(rebuiltAddress, false).hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) { Set<Resource.ResourceEntry> children = aliasContext.readResourceFromRoot(rebuiltAddress, false).getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()); if (children.size() > 1 && !Operations.getOperationName(aliasContext.getOperation()).equals(AliasContext.RECURSIVE_GLOBAL_OP)) { throw new IllegalStateException(ModClusterLogger.ROOT_LOGGER.legacyOperationsWithMultipleProxies()); } PathAddress proxyPath = PathAddress.pathAddress(ProxyConfigurationResourceDefinition.pathElement(children.iterator().next().getName())); rebuiltAddress = rebuiltAddress.append(proxyPath); } else { // handle :add rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.pathElement("default")); } } catch (Resource.NoSuchResourceException ignore) { // handle recursive-global-op rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.WILDCARD_PATH); } } else { rebuiltAddress = rebuiltAddress.append(pathElement); } } return rebuiltAddress; } });
addRequiredChildren(context, this.descriptor.getRequiredSingletonChildren(), (Resource parent, PathElement path) -> parent.hasChildren(path.getKey()));
/** * @return contextual discard policy if any resource attributes are undefined and has no children; {@link DiscardPolicy#SILENT} otherwise. */ @Override public DiscardPolicy checkResource(TransformationContext context, PathAddress address) { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ImmutableManagementResourceRegistration registration = context.getResourceRegistration(PathAddress.EMPTY_ADDRESS); ModelNode model = resource.getModel(); if (model.isDefined()) { for (String attribute : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { if (model.hasDefined(attribute)) { return this.policy; } } } for (PathElement path : registration.getChildAddresses(PathAddress.EMPTY_ADDRESS)) { if (path.isWildcard() ? resource.hasChildren(path.getKey()) : resource.hasChild(path)) { return this.policy; } } return DiscardPolicy.SILENT; } }
@Override public boolean hasChildren(final String childType) { if (BALANCER.equals(childType)) { return !getChildrenNames(BALANCER).isEmpty(); } return delegate.hasChildren(childType); }
@Override public boolean hasChildren(final String childType) { if (BatchJobExecutionResourceDefinition.EXECUTION.equals(childType)) { return !getChildrenNames(BatchJobExecutionResourceDefinition.EXECUTION).isEmpty(); } return delegate.hasChildren(childType); }
@Override public boolean hasChildren(String childType) { if (ModelConstants.BUNDLE.equals(childType)) return getChildrenNames(ModelConstants.BUNDLE).size() > 0; else return delegate.hasChildren(childType); }
@Override public boolean hasChildren(final String childType) { if (BALANCER.equals(childType)) { return !getChildrenNames(BALANCER).isEmpty(); } return delegate.hasChildren(childType); }
@Override public boolean hasChildren(String childType) { if (CORE_ADDRESS.equals(childType)) { return getChildrenNames(CORE_ADDRESS).size() > 0; } else if (RUNTIME_QUEUE.equals(childType)) { return getChildrenNames(RUNTIME_QUEUE).size() > 0; } else { return delegate.hasChildren(childType); } }
@Override public boolean hasChildren(String childType) { if (CORE_ADDRESS.equals(childType)) { return getChildrenNames(CORE_ADDRESS).size() > 0; } else if (RUNTIME_QUEUE.equals(childType)) { return getChildrenNames(RUNTIME_QUEUE).size() > 0; } else { return delegate.hasChildren(childType); } }
private static Set<String> listServerGroupsReferencingOverlay(Resource rootResource, String overlayName) { final PathElement overlayPath = PathElement.pathElement(DEPLOYMENT_OVERLAY, overlayName); if (rootResource.hasChildren(SERVER_GROUP)) { Set<String> set = new HashSet<>(); for (String serverGroupName : rootResource.getChildrenNames(SERVER_GROUP)) { if (rootResource.getChild(PathElement.pathElement(SERVER_GROUP, serverGroupName)).hasChild(overlayPath)) { set.add(serverGroupName); } } return set; } return Collections.emptySet(); }
@Override public DiscardPolicy checkResource(TransformationContext context, PathAddress address) { Resource resource = context.readResourceFromRoot(address.getParent()); if (resource.hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()) && resource.getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey()).size() > 1) { return DiscardPolicy.REJECT_AND_WARN; } return DiscardPolicy.NEVER; } }