private String getBundleKey(PathElement path, String[] keys, String... suffixes) { StringBuilder builder = new StringBuilder(this.prefix); for (String value : path.isWildcard() ? new String[] { path.getKey() } : path.getKeyValuePair()) { builder.append('.').append(value); } for (String key : keys) { builder.append('.').append(key); } for (String suffix : suffixes) { builder.append('.').append(suffix); } return builder.toString(); } }
CacheComponent(PathElement... paths) { this(Stream.of(paths).map(path -> path.isWildcard() ? path.getKey() : path.getValue())); }
XMLElement(PathElement path) { this.name = path.isWildcard() ? path.getKey() : path.getValue(); }
XMLElement(PathElement path) { this.name = path.isWildcard() ? path.getKey() : path.getValue(); }
ProtocolResourceDefinition(PathElement path, UnaryOperator<ResourceDescriptor> configurator, ResourceServiceConfiguratorFactory serviceConfiguratorFactory, ResourceServiceConfiguratorFactory parentServiceConfiguratorFactory) { super(new Parameters(path, path.isWildcard() ? JGroupsExtension.SUBSYSTEM_RESOLVER.createChildResolver(path) : JGroupsExtension.SUBSYSTEM_RESOLVER.createChildResolver(path, WILDCARD_PATH)).setOrderedChild(), new ResourceDescriptorConfigurator(configurator), serviceConfiguratorFactory, parentServiceConfiguratorFactory); } }
@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); } }
} else if (i < target.size()) { PathElement targetElement = target.getElement(i); result.add(targetElement.isWildcard() ? PathElement.pathElement(targetElement.getKey(), element.getValue()) : targetElement); } else { result.add(element);
@SuppressWarnings("deprecation") @Override public ManagementResourceRegistration register(ManagementResourceRegistration parent) { ManagementResourceRegistration registration = parent.registerSubModel(this); ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())) .addAttributes(Attribute.class) .addExtraParameters(DeprecatedAttribute.class) ; new RestartParentResourceRegistration(this.parentServiceConfiguratorFactory, descriptor, this.handler).register(registration); if (registration.getPathAddress().getLastElement().isWildcard()) { new PropertyResourceDefinition().register(registration); } return registration; } }
if (registration.getPathAddress().getLastElement().isWildcard()) { for (ThreadPoolResourceDefinition pool : EnumSet.allOf(ThreadPoolResourceDefinition.class)) { pool.register(registration); if (registration.getPathAddress().getLastElement().isWildcard()) { parent.registerAlias(LEGACY_PATH, new AliasEntry(registration) { @Override
/** * @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; } }
if (registration.getPathAddress().getLastElement().isWildcard()) { OverrideDescriptionProvider provider = new OverrideDescriptionProvider() { @Override
/** * Determine whether the given element matches this element. * An element matches this element when keys are equal, values are equal * or this element value is a wildcard. * @param pe the element to check * @return {@code true} if the element matches */ public boolean matches(PathElement pe) { return pe.key.equals(key) && (isWildcard() || pe.value.equals(value)); }
/** * Gets the maximum number of times a resource of the type described by this definition * can occur under its parent resource (or, for a root resource, the minimum number of times it can * occur at all.) * * @return the minimum number of occurrences */ default int getMaxOccurs() { PathElement pe = getPathElement(); return pe == null || !pe.isWildcard() ? 1 : Integer.MAX_VALUE; }
@Override public ResourceTransformationDescriptionBuilder addChildRedirection(PathElement current, PathElement legacy, DynamicDiscardPolicy dynamicDiscardPolicy) { final PathAddressTransformer transformation; if (legacy.isWildcard()) { assert current.isWildcard() : "legacy is wildcard while current is not"; transformation = new PathAddressTransformer.ReplaceElementKey(legacy.getKey()); } else { assert !current.isWildcard() : "legacy is fixed while current is not"; transformation = new PathAddressTransformer.BasicPathAddressTransformer(legacy); } return addChildRedirection(current, transformation, dynamicDiscardPolicy); }
private PersistentResourceXMLBuilder(final PathElement pathElement, String namespaceURI) { this.pathElement = pathElement; this.namespaceURI = namespaceURI; this.xmlElementName = pathElement.isWildcard() ? pathElement.getKey() : pathElement.getValue(); }
private PersistentResourceXMLBuilder(final PathElement pathElement) { this.pathElement = pathElement; this.namespaceURI = null; this.xmlElementName = pathElement.isWildcard() ? pathElement.getKey() : pathElement.getValue(); }
private static boolean matches(PathElement pattern, PathElement element) { if (!pattern.getKey().equals(element.getKey())) { return false; } if (pattern.isWildcard()) { return true; } return pattern.getValue().equals(element.getValue()); } }
/** * Gets the maximum number of times a resource of the type described by this registration * can occur under its parent resource (or, for a root resource, the minimum number of times it can * occur at all.) * * @return the minimum number of occurrences */ default int getMaxOccurs() { PathAddress pa = getPathAddress(); return pa.size() == 0 || !pa.getLastElement().isWildcard() ? 1 : Integer.MAX_VALUE; }
@Override public boolean hasChild(final PathElement address) { final ResourceProvider provider = getProvider(address.getKey()); if(provider == null) { return false; } if(address.isWildcard()) { return provider.hasChildren(); } return provider.has(address.getValue()); }
private boolean definedInModel(ModelNode model, PersistentResourceXMLDescription child) { PathElement pe = child.getPathElement(); boolean wildcard = getPathElement().isWildcard(); if (wildcard ? model.hasDefined(pe.getKey()) : model.hasDefined(pe.getKeyValuePair())){ return true; } return false; }