Пример #1
0
 static {
   ServiceLoader<ZoneRulesProvider> sl =
       ServiceLoader.load(ZoneRulesProvider.class, ClassLoader.getSystemClassLoader());
   List<ZoneRulesProvider> loaded = new ArrayList<>();
   Iterator<ZoneRulesProvider> it = sl.iterator();
   while (it.hasNext()) {
     ZoneRulesProvider provider;
     try {
       provider = it.next();
     } catch (ServiceConfigurationError ex) {
       if (ex.getCause() instanceof SecurityException) {
         continue; // ignore the security exception, try the next provider
       }
       throw ex;
     }
     registerProvider0(provider);
   }
   // CopyOnWriteList could be slow if lots of providers and each added individually
   PROVIDERS.addAll(loaded);
 }
Пример #2
0
 /**
  * Registers a zone rules provider.
  *
  * <p>This adds a new provider to those currently available. A provider supplies rules for one or
  * more zone IDs. A provider cannot be registered if it supplies a zone ID that has already been
  * registered. See the notes on time-zone IDs in {@link ZoneId}, especially the section on using
  * the concept of a "group" to make IDs unique.
  *
  * <p>To ensure the integrity of time-zones already created, there is no way to deregister
  * providers.
  *
  * @param provider the provider to register, not null
  * @throws ZoneRulesException if a region is already registered
  */
 public static void registerProvider(ZoneRulesProvider provider) {
   Objects.requireNonNull(provider, "provider");
   registerProvider0(provider);
   PROVIDERS.add(provider);
 }