Java Code Examples for play.vfs.VirtualFile#child()

The following examples show how to use play.vfs.VirtualFile#child() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TemplateLoader.java    From restcommander with Apache License 2.0 6 votes vote down vote up
/**
 * List all found templates
 * @return A list of executable templates
 */
public static List<Template> getAllTemplate() {
    List<Template> res = new ArrayList<Template>();
    for (VirtualFile virtualFile : Play.templatesPath) {
        scan(res, virtualFile);
    }
    for (VirtualFile root : Play.roots) {
        VirtualFile vf = root.child("conf/routes");
        if (vf != null && vf.exists()) {
            Template template = load(vf);
            if (template != null) {
                template.compile();
            }
        }
    }
    return res;
}
 
Example 2
Source File: ApplicationClassloader.java    From restcommander with Apache License 2.0 5 votes vote down vote up
/**
 * You know ...
 */
@Override
public InputStream getResourceAsStream(String name) {
    for (VirtualFile vf : Play.javaPath) {
        VirtualFile res = vf.child(name);
        if (res != null && res.exists()) {
            return res.inputstream();
        }
    }
    return super.getResourceAsStream(name);
}
 
Example 3
Source File: ApplicationClassloader.java    From restcommander with Apache License 2.0 5 votes vote down vote up
/**
 * You know ...
 */
@Override
public URL getResource(String name) {
    for (VirtualFile vf : Play.javaPath) {
        VirtualFile res = vf.child(name);
        if (res != null && res.exists()) {
            try {
                return res.getRealFile().toURI().toURL();
            } catch (MalformedURLException ex) {
                throw new UnexpectedException(ex);
            }
        }
    }
    return super.getResource(name);
}
 
Example 4
Source File: ApplicationClassloader.java    From restcommander with Apache License 2.0 5 votes vote down vote up
/**
 * You know ...
 */
@Override
public Enumeration<URL> getResources(String name) throws IOException {
    List<URL> urls = new ArrayList<URL>();
    for (VirtualFile vf : Play.javaPath) {
        VirtualFile res = vf.child(name);
        if (res != null && res.exists()) {
            try {
                urls.add(res.getRealFile().toURI().toURL());
            } catch (MalformedURLException ex) {
                throw new UnexpectedException(ex);
            }
        }
    }
    Enumeration<URL> parent = super.getResources(name);
    while (parent.hasMoreElements()) {
        URL next = parent.nextElement();
        if (!urls.contains(next)) {
            urls.add(next);
        }
    }
    final Iterator<URL> it = urls.iterator();
    return new Enumeration<URL>() {

        public boolean hasMoreElements() {
            return it.hasNext();
        }

        public URL nextElement() {
            return it.next();
        }
    };
}
 
Example 5
Source File: ApplicationClasses.java    From restcommander with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the corresponding source file for a given class name.
 * It handles innerClass too !
 * @param name The fully qualified class name 
 * @return The virtualFile if found
 */
public static VirtualFile getJava(String name) {
    String fileName = name;
    if (fileName.contains("$")) {
        fileName = fileName.substring(0, fileName.indexOf("$"));
    }
    fileName = fileName.replace(".", "/") + ".java";
    for (VirtualFile path : Play.javaPath) {
        VirtualFile javaFile = path.child(fileName);
        if (javaFile.exists()) {
            return javaFile;
        }
    }
    return null;
}