Get or load an object by name. The name is case-insensitive. @param name the name of the object. @return the corresponding loaded object, or null if not loaded.
(String name)
| 289 | * @return the corresponding loaded object, or null if not loaded. |
| 290 | */ |
| 291 | public T getObject(String name) |
| 292 | { |
| 293 | if (errorNames.contains(name)) |
| 294 | return null; |
| 295 | if (nameMap.containsKey(name)) |
| 296 | return nameMap.get(name); |
| 297 | |
| 298 | T object = null; |
| 299 | |
| 300 | try |
| 301 | { |
| 302 | synchronized (uniqueKey(name)) |
| 303 | { |
| 304 | // Early outs for waiting threads. |
| 305 | if (errorNames.contains(name)) |
| 306 | return null; |
| 307 | if (nameMap.containsKey(name)) |
| 308 | return nameMap.get(name); |
| 309 | |
| 310 | for (int i = 0; i < loaderFunctions.length; i++) |
| 311 | { |
| 312 | try |
| 313 | { |
| 314 | if ((object = loaderFunctions[i].load(name)) != null) |
| 315 | break; |
| 316 | } |
| 317 | catch (Exception e) |
| 318 | { |
| 319 | if (errorListener != null) |
| 320 | errorListener.onLoaderError(loaderFunctions[i], e); |
| 321 | continue; |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | finally |
| 327 | { |
| 328 | releaseKey(name); |
| 329 | } |
| 330 | |
| 331 | if (object == null) |
| 332 | { |
| 333 | synchronized (errorNames) |
| 334 | { |
| 335 | errorNames.add(name); |
| 336 | } |
| 337 | } |
| 338 | else |
| 339 | { |
| 340 | setObject(name, object); |
| 341 | } |
| 342 | |
| 343 | return object; |
| 344 | } |
| 345 | |
| 346 | /** |
| 347 | * Get or load an object by name asynchronously. |
no test coverage detected