"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "clustering/common/src/main/java/org/jboss/as/clustering/controller/PredicateCapabilityReference.java" between
wildfly-21.0.0.Final-src.zip and wildfly-21.0.1.Final-src.zip

About: WildFly is an application server with a standards-compliant, fast and lightweight implementation of the Java Enterprise Edition 7 Platform specifications (formerly known as JBoss community version). Sources.

PredicateCapabilityReference.java  (wildfly-21.0.0.Final-src):PredicateCapabilityReference.java  (wildfly-21.0.1.Final-src)
skipping to change at line 25 skipping to change at line 25
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free * License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/ */
package org.jboss.as.clustering.controller; package org.jboss.as.clustering.controller;
import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.jboss.as.controller.OperationContext; import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.controller.registry.Resource; import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode; import org.jboss.dmr.ModelNode;
import org.wildfly.clustering.service.BinaryRequirement; import org.wildfly.clustering.service.BinaryRequirement;
import org.wildfly.clustering.service.Requirement; import org.wildfly.clustering.service.Requirement;
import org.wildfly.clustering.service.UnaryRequirement; import org.wildfly.clustering.service.UnaryRequirement;
/** /**
* A capability reference recorder that registers a given requirement conditiona lly based the attribute value. * A capability reference recorder that registers a given requirement conditiona lly based the attribute value.
* @author Paul Ferraro * @author Paul Ferraro
*/ */
public class PredicateCapabilityReference extends AbstractCapabilityReference { public class PredicateCapabilityReference extends ResourceCapabilityReference {
private static final Predicate<ModelNode> BOOLEAN = ModelNode::asBoolean; private static final Predicate<ModelNode> BOOLEAN = ModelNode::asBoolean;
private final Function<PathAddress, String[]> requirementNameResolver;
private final Predicate<ModelNode> predicate; private final Predicate<ModelNode> predicate;
/** /**
* Creates a new reference between the specified capability and the specifie d requirement for boolean attributes. * Creates a new reference between the specified capability and the specifie d requirement for boolean attributes.
* @param capability the capability referencing the specified requirement * @param capability the capability referencing the specified requirement
* @param requirement the requirement of the specified capability * @param requirement the requirement of the specified capability
*/ */
public PredicateCapabilityReference(Capability capability, Requirement requi rement) { public PredicateCapabilityReference(Capability capability, Requirement requi rement) {
this(capability, requirement, new SimpleCapabilityNameResolver(), BOOLEA N); this(capability, requirement, BOOLEAN);
} }
/** /**
* Creates a new reference between the specified capability and the specifie d requirement * Creates a new reference between the specified capability and the specifie d requirement
* @param capability the capability referencing the specified requirement * @param capability the capability referencing the specified requirement
* @param requirement the requirement of the specified capability * @param requirement the requirement of the specified capability
* @param predicate a predicate that determines for which values the require ment should be registered * @param predicate a predicate that determines for which values the require ment should be registered
*/ */
public PredicateCapabilityReference(Capability capability, Requirement requi rement, Predicate<ModelNode> predicate) { public PredicateCapabilityReference(Capability capability, Requirement requi rement, Predicate<ModelNode> predicate) {
this(capability, requirement, new SimpleCapabilityNameResolver(), predic super(capability, requirement);
ate); this.predicate = predicate;
} }
/** /**
* Creates a new reference between the specified capability and the specifie d requirement * Creates a new reference between the specified capability and the specifie d requirement
* @param capability the capability referencing the specified requirement * @param capability the capability referencing the specified requirement
* @param requirement the requirement of the specified capability * @param requirement the requirement of the specified capability
* @param requirementNameResolver function for resolving the dynamic element s of the requirement name * @param requirementNameResolver function for resolving the dynamic element s of the requirement name
*/ */
public PredicateCapabilityReference(Capability capability, UnaryRequirement requirement, UnaryCapabilityNameResolver requirementNameResolver) { public PredicateCapabilityReference(Capability capability, UnaryRequirement requirement, UnaryCapabilityNameResolver requirementNameResolver) {
this(capability, requirement, requirementNameResolver, BOOLEAN); this(capability, requirement, requirementNameResolver, BOOLEAN);
} }
/** /**
* Creates a new reference between the specified capability and the specifie d requirement * Creates a new reference between the specified capability and the specifie d requirement
* @param capability the capability referencing the specified requirement * @param capability the capability referencing the specified requirement
* @param requirement the requirement of the specified capability * @param requirement the requirement of the specified capability
* @param requirementNameResolver function for resolving the dynamic element s of the requirement name * @param requirementNameResolver function for resolving the dynamic element s of the requirement name
* @param predicate a predicate that determines for which values the require ment should be registered * @param predicate a predicate that determines for which values the require ment should be registered
*/ */
public PredicateCapabilityReference(Capability capability, UnaryRequirement requirement, UnaryCapabilityNameResolver requirementNameResolver, Predicate<Mode lNode> predicate) { public PredicateCapabilityReference(Capability capability, UnaryRequirement requirement, UnaryCapabilityNameResolver requirementNameResolver, Predicate<Mode lNode> predicate) {
this(capability, (Requirement) requirement, requirementNameResolver, pre super(capability, requirement, requirementNameResolver);
dicate); this.predicate = predicate;
} }
/** /**
* Creates a new reference between the specified capability and the specifie d requirement * Creates a new reference between the specified capability and the specifie d requirement
* @param capability the capability referencing the specified requirement * @param capability the capability referencing the specified requirement
* @param requirement the requirement of the specified capability * @param requirement the requirement of the specified capability
* @param requirementNameResolver function for resolving the dynamic element s of the requirement name * @param requirementNameResolver function for resolving the dynamic element s of the requirement name
* @param predicate a predicate that determines for which values the require ment should be registered * @param predicate a predicate that determines for which values the require ment should be registered
*/ */
public PredicateCapabilityReference(Capability capability, BinaryRequirement requirement, BinaryCapabilityNameResolver requirementNameResolver) { public PredicateCapabilityReference(Capability capability, BinaryRequirement requirement, BinaryCapabilityNameResolver requirementNameResolver) {
this(capability, (Requirement) requirement, requirementNameResolver, BOO LEAN); this(capability, requirement, requirementNameResolver, BOOLEAN);
} }
/** /**
* Creates a new reference between the specified capability and the specifie d requirement * Creates a new reference between the specified capability and the specifie d requirement
* @param capability the capability referencing the specified requirement * @param capability the capability referencing the specified requirement
* @param requirement the requirement of the specified capability * @param requirement the requirement of the specified capability
* @param requirementNameResolver function for resolving the dynamic element s of the requirement name * @param requirementNameResolver function for resolving the dynamic element s of the requirement name
* @param predicate a predicate that determines for which values the require ment should be registered * @param predicate a predicate that determines for which values the require ment should be registered
*/ */
public PredicateCapabilityReference(Capability capability, BinaryRequirement requirement, BinaryCapabilityNameResolver requirementNameResolver, Predicate<Mo delNode> predicate) { public PredicateCapabilityReference(Capability capability, BinaryRequirement requirement, BinaryCapabilityNameResolver requirementNameResolver, Predicate<Mo delNode> predicate) {
this(capability, (Requirement) requirement, requirementNameResolver, pre super(capability, requirement, requirementNameResolver);
dicate);
}
private PredicateCapabilityReference(Capability capability, Requirement requ
irement, Function<PathAddress, String[]> requirementNameResolver, Predicate<Mode
lNode> predicate) {
super(capability, requirement);
this.requirementNameResolver = requirementNameResolver;
this.predicate = predicate; this.predicate = predicate;
} }
@Override @Override
public void addCapabilityRequirements(OperationContext context, Resource res ource, String attributeName, String... values) { public void addCapabilityRequirements(OperationContext context, Resource res ource, String attributeName, String... values) {
for (String value : values) { for (String value : values) {
if (this.predicate.test(new ModelNode(value))) { if (this.predicate.test(new ModelNode(value))) {
context.registerAdditionalCapabilityRequirement(this.getRequirem entName(context), this.getDependentName(context), attributeName); super.addCapabilityRequirements(context, resource, attributeName , value);
} }
} }
} }
@Override @Override
public void removeCapabilityRequirements(OperationContext context, Resource resource, String attributeName, String... values) { public void removeCapabilityRequirements(OperationContext context, Resource resource, String attributeName, String... values) {
for (String value : values) { for (String value : values) {
if (this.predicate.test(new ModelNode(value))) { if (this.predicate.test(new ModelNode(value))) {
context.deregisterCapabilityRequirement(this.getRequirementName( super.removeCapabilityRequirements(context, resource, attributeN
context), this.getDependentName(context)); ame, value);
}
}
}
private String getRequirementName(OperationContext context) {
String[] parts = this.requirementNameResolver.apply(context.getCurrentAd
dress());
return (parts.length > 0) ? RuntimeCapability.buildDynamicCapabilityName
(this.getBaseRequirementName(), parts) : this.getBaseRequirementName();
}
@Override
public String[] getRequirementPatternSegments(String name, PathAddress addre
ss) {
String[] segments = this.requirementNameResolver.apply(address);
for (int i = 0; i < segments.length; ++i) {
String segment = segments[i];
if (segment.charAt(0) == '$') {
segments[i] = segment.substring(1);
} }
} }
return segments;
} }
} }
 End of changes. 12 change blocks. 
43 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)