final RuntimeType runtimeConstraint,
final boolean scanned,
final boolean isResource) {
final Set<Class<?>> contracts = model.getContracts();
final ConstrainedTo constrainedTo = component.getAnnotation(ConstrainedTo.class);
final RuntimeType componentConstraint = constrainedTo == null ? null : constrainedTo.value();
if (Feature.class.isAssignableFrom(component)) {
// TODO: solve after implementation
return true;
}
final StringBuilder warnings = new StringBuilder();
try {
/**
* Indicates that the provider implements at least one contract compatible
* with it's implementation class constraint.
*/
boolean foundComponentCompatible = componentConstraint == null;
boolean foundRuntimeCompatibleContract = isResource && runtimeConstraint == RuntimeType.SERVER;
for (final Class<?> contract : contracts) {
// if the contract is common/not constrained, default to provider constraint
final RuntimeType contractConstraint = getContractConstraint(contract, componentConstraint);
foundRuntimeCompatibleContract |= contractConstraint == null || contractConstraint == runtimeConstraint;
if (componentConstraint != null) {
if (contractConstraint != componentConstraint) {
warnings.append(LocalizationMessages.WARNING_PROVIDER_CONSTRAINED_TO_WRONG_PACKAGE(
component.getName(),
componentConstraint.name(),
contract.getName(),
contractConstraint.name()))
.append(" ");
} else {
foundComponentCompatible = true;
}
}