Set the appropriate context attribute for our class path. This is required only because Jasper depends on it.
()
| 442 | * Set the appropriate context attribute for our class path. This is required only because Jasper depends on it. |
| 443 | */ |
| 444 | private void setClassPath() { |
| 445 | |
| 446 | // Validate our current state information |
| 447 | if (context == null) { |
| 448 | return; |
| 449 | } |
| 450 | ServletContext servletContext = context.getServletContext(); |
| 451 | if (servletContext == null) { |
| 452 | return; |
| 453 | } |
| 454 | |
| 455 | StringBuilder classpath = new StringBuilder(); |
| 456 | |
| 457 | // Assemble the class path information from our class loader chain |
| 458 | ClassLoader loader = getClassLoader(); |
| 459 | |
| 460 | if (delegate && loader != null) { |
| 461 | // Skip the webapp loader for now as delegation is enabled |
| 462 | loader = loader.getParent(); |
| 463 | } |
| 464 | |
| 465 | while (loader != null) { |
| 466 | if (!buildClassPath(classpath, loader)) { |
| 467 | break; |
| 468 | } |
| 469 | loader = loader.getParent(); |
| 470 | } |
| 471 | |
| 472 | if (delegate) { |
| 473 | // Delegation was enabled, go back and add the webapp paths |
| 474 | loader = getClassLoader(); |
| 475 | if (loader != null) { |
| 476 | buildClassPath(classpath, loader); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | this.classpath = classpath.toString(); |
| 481 | |
| 482 | // Store the assembled class path as a servlet context attribute |
| 483 | servletContext.setAttribute(Globals.CLASS_PATH_ATTR, this.classpath); |
| 484 | } |
| 485 | |
| 486 | |
| 487 | private boolean buildClassPath(StringBuilder classpath, ClassLoader loader) { |
no test coverage detected