@Override public InputStream open() { try { return new FileInputStream(current); } catch (final FileNotFoundException e) { throw new ResourceFinderException(e); } }
@Override public InputStream open() { try { return new FileInputStream(current); } catch (final FileNotFoundException e) { throw new ResourceFinderException(e); } }
@Override public InputStream open() { try { return new FileInputStream(current); } catch (final FileNotFoundException e) { throw new ResourceFinderException(e); } }
@Override public InputStream open() { try { return new FileInputStream(current); } catch (final FileNotFoundException e) { throw new ResourceFinderException(e); } }
private Method bindMethod0(final Object object, final String name) { final Class<?> clazz = object.getClass(); try { return clazz.getMethod(name); } catch (final NoSuchMethodException e) { throw new ResourceFinderException("VFS object did not have a valid signature"); } }
@Override public InputStream open() { if (!accessed) { try { accessed = true; return uri.toURL().openStream(); } catch (final IOException e) { throw new ResourceFinderException(e); } } return null; }
private Method bindMethod0(final Object object, final String name) { final Class<?> clazz = object.getClass(); try { return clazz.getMethod(name); } catch (final NoSuchMethodException e) { throw new ResourceFinderException("VFS object did not have a valid signature"); } }
@Override public InputStream open() { if (!accessed) { try { accessed = true; return uri.toURL().openStream(); } catch (final IOException e) { throw new ResourceFinderException(e); } } return null; }
private <T> T invoke(final Object instance, final Method method, final Class<T> type) { try { return type.cast(method.invoke(instance)); } catch (final Exception e) { throw new ResourceFinderException("VFS object could not be invoked upon"); } }
private <T> T invoke(final Object instance, final Method method, final Class<T> type) { try { return type.cast(method.invoke(instance)); } catch (final Exception e) { throw new ResourceFinderException("VFS object could not be invoked upon"); } }
private Object bindDirectory(final URI uri) { Object directory = null; try { directory = uri.toURL().getContent(); } catch (final IOException e) { // Eat } if (directory == null || !directory.getClass().getSimpleName().equals("VirtualFile")) { throw new ResourceFinderException("VFS URL did not map to a valid VFS object"); } return directory; }
private Object bindDirectory(final URI uri) { Object directory = null; try { directory = uri.toURL().getContent(); } catch (final IOException e) { // Eat } if (directory == null || !directory.getClass().getSimpleName().equals("VirtualFile")) { throw new ResourceFinderException("VFS URL did not map to a valid VFS object"); } return directory; }
@Override public JarZipSchemeScanner create(final URI uri, final boolean recursive) { final String ssp = uri.getRawSchemeSpecificPart(); final String jarUrlString = ssp.substring(0, ssp.lastIndexOf('!')); final String parent = ssp.substring(ssp.lastIndexOf('!') + 2); try { return new JarZipSchemeScanner(getInputStream(jarUrlString), parent, recursive); } catch (final IOException e) { throw new ResourceFinderException(e); } }
@Override public JarZipSchemeScanner create(final URI uri, final boolean recursive) { final String ssp = uri.getRawSchemeSpecificPart(); final String jarUrlString = ssp.substring(0, ssp.lastIndexOf('!')); final String parent = ssp.substring(ssp.lastIndexOf('!') + 2); try { return new JarZipSchemeScanner(getInputStream(jarUrlString), parent, recursive); } catch (final IOException e) { throw new ResourceFinderException(e); } }
private void addResourceFinder(final URI u) { final UriSchemeResourceFinderFactory finderFactory = finderFactories.get(u.getScheme().toLowerCase()); if (finderFactory != null) { compositeResourceFinder.push(finderFactory.create(u, recursive)); } else { throw new ResourceFinderException("The URI scheme " + u.getScheme() + " of the URI " + u + " is not supported. Package scanning deployment is not" + " supported for such URIs." + "\nTry using a different deployment mechanism such as" + " explicitly declaring root resource and provider classes" + " using an extension of javax.ws.rs.core.Application"); } }
private void addResourceFinder(final URI u) { final UriSchemeResourceFinderFactory finderFactory = finderFactories.get(u.getScheme().toLowerCase()); if (finderFactory != null) { compositeResourceFinder.push(finderFactory.create(u, recursive)); } else { throw new ResourceFinderException("The URI scheme " + u.getScheme() + " of the URI " + u + " is not supported. Package scanning deployment is not" + " supported for such URIs." + "\nTry using a different deployment mechanism such as" + " explicitly declaring root resource and provider classes" + " using an extension of javax.ws.rs.core.Application"); } }
private Iterator<?> getChildren(final Object directory, final boolean recursive) { final Method getChildren = bindMethod(directory, recursive ? "getChildrenRecursively" : "getChildren"); final List<?> list = invoke(directory, getChildren, List.class); if (list == null) { throw new ResourceFinderException("VFS object returned null when accessing children"); } return list.iterator(); }
@Override public boolean hasNext() { while (next == null && !resourcePathsStack.isEmpty()) { next = resourcePathsStack.pop(); if (next.endsWith("/")) { processPaths(next); next = null; } else if (next.endsWith(".jar")) { try { compositeResourceFinder.push(new JarFileScanner(sc.getResourceAsStream(next), "", true)); } catch (final IOException ioe) { throw new ResourceFinderException(ioe); } next = null; } } return next != null; }
private Iterator<?> getChildren(final Object directory, final boolean recursive) { final Method getChildren = bindMethod(directory, recursive ? "getChildrenRecursively" : "getChildren"); final List<?> list = invoke(directory, getChildren, List.class); if (list == null) { throw new ResourceFinderException("VFS object returned null when accessing children"); } return list.iterator(); }
private void init() { compositeResourceFinder = new CompositeResourceFinder(); for (final String p : packages) { try { final Enumeration<URL> urls = ResourcesProvider.getInstance().getResources(p.replace('.', '/'), classloader); while (urls.hasMoreElements()) { try { addResourceFinder(toURI(urls.nextElement())); } catch (final URISyntaxException e) { throw new ResourceFinderException("Error when converting a URL to a URI", e); } } } catch (final IOException e) { throw new ResourceFinderException("IO error when package scanning jar", e); } } }