private void invokeInitializersBasedOnPriority ( ITestContext context ) { ServiceLoader < Initializer > serviceLoader = ServiceLoader . load ( Initializer . class ) ; List < AbstractConfigInitializer > loader = new ArrayList < AbstractConfigInitializer > ( ) ; for ( Initializer l : serviceLoader ) { loader . add ( ( AbstractConfigInitializer ) l ) ; } Collections . sort ( loader ) ; for ( AbstractConfigInitializer temp : loader ) { temp . initialize ( context ) ; } }
This method facilitates initialization of all configurations from the current project as well as downstream consumers .