@Override public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException { Matcher matcher = Pattern.compile("(\\d+)(/.*)?").matcher(path); if (!matcher.matches()) { return super.handleConnectorRequest(request, response, path); } DownloadStream stream; VaadinSession session = getSession(); session.lock(); try { List<URLReference> sources = getState().sources; int sourceIndex = Integer.parseInt(matcher.group(1)); if (sourceIndex < 0 || sourceIndex >= sources.size()) { getLogger().log(Level.WARNING, "Requested source index {0} is out of bounds", sourceIndex); return false; } URLReference reference = sources.get(sourceIndex); ConnectorResource resource = (ConnectorResource) ResourceReference.getResource(reference); stream = resource.getStream(); } finally { session.unlock(); } stream.writeResponse(request, response); return true; }