jdk/src/share/classes/java/util/ServiceLoader.java
changeset 7803 56bc97d69d93
parent 5506 202f599c92aa
child 9035 1255eb81cc2f
equal deleted inserted replaced
7802:74f2ee2b62ba 7803:56bc97d69d93
   189 
   189 
   190     // The class loader used to locate, load, and instantiate providers
   190     // The class loader used to locate, load, and instantiate providers
   191     private ClassLoader loader;
   191     private ClassLoader loader;
   192 
   192 
   193     // Cached providers, in instantiation order
   193     // Cached providers, in instantiation order
   194     private LinkedHashMap<String,S> providers = new LinkedHashMap<String,S>();
   194     private LinkedHashMap<String,S> providers = new LinkedHashMap<>();
   195 
   195 
   196     // The current lazy-lookup iterator
   196     // The current lazy-lookup iterator
   197     private LazyIterator lookupIterator;
   197     private LazyIterator lookupIterator;
   198 
   198 
   199     /**
   199     /**
   289     private Iterator<String> parse(Class service, URL u)
   289     private Iterator<String> parse(Class service, URL u)
   290         throws ServiceConfigurationError
   290         throws ServiceConfigurationError
   291     {
   291     {
   292         InputStream in = null;
   292         InputStream in = null;
   293         BufferedReader r = null;
   293         BufferedReader r = null;
   294         ArrayList<String> names = new ArrayList<String>();
   294         ArrayList<String> names = new ArrayList<>();
   295         try {
   295         try {
   296             in = u.openStream();
   296             in = u.openStream();
   297             r = new BufferedReader(new InputStreamReader(in, "utf-8"));
   297             r = new BufferedReader(new InputStreamReader(in, "utf-8"));
   298             int lc = 1;
   298             int lc = 1;
   299             while ((lc = parseLine(service, u, r, lc, names)) >= 0);
   299             while ((lc = parseLine(service, u, r, lc, names)) >= 0);
   461      * @return A new service loader
   461      * @return A new service loader
   462      */
   462      */
   463     public static <S> ServiceLoader<S> load(Class<S> service,
   463     public static <S> ServiceLoader<S> load(Class<S> service,
   464                                             ClassLoader loader)
   464                                             ClassLoader loader)
   465     {
   465     {
   466         return new ServiceLoader<S>(service, loader);
   466         return new ServiceLoader<>(service, loader);
   467     }
   467     }
   468 
   468 
   469     /**
   469     /**
   470      * Creates a new service loader for the given service type, using the
   470      * Creates a new service loader for the given service type, using the
   471      * current thread's {@linkplain java.lang.Thread#getContextClassLoader
   471      * current thread's {@linkplain java.lang.Thread#getContextClassLoader