private void registerRequirement ( RuntimeRequirementRegistration requirement ) { assert writeLock . isHeldByCurrentThread ( ) ; CapabilityId dependentId = requirement . getDependentId ( ) ; if ( ! capabilities . containsKey ( dependentId ) ) { throw ControllerLogger . MGMT_OP_LOGGER . unknownCapabilityInContext ( dependentId . getName ( ) , dependentId . getScope ( ) . getName ( ) ) ; } Map < CapabilityId , Map < String , RuntimeRequirementRegistration > > requirementMap = requirement . isRuntimeOnly ( ) ? runtimeOnlyRequirements : requirements ; Map < String , RuntimeRequirementRegistration > dependents = requirementMap . get ( dependentId ) ; if ( dependents == null ) { dependents = new HashMap <> ( ) ; requirementMap . put ( dependentId , dependents ) ; } RuntimeRequirementRegistration existing = dependents . get ( requirement . getRequiredName ( ) ) ; if ( existing == null ) { dependents . put ( requirement . getRequiredName ( ) , requirement ) ; } else { existing . addRegistrationPoint ( requirement . getOldestRegistrationPoint ( ) ) ; } modified = true ; }
This must be called with the write lock held .