use of io.vertx.core.impl.FileResolver in project vert.x by eclipse.
the class FileResolverTestBase method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
resolver = new FileResolver(vertx);
}
use of io.vertx.core.impl.FileResolver in project vert.x by eclipse.
the class FileResolverTestBase method testDeleteCacheDir.
@Test
public void testDeleteCacheDir() throws Exception {
Vertx vertx2 = vertx();
FileResolver resolver2 = new FileResolver(vertx2);
File file = resolver2.resolveFile(webRoot + "/somefile.html");
assertTrue(file.exists());
File cacheDir = file.getParentFile().getParentFile();
assertTrue(cacheDir.exists());
resolver2.close(onSuccess(res -> {
assertFalse(cacheDir.exists());
vertx2.close(res2 -> {
testComplete();
});
}));
await();
}
use of io.vertx.core.impl.FileResolver in project VX-API-Gateway by EliMirren.
the class ClientVerticle method getTemplateRoot.
/**
* 获得模板的路径
*
* @return
*/
public String getTemplateRoot() {
if (PathUtil.isJarEnv()) {
FileResolver resolver = new FileResolver(vertx);
File file = resolver.resolveFile(new File(PathUtil.getPathString("templates")).getPath());
return "/" + file.getPath();
} else {
return "target/classes/templates";
}
}
use of io.vertx.core.impl.FileResolver in project vert.x by eclipse.
the class FileResolverTestBase method testResolveFileFromClasspathDisableCaching.
@Test
public void testResolveFileFromClasspathDisableCaching() throws Exception {
System.setProperty(FileResolver.DISABLE_FILE_CACHING_PROP_NAME, "true");
resolver = new FileResolver(vertx);
for (int i = 0; i < 2; i++) {
File file = resolver.resolveFile("afile.html");
assertTrue(file.exists());
assertTrue(file.getPath().startsWith(".vertx" + File.separator + "file-cache-"));
assertFalse(file.isDirectory());
assertEquals("<html><body>afile</body></html>", readFile(file));
}
}
use of io.vertx.core.impl.FileResolver in project vertx-swagger by bobxwang.
the class Application method demo.
/**
* a demo method about how to using vertx
*
* @param applicationContext
*/
private void demo(ApplicationContext applicationContext) {
final Vertx vertx = applicationContext.getBean(Vertx.class);
vertx.setPeriodic(1000, id -> {
// This handler will get called every second
System.out.println("timer fired!" + new Date().toString());
});
vertx.setTimer(1000, id -> {
// this handler will called after one second, just once
System.out.println("And one second later this is printed");
});
// 拦截所有消息
vertx.eventBus().addInterceptor(event -> {
Message message = event.message();
logger.info(message);
event.next();
});
FileResolver fileResolver = new FileResolver(vertx);
File file = fileResolver.resolveFile("webjars/bycdao-ui/cdao/DUI.js");
if (file != null) {
System.out.println(file.getAbsoluteFile());
} else {
System.out.println("null");
}
}
Aggregations