1171 }
1172 }
1173
1174 private static XmlPropertiesProvider loadProviderAsService(ClassLoader cl) {
1175 Iterator<XmlPropertiesProvider> iterator =
1176 ServiceLoader.load(XmlPropertiesProvider.class, cl).iterator();
1177 return iterator.hasNext() ? iterator.next() : null;
1178 }
1179
1180 private static XmlPropertiesProvider loadProvider() {
1181 return AccessController.doPrivileged(
1182 new PrivilegedAction<XmlPropertiesProvider>() {
1183 public XmlPropertiesProvider run() {
1184 ClassLoader cl = ClassLoader.getSystemClassLoader();
1185 XmlPropertiesProvider provider = loadProviderFromProperty(cl);
1186 if (provider != null)
1187 return provider;
1188 provider = loadProviderAsService(cl);
1189 if (provider != null)
1190 return provider;
1191 throw new InternalError("No fallback");
1192 }});
1193 }
1194
1195 private static final XmlPropertiesProvider PROVIDER = loadProvider();
1196
1197 static void load(Properties props, InputStream in)
1198 throws IOException, InvalidPropertiesFormatException
1199 {
1200 PROVIDER.load(props, in);
1201 }
1202
1203 static void save(Properties props, OutputStream os, String comment,
1204 String encoding)
1205 throws IOException
1206 {
1207 PROVIDER.store(props, os, comment, encoding);
1208 }
1209 }
1210 }
|
1171 }
1172 }
1173
1174 private static XmlPropertiesProvider loadProviderAsService(ClassLoader cl) {
1175 Iterator<XmlPropertiesProvider> iterator =
1176 ServiceLoader.load(XmlPropertiesProvider.class, cl).iterator();
1177 return iterator.hasNext() ? iterator.next() : null;
1178 }
1179
1180 private static XmlPropertiesProvider loadProvider() {
1181 return AccessController.doPrivileged(
1182 new PrivilegedAction<XmlPropertiesProvider>() {
1183 public XmlPropertiesProvider run() {
1184 ClassLoader cl = ClassLoader.getSystemClassLoader();
1185 XmlPropertiesProvider provider = loadProviderFromProperty(cl);
1186 if (provider != null)
1187 return provider;
1188 provider = loadProviderAsService(cl);
1189 if (provider != null)
1190 return provider;
1191 return new jdk.internal.util.xml.BasicXmlPropertiesProvider();
1192 }});
1193 }
1194
1195 private static final XmlPropertiesProvider PROVIDER = loadProvider();
1196
1197 static void load(Properties props, InputStream in)
1198 throws IOException, InvalidPropertiesFormatException
1199 {
1200 PROVIDER.load(props, in);
1201 }
1202
1203 static void save(Properties props, OutputStream os, String comment,
1204 String encoding)
1205 throws IOException
1206 {
1207 PROVIDER.store(props, os, comment, encoding);
1208 }
1209 }
1210 }
|