public void listRunningServices ( ) { try { final List < String > formatedOutput = SecurityContext . executeWithSystemPermissions ( new Callable < List < String > > ( ) { @ Override public List < String > call ( ) throws Exception { List < String > tmp = new ArrayList < String > ( ) ; List < ServiceReference < Domain > > listServiceReferences = osgiUtilsService . listServiceReferences ( Domain . class ) ; for ( ServiceReference < Domain > ref : listServiceReferences ) { Domain service = bundleContext . getService ( ref ) ; tmp . add ( OutputStreamFormater . formatValues ( ref . getProperty ( org . osgi . framework . Constants . SERVICE_PID ) . toString ( ) , service . getAliveState ( ) . toString ( ) ) ) ; } return tmp ; } } ) ; for ( String s : formatedOutput ) { OutputStreamFormater . printValue ( s ) ; } } catch ( ExecutionException ex ) { ex . printStackTrace ( ) ; System . err . println ( "Could not get services" ) ; } }
prints out all available services and their alive state