private static int getPort ( Service service , Annotation ... qualifiers ) { for ( Annotation q : qualifiers ) { if ( q instanceof Port ) { Port port = ( Port ) q ; if ( port . value ( ) > 0 ) { return port . value ( ) ; } } } ServicePort servicePort = findQualifiedServicePort ( service , qualifiers ) ; if ( servicePort != null ) { return servicePort . getPort ( ) ; } return 0 ; }
Find the the qualified container port of the target service Uses java annotations first or returns the container port .