mil.dod.th.ose.shell/src/mil/dod/th/ose/shell/Utilities.java
public static void printServiceImplementations(final BundleContext context, final PrintStream out, 
            final Class<?> clazz, final boolean showBundle, final boolean showProperties)
    {
        try
        {
            final List<ServiceReference<?>> services = new ArrayList<>();

            // Get all registered factories and filter based on the given clazz
            final ServiceReference<?>[] refs = context.getServiceReferences(FactoryDescriptor.class.getName(), null);
            if (refs != null)
            {
                for (ServiceReference<?> ref : refs)
                {
                    if (clazz == null || clazz.equals(ref.getProperty(FactoryDescriptor.FACTORY_TYPE_SERVICE_PROPERTY)))
                    {
                        services.add(ref);
                    }
                }
            }

            if (services.isEmpty())
            {
                out.println("None");
            }
            else
            {
                for (ServiceReference<?> service : services)
                {
                    if (showBundle)
                    {
                        out.print(service.getBundle().getSymbolicName() + ": ");
                    }

                    out.println(service.getProperty(FactoryDescriptor.PRODUCT_TYPE_SERVICE_PROPERTY));

                    if (showProperties)
                    {
                        for (String key : service.getPropertyKeys())
                        {
                            out.println("   " + key + "=" + service.getProperty(key));
                        }
                    }
                }
            }
        }
        catch (final InvalidSyntaxException e)
        {
            e.printStackTrace(out);
        }
    }
/**
     * Print out all services references for the given interface class.
     * 
     * @param context
     *            Bundle context
     * @param out
     *            Where to emit output
     * @param clazz
     *            Interface class to lookup or null for all
     * @param showBundle
     *            Whether to show which bundle registered the service
     * @param showProperties
     *            Whether to show service registration properties
     */
Print out all services references for the given interface class.


Print out all services references for the given interface class .
public static void printServiceImplementations(final BundleContext context, final PrintStream out, 
            final Class<?> clazz, final boolean showBundle, final boolean showProperties)
    {
        try
        {
            final List<ServiceReference<?>> services = new ArrayList<>();
            final ServiceReference<?>[] refs = context.getServiceReferences(FactoryDescriptor.class.getName(), null);
            if (refs != null)
            {
                for (ServiceReference<?> ref : refs)
                {
                    if (clazz == null || clazz.equals(ref.getProperty(FactoryDescriptor.FACTORY_TYPE_SERVICE_PROPERTY)))
                    {
                        services.add(ref);
                    }
                }
            }
            if (services.isEmpty())
            {
                out.println("None");
            }
            else
            {
                for (ServiceReference<?> service : services)
                {
                    if (showBundle)
                    {
                        out.print(service.getBundle().getSymbolicName() + ": ");
                    }
                    out.println(service.getProperty(FactoryDescriptor.PRODUCT_TYPE_SERVICE_PROPERTY));
                    if (showProperties)
                    {
                        for (String key : service.getPropertyKeys())
                        {
                            out.println("   " + key + "=" + service.getProperty(key));
                        }
                    }
                }
            }
        }
        catch (final InvalidSyntaxException e)
        {
            e.printStackTrace(out);
        }
    }
public static void printServiceImplementations ( final BundleContext context , final PrintStream out , final Class < ? > clazz , final boolean showBundle , final boolean showProperties ) { try { final List < ServiceReference < ? > > services = new ArrayList < > ( ) ; final ServiceReference < ? > [ ] refs = context . getServiceReferences ( FactoryDescriptor . class . getName ( ) , null ) ; if ( refs != null ) { for ( ServiceReference < ? > ref : refs ) { if ( clazz == null || clazz . equals ( ref . getProperty ( FactoryDescriptor . FACTORY_TYPE_SERVICE_PROPERTY ) ) ) { services . add ( ref ) ; } } } if ( services . isEmpty ( ) ) { out . println ( "None" ) ; } else { for ( ServiceReference < ? > service : services ) { if ( showBundle ) { out . print ( service . getBundle ( ) . getSymbolicName ( ) + ": " ) ; } out . println ( service . getProperty ( FactoryDescriptor . PRODUCT_TYPE_SERVICE_PROPERTY ) ) ; if ( showProperties ) { for ( String key : service . getPropertyKeys ( ) ) { out . println ( "   " + key + "=" + service . getProperty ( key ) ) ; } } } } } catch ( final InvalidSyntaxException e ) { e . printStackTrace ( out ) ; } }
Print out all services references for the given interface class.
Print out all services references for the given interface class .
// Get all registered factories and filter based on the given clazz