Class ServicesInspector<S>

  • Direct Known Subclasses:
    ServiceDescriptorsInspector

    public class ServicesInspector<S>
    extends java.lang.Object
    Inspects classpath for service implementation classes. For instance finds JavaSound AudioFileReader implementations. Note: With JRE7 java.util.ServiceLoader there is an implementation with similar functionality but we need it with JRE5
    Author:
    Klaus Jaensch
    • Constructor Detail

      • ServicesInspector

        public ServicesInspector​(java.lang.Class<S> serviceClass)
        Create service inspector for interface class.
        Parameters:
        serviceClass - service class (same as parameter type S)
      • ServicesInspector

        public ServicesInspector()
    • Method Detail

      • readServiceImplementorClassnames

        protected java.util.List<java.lang.String> readServiceImplementorClassnames​(java.io.InputStream is)
                                                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getServiceDescriptors

        public java.util.List<ServiceDescriptor> getServiceDescriptors()
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getServiceDescriptors

        public java.util.List<ServiceDescriptor> getServiceDescriptors​(java.lang.Class<S> providerClass,
                                                                       java.lang.Class<? extends ServiceDescriptor> serviceDescriptorClass,
                                                                       java.lang.ClassLoader cl,
                                                                       boolean loadImplementationClass)
                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getServiceImplementorClassnames

        public java.util.List<java.lang.String> getServiceImplementorClassnames()
                                                                         throws java.io.IOException
        Returns list of class names implementing the service.
        Returns:
        list of class names implementing the service
        Throws:
        java.io.IOException
      • getServiceImplementorClassnames

        protected java.util.List<java.lang.String> getServiceImplementorClassnames​(java.lang.String providerClassname)
                                                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • getServiceImplementorClasses

        public java.util.List<java.lang.Class<? extends S>> getServiceImplementorClasses()
                                                                                  throws java.io.IOException,
                                                                                         java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • getServiceImplementorClasses

        public java.util.List<java.lang.Class<? extends S>> getServiceImplementorClasses​(boolean ignoreErrors)
                                                                                  throws java.io.IOException,
                                                                                         java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • isUnique

        public boolean isUnique()
      • setUnique

        public void setUnique​(boolean unique)
      • main

        public static void main​(java.lang.String[] args)
        Parameters:
        args -