当前位置: 首页>>代码示例>>Java>>正文


Java VirtualFile类代码示例

本文整理汇总了Java中play.vfs.VirtualFile的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile类的具体用法?Java VirtualFile怎么用?Java VirtualFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VirtualFile类属于play.vfs包,在下文中一共展示了VirtualFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepare

import play.vfs.VirtualFile; //导入依赖的package包/类
@BeforeClass
public static void prepare() {
    try {
        Field f = Act.class.getDeclaredField("pluginManager");
        f.setAccessible(true);
        f.set(null, new GenericPluginManager());
    } catch (Exception e) {
        throw E.unexpected(e);
    }
    app = App.testInstance();
    config = app.config();
    RequestHandlerResolver controllerLookup = new MockRequestHandlerResolver();
    router = new Router(controllerLookup, app);
    InputStream is = TestBase.class.getResourceAsStream("/routes");
    String fc = IO.readContentAsString(is);
    builder = new RouteTableRouterBuilder(fc.split("[\r\n]+"));
    builder.build(router);
    Play.pluginCollection = new PluginCollection();
    URL url = TestBase.class.getResource("/routes");
    Play.applicationPath = new File(FastStr.of(url.getPath()).beforeLast('/').toString());
    Play.routes = VirtualFile.fromRelativePath("routes");
    play.mvc.Router.load("");
}
 
开发者ID:actframework,项目名称:actframework,代码行数:24,代码来源:RouterBenchmark.java

示例2: getAllTemplate

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:21,代码来源:TemplateLoader.java

示例3: scan

import play.vfs.VirtualFile; //导入依赖的package包/类
private static void scan(List<Template> templates, VirtualFile current) {
    if (!current.isDirectory() && !current.getName().startsWith(".") && !current.getName().endsWith(".scala.html")) {
        long start = System.currentTimeMillis();
        Template template = load(current);
        if (template != null) {
            try {
                template.compile();
                if (Logger.isTraceEnabled()) {
                    Logger.trace("%sms to load %s", System.currentTimeMillis() - start, current.getName());
                }
            } catch (TemplateCompilationException e) {
                Logger.error("Template %s does not compile at line %d", e.getTemplate().name, e.getLineNumber());
                throw e;
            }
            templates.add(template);
        }
    } else if (current.isDirectory() && !current.getName().startsWith(".")) {
        for (VirtualFile virtualFile : current.list()) {
            scan(templates, virtualFile);
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:23,代码来源:TemplateLoader.java

示例4: detectChanges

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * In PROD mode and if the routes are already loaded, this does nothing.
 * <p/>
 * <p>In DEV mode, this checks each routes file's "last modified" time to see if the routes need updated.
 *
 * @param prefix The prefix that the path of all routes in this route file start with. This prefix should not end with a '/' character.
 */
public static void detectChanges(String prefix) {
    if (Play.mode == Mode.PROD && lastLoading > 0) {
        return;
    }
    if (Play.routes.lastModified() > lastLoading) {
        load(prefix);
    } else {
        for (VirtualFile file : Play.modulesRoutes.values()) {
            if (file.lastModified() > lastLoading) {
                load(prefix);
                return;
            }
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:23,代码来源:Router.java

示例5: redirectToStatic

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * Send a 302 redirect response.
 * @param file The Location to redirect
 */
protected static void redirectToStatic(String file) {
    try {
        VirtualFile vf = Play.getVirtualFile(file);
        if (vf == null || !vf.exists()) {
            throw new NoRouteFoundException(file);
        }
        throw new RedirectToStatic(Router.reverse(Play.getVirtualFile(file)));
    } catch (NoRouteFoundException e) {
        StackTraceElement element = PlayException.getInterestingStrackTraceElement(e);
        if (element != null) {
            throw new NoRouteFoundException(file, Play.classes.getApplicationClass(element.getClassName()), element.getLineNumber());
        } else {
            throw e;
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:21,代码来源:Controller.java

示例6: addModule

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * Add a play application (as plugin)
 *
 * @param path The application path
 */
public static void addModule(String name, File path) {
    VirtualFile root = VirtualFile.open(path);
    modules.put(name, root);
    if (root.child("app").exists()) {
        javaPath.add(root.child("app"));
    }
    if (root.child("app/views").exists()) {
        templatesPath.add(root.child("app/views"));
    }
    if (root.child("conf/routes").exists()) {
        modulesRoutes.put(name, root.child("conf/routes"));
    }
    roots.add(root);
    if (!name.startsWith("_")) {
        Logger.info("Module %s is available (%s)", name, path.getAbsolutePath());
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:23,代码来源:Play.java

示例7: getTransformedFilesRelativeURLs

import play.vfs.VirtualFile; //导入依赖的package包/类
ArrayList<String> getTransformedFilesRelativeURLs() throws IOException {
	ArrayList<JSSourceDatabaseEntry> all_entries = getDatabase().getSortedEntries();
	ArrayList<String> results = new ArrayList<String>(all_entries.size() + 1);
	String url;
	
	if (reduced_declaration_file.exists()) {
		try {
			url = Router.reverse(VirtualFile.open(reduced_declaration_file));
			results.add(url);
		} catch (NoRouteFoundException e) {
			throw new IOException("Play can't resolve route for " + reduced_declaration_file.getPath());
		}
	}
	
	File transformed_file;
	for (int pos = 0; pos < all_entries.size(); pos++) {
		transformed_file = all_entries.get(pos).computeTransformedFilepath(module_path, transformed_directory);
		if (transformed_file.exists() == false) {
			Loggers.Play_JSSource.warn("A transformed file don't exists: " + transformed_file);
			continue;
		}
		url = Router.reverse(VirtualFile.open(transformed_file));
		results.add(url);
	}
	return results;
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:27,代码来源:JSSourceModule.java

示例8: addNews

import play.vfs.VirtualFile; //导入依赖的package包/类
public void addNews(@Required String path, @Required String title, @Required Date date, String tags) {
  checkAuthenticity();
  if (validation.hasErrors()) forbidden(validation.errorsMap().toString());
  WebPage.News parent = WebPage.forPath(path);
  if (parent.isStory()) parent = (WebPage.News) parent.parent();
  if (parent.isMonth()) parent = (WebPage.News) parent.parent();
  if (parent.isYear()) parent = (WebPage.News) parent.parent();

  String pathSuffix = new SimpleDateFormat("yyyy/MM/dd").format(date);
  File dir = new File(parent.dir.getRealFile(), pathSuffix);
  while (dir.exists()) dir = new File(dir.getPath() + "-1");
  dir.mkdirs();

  VirtualFile vdir = VirtualFile.open(dir);
  vdir.child("metadata.properties").write("title: " + title + "\ntags: " + defaultString(tags) + "\n");
  vdir.child("content.html").write(Messages.get("web.admin.defaultContent"));

  WebPage.News page = WebPage.forPath(vdir);
  redirect(page.path);
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:21,代码来源:WebAdmin.java

示例9: WebPage

import play.vfs.VirtualFile; //导入依赖的package包/类
WebPage(VirtualFile dir, String path) {
  this.dir = dir;
  this.path = path.endsWith("/") ? path : path + "/";
  level = countMatches(this.path, "/") - 1;

  metadata = loadMetadata(dir);
  title = metadata.getProperty("title");
  if (isEmpty(title)) title = generateTitle();
  template = metadata.getProperty("template", "custom");

  try {
    order = parseInt(metadata.getProperty("order", "99"));
  }
  catch (NumberFormatException e) {
    order = 99;
  }
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:18,代码来源:WebPage.java

示例10: mailLinksAreProtectedFromSpamBots

import play.vfs.VirtualFile; //导入依赖的package包/类
@Test
public void mailLinksAreProtectedFromSpamBots() {
  VirtualFile dir = mock(VirtualFile.class, RETURNS_DEEP_STUBS);
  WebPage page = new WebPage(dir, "/page");

  assertEquals("<a class=\"email\" href=\"cryptmail:736f6d65626f6479406578616d706c652e636f6d\">736f6d65626f6479406578616d706c652e636f6d</a>",
      page.processContent("<a href=\"mailto:[email protected]\">[email protected]</a>"));

  assertEquals("<a\nclass=\"email\" href=\"cryptmail:736f6d65626f6479406578616d706c652e636f6d\">736f6d65626f6479406578616d706c652e636f6d</a>",
      page.processContent("<a\nhref=\"mailto:[email protected]\">[email protected]</a>"));

  assertEquals("<a class=\"email\" href=\"cryptmail:736f6d65626f6479406578616d706c652e636f6d\">Ivan Examploff</a>",
      page.processContent("<a href=\"mailto:[email protected]\">Ivan Examploff</a>"));

  assertEquals("<a class=\"email\" href=\"cryptmail:736f6d65626f6479406578616d706c652e636f6d\">Ivan\nExamploff</a>",
      page.processContent("<a href=\"mailto:[email protected]\">Ivan\nExamploff</a>"));
}
 
开发者ID:codeborne,项目名称:play-web,代码行数:18,代码来源:WebPageTest.java

示例11: onLoad

import play.vfs.VirtualFile; //导入依赖的package包/类
@Override
public void onLoad() {
    VirtualFile appRoot = VirtualFile.open(Play.applicationPath);
    Play.javaPath.add(appRoot.child("test"));
    for (VirtualFile module : Play.modules.values()) {
        File modulePath = module.getRealFile();
        if (!modulePath.getAbsolutePath().startsWith(Play.frameworkPath.getAbsolutePath()) && !Play.javaPath.contains(module.child("test"))) {
            Play.javaPath.add(module.child("test"));
        }
    }
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:12,代码来源:TestRunnerPlugin.java

示例12: CompilationException

import play.vfs.VirtualFile; //导入依赖的package包/类
public CompilationException(VirtualFile source, String problem, int line, int start, int end) {
    super(problem);
    this.problem = problem;
    this.line = line;
    this.source = source;
    this.start = start;
    this.end = end;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:9,代码来源:CompilationException.java

示例13: parse

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * Parse a route file.
 * If an action starts with <i>"plugin:name"</i>, replace that route by the ones declared
 * in the plugin route file denoted by that <i>name</i>, if found.
 *
 * @param routeFile
 * @param prefix    The prefix that the path of all routes in this route file start with. This prefix should not
 *                  end with a '/' character.
 */
static void parse(VirtualFile routeFile, String prefix) {
    String fileAbsolutePath = routeFile.getRealFile().getAbsolutePath();
    String content = routeFile.contentAsString();
    if (content.indexOf("${") > -1 || content.indexOf("#{") > -1 || content.indexOf("%{") > -1) {
        // Mutable map needs to be passed in.
        content = TemplateLoader.load(routeFile).render(new HashMap<String, Object>(16));
    }
    parse(content, prefix, fileAbsolutePath);
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:19,代码来源:Router.java

示例14: getResourceAsStream

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:14,代码来源:ApplicationClassloader.java

示例15: getResource

import play.vfs.VirtualFile; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:18,代码来源:ApplicationClassloader.java


注:本文中的play.vfs.VirtualFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。