X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fjagi%2Ffs%2FJavaHandler.java;h=6579097e73aac163121b8a06eec7645bb58b2595;hb=e8892ea03fb37d1f1d362ad82b16a14986c5cd25;hp=111264f26582e0fa64efe0b7065a3543b26a7f8e;hpb=06577e0b601d42f7d6453d2f4b4fdf70507f4fd6;p=jagi.git diff --git a/src/jagi/fs/JavaHandler.java b/src/jagi/fs/JavaHandler.java index 111264f..6579097 100644 --- a/src/jagi/fs/JavaHandler.java +++ b/src/jagi/fs/JavaHandler.java @@ -9,7 +9,7 @@ import java.nio.file.*; public class JavaHandler implements Function, Map> { private static final Logger log = Logger.getLogger("jagi-fs"); - private final Map, Map>> handlers = new WeakHashMap<>(); + private final Map, Map>> handlers = new WeakHashMap<>(); public static class HandlerException extends RuntimeException { public final Path file; @@ -31,7 +31,7 @@ public class JavaHandler implements Function, Map, Map> makehandler(Compiler.Module mod) { Class main; try { - main = mod.code().loadClass("Main"); + main = mod.code.loadClass("Main"); } catch(ClassNotFoundException e) { throw(new HandlerException(mod.file, "no Main class")); } @@ -65,30 +65,30 @@ public class JavaHandler implements Function, Map, Map> gethandler(Compiler.Module mod) { - ClassLoader code = mod.code(); + private Function, Map> gethandler(Compiler.File file) { + Compiler.Module mod = file.mod(); synchronized(handlers) { - Function, Map> ret = handlers.get(code); + Function, Map> ret = handlers.get(mod); if(ret == null) - handlers.put(code, ret = makehandler(mod)); + handlers.put(mod, ret = makehandler(mod)); return(ret); } } public Map apply(Map req) { - Compiler.Module mod = Compiler.get().module(Paths.get((String)req.get("SCRIPT_FILENAME"))); + Compiler.File file = Compiler.get().file(Paths.get((String)req.get("SCRIPT_FILENAME"))); try { - mod.update(); + file.update(); } catch(Compiler.CompilationException e) { - log.warning(String.format("Could not compile %s:\n%s", mod.file, e.messages())); + log.warning(String.format("Could not compile %s:\n%s", file.name, e.messages())); return(Utils.simpleerror(500, "Internal Error", "Could not load JAGI handler")); } catch(Exception e) { - log.log(Level.WARNING, String.format("Error occurred when loading %s", mod.file), e); + log.log(Level.WARNING, String.format("Error occurred when loading %s", file.name), e); return(Utils.simpleerror(500, "Internal Error", "Could not load JAGI handler")); } Function, Map> handler; try { - handler = gethandler(mod); + handler = gethandler(file); } catch(HandlerException e) { Throwable cause = e.getCause(); if(cause != null)