ActivationConditionHandler release() { if (activationCondition != null) { eventBus.unregister(this); nexusActiveCondition.release(); activationCondition.release(); activationCondition = null; } return this; }
ActivationConditionHandler bind() { if (activationCondition == null) { nexusActiveCondition = conditions.nexus().active(); try { activationCondition = reference.capability().activationCondition(); if (activationCondition instanceof CapabilityContextAware) { ((CapabilityContextAware) activationCondition).setContext(reference.context()); } } catch (Exception e) { activationCondition = new UnsatisfiedCondition("Failed to determine activation condition"); getLogger() .error( "Could not get activation condition from capability {} ({}). Considering it as non activatable", new Object[] {reference.capability(), reference.context().id(), e}); } if (activationCondition == null) { activationCondition = new SatisfiedCondition("Capability has no activation condition"); } nexusActiveCondition.bind(); activationCondition.bind(); eventBus.register(this); } return this; }
@Override public String explainUnsatisfied() { return condition.explainSatisfied(); }
boolean isConditionSatisfied() { return activationCondition != null && activationCondition.isSatisfied(); }
public String explainWhyNotSatisfied() { return isConditionSatisfied() ? null : activationCondition.explainUnsatisfied(); }