示例#1
0
 public JoodoServlet() {
   try {
     final Var var = loadVar("joodo.kake.servlet", "initialize-joodo-servlet");
     var.invoke(this);
   } catch (Exception e) {
     e.printStackTrace();
     throw new RuntimeException(e);
   }
 }
示例#2
0
  protected static Var loadVar(String namespace, String varName) {
    try {
      Symbol namespaceSymbol = Symbol.intern(namespace);
      Namespace ns = Namespace.find(namespaceSymbol);
      if (ns != null) return (Var) ns.getMapping(Symbol.create(varName));

      RT.load(namespace, false);

      ns = Namespace.find(namespaceSymbol);
      if (ns != null) return (Var) ns.getMapping(Symbol.create(varName));

      final String coreFilename = Clj.nsToFilename(namespace);
      RT.loadResourceScript(coreFilename);
      ns = Namespace.find(namespaceSymbol);
      if (ns != null) return (Var) ns.getMapping(Symbol.create(varName));

      throw new RuntimeException(
          "var still not found after load attempts: " + namespace + "/" + varName);
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException("Failed to load var:" + namespace + "/" + varName, e);
    }
  }