synchronized public void setDependency ( String objectName , String dependencyName ) throws EvaluationException { // Determine if adding this dependency will create a cycle. String nextObjectName = dependencies . get ( dependencyName ) ; while ( nextObjectName != null ) { if ( objectName . equals ( nextObjectName ) ) { throw EvaluationException . create ( MSG_CIRCULAR_OBJECT_DEPENDENCY , getCycle ( objectName , dependencyName ) ) ; } nextObjectName = dependencies . get ( nextObjectName ) ; } // If we get to here, then we reached the end of the chain without // creating a cycle. It is OK to add this to the dependencies. dependencies . put ( objectName , dependencyName ) ; // To avoid deadlock, ensure that the number of available threads is // larger than number of entries in the dependencies. compiler . ensureMinimumBuildThreadLimit ( dependencies . size ( ) + 1 ) ; }
This method will set the given dependency in the map which holds them . This method will throw an exception if the specified dependency would create a cycle in the dependency map . In this case the dependency will not be inserted .