public PropertiesReader(final ResourceStreamSource resourceStream, final String configurationResource) throws IOException { InputStream in = null; try { in = resourceStream.readResource(configurationResource); if (in == null) { throw new IOException("Unable to find resource " + configurationResource); } properties.load(in); } finally { IoUtils.closeSafely(in); } }
private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { String servletPath = stripLeadingSlash(request.getServletPath()); LOG.info("request: " + servletPath); InputStream is = Resources.getResourceAsStream(servletPath); if (is != null) { IoUtils.copy(is, response.getOutputStream()); } }
private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final String servletPath = StringUtils.stripLeadingSlash(request.getServletPath()); LOG.info("request: " + servletPath); // try to load from classpath InputStream is = Resources.getResourceAsStream(servletPath); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } // otherwise, try to load from filesystem is = getRealPath(request); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } }
public PropertiesReader( final ResourceStreamSource resourceStream, final String configurationResource) throws IOException { InputStream in = null; try { in = resourceStream.readResource(configurationResource); if (in == null) { throw new IOException("Unable to find resource " + configurationResource); } properties.load(in); } finally { IoUtils.closeSafely(in); } }
private void processRequest(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final String servletPath = StringUtils.stripLeadingSlash(request.getServletPath()); LOG.info("request: " + servletPath); // try to load from classpath InputStream is = Resources.getResourceAsStream(servletPath); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } // otherwise, try to load from filesystem is = getRealPath(request); if (is != null) { IoUtils.copy(is, response.getOutputStream()); is.close(); return; } }
throw new NakedObjectException("Failed to read password file: " + FileAuthenticationConstants.PASSWORDS_FILE + " from " + resourceStreamSource.getName()); } finally { IoUtils.closeSafely(reader);