private void findUsesComponentAnnotations ( Component component , String typeName ) { try { Class type = getTypeRepository ( ) . loadClass ( typeName ) ; for ( Field field : type . getDeclaredFields ( ) ) { UsesComponent annotation = field . getAnnotation ( UsesComponent . class ) ; if ( annotation != null ) { String name = field . getType ( ) . getCanonicalName ( ) ; String description = field . getAnnotation ( UsesComponent . class ) . description ( ) ; String technology = annotation . technology ( ) ; Component destination = componentFinder . getContainer ( ) . getComponentOfType ( name ) ; if ( destination != null ) { for ( Relationship relationship : component . getRelationships ( ) ) { if ( relationship . getDestination ( ) == destination && StringUtils . isNullOrEmpty ( relationship . getDescription ( ) ) ) { // only change the details of relationships that have no description component . getModel ( ) . modifyRelationship ( relationship , description , technology ) ; } } } else { log . warn ( "A component of type \"" + name + "\" could not be found." ) ; } } } } catch ( ClassNotFoundException e ) { log . warn ( "Could not load type " + typeName ) ; } }
This will add a description to existing component dependencies where they have been annotated