MCPcopy Create free account
hub / github.com/M66B/FairEmail / loadAllResources

Method loadAllResources

app/src/main/java/javax/mail/Session.java:1195–1252  ·  view source on GitHub ↗

Load all of the named resource.

(String name, Class<?> cl,
	    StreamLoader loader)

Source from the content-addressed store, hash-verified

1193 * Load all of the named resource.
1194 */
1195 private void loadAllResources(String name, Class<?> cl,
1196 StreamLoader loader) {
1197 boolean anyLoaded = false;
1198 try {
1199 URL[] urls;
1200 ClassLoader cld = null;
1201 // First try the "application's" class loader.
1202 cld = getContextClassLoader();
1203 if (cld == null)
1204 cld = cl.getClassLoader();
1205 if (cld != null)
1206 urls = getResources(cld, name);
1207 else
1208 urls = getSystemResources(name);
1209 if (urls != null) {
1210 for (int i = 0; i < urls.length; i++) {
1211 URL url = urls[i];
1212 InputStream clis = null;
1213 logger.log(Level.CONFIG, "URL {0}", url);
1214 try {
1215 clis = openStream(url);
1216 if (clis != null) {
1217 loader.load(clis);
1218 anyLoaded = true;
1219 logger.log(Level.CONFIG,
1220 "successfully loaded resource: {0}", url);
1221 } else {
1222 logger.log(Level.CONFIG,
1223 "not loading resource: {0}", url);
1224 }
1225 } catch (FileNotFoundException fex) {
1226 // ignore it
1227 } catch (IOException ioex) {
1228 logger.log(Level.CONFIG, "Exception loading resource",
1229 ioex);
1230 } catch (SecurityException sex) {
1231 logger.log(Level.CONFIG, "Exception loading resource",
1232 sex);
1233 } finally {
1234 try {
1235 if (clis != null)
1236 clis.close();
1237 } catch (IOException cex) { }
1238 }
1239 }
1240 }
1241 } catch (Exception ex) {
1242 logger.log(Level.CONFIG, "Exception loading resource", ex);
1243 }
1244
1245 // if failed to load anything, fall back to old technique, just in case
1246 if (!anyLoaded) {
1247 /*
1248 logger.config("!anyLoaded");
1249 */
1250 loadResource("/" + name, cl, loader, false);
1251 }
1252 }

Callers 2

loadProvidersMethod · 0.95
loadAddressMapMethod · 0.95

Calls 8

getContextClassLoaderMethod · 0.95
getResourcesMethod · 0.95
getSystemResourcesMethod · 0.95
openStreamMethod · 0.95
loadResourceMethod · 0.95
loadMethod · 0.65
logMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected