org.jboss.as.clustering.controller.RequirementCapability Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wildfly-clustering-common Show documentation
Show all versions of wildfly-clustering-common Show documentation
The code in this module is not explicitly related to clustering, but rather contains resuable code used by clustering modules
and any modules that integrate with clustering.
The newest version!
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.as.clustering.controller;
import java.util.function.UnaryOperator;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.wildfly.clustering.service.Requirement;
/**
* Provides a capability definition provider built from a requirement.
* @author Paul Ferraro
*/
public class RequirementCapability implements Capability {
private final RuntimeCapability definition;
/**
* Creates a new capability based on the specified requirement
* @param requirement the requirement basis
*/
public RequirementCapability(Requirement requirement) {
this(requirement, UnaryOperator.identity());
}
/**
* Creates a new capability based on the specified requirement
* @param requirement the requirement basis
* @param configurator configures the capability
*/
public RequirementCapability(Requirement requirement, UnaryOperator> configurator) {
this.definition = configurator.apply(RuntimeCapability.Builder.of(requirement.getName()).setServiceType(requirement.getType())).build();
}
@Override
public RuntimeCapability getDefinition() {
return this.definition;
}
}