Changeset 74:e5ff09208c28 in AnnotationManagerN4J for src/main/java/de/mpiwg/itgroup/annotations
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/de/mpiwg/itgroup/annotations/restlet/BaseRestlet.java
r73 r74 337 337 338 338 /** 339 * returns resource from path (in webapp) as InputStream. 339 * returns resource from path as InputStream. 340 * 341 * Tries path in webapp first, then uses classpath loader. 342 * Relative paths in webapp start in /WEB-INF/. 340 343 * 341 344 * @param sc … … 348 351 // no servlet context -> use class loader 349 352 ps = Thread.currentThread().getContextClassLoader().getResourceAsStream(path); 350 /* Request request = new Request(Method.GET, "riap://component/ping");351 Response response = getContext().getClientDispatcher().handle(request);352 Representation repr = response.getEntity(); */353 353 } else { 354 354 // try path in webapp first 355 ps = sc.getResourceAsStream(path); 355 String webPath = path; 356 if (!webPath.startsWith("/")) { 357 // relative path in webapp starts in WEB-INF 358 webPath = "WEB-INF/" + webPath; 359 } 360 ps = sc.getResourceAsStream(webPath); 356 361 if (ps == null) { 357 362 // try as file 358 File pf = new File(sc.getRealPath( path));363 File pf = new File(sc.getRealPath(webPath)); 359 364 if (pf.canRead()) { 360 365 logger.debug("trying file for: " + pf); … … 377 382 * 378 383 * If filename starts with "/" its treated as absolute else the path is 379 * appended to the base directory ofthe web-app.384 * appended to the /WEB-INF/ directory in the web-app. 380 385 * 381 386 * @param filename … … 388 393 if (!f.isAbsolute() && sc != null) { 389 394 // relative path -> use getRealPath to resolve in webapp 390 filename = sc.getRealPath( filename);395 filename = sc.getRealPath("WEB-INF/" + filename); 391 396 } 392 397 return filename;
Note: See TracChangeset
for help on using the changeset viewer.