Checks the module for relevant annotations. @param ctx database context @throws QueryException query exception @throws IOException I/O exception
(final Context ctx)
| 46 | * @throws IOException I/O exception |
| 47 | */ |
| 48 | void parse(final Context ctx) throws QueryException, IOException { |
| 49 | final long ts = file.timeStamp(); |
| 50 | if(time == ts) return; |
| 51 | |
| 52 | time = ts; |
| 53 | content = file.readString(); |
| 54 | |
| 55 | functions.clear(); |
| 56 | wsFunctions.clear(); |
| 57 | |
| 58 | try(QueryContext qc = qc(ctx)) { |
| 59 | // loop through all functions |
| 60 | final String name = file.name(); |
| 61 | for(final StaticFunc sf : qc.functions) { |
| 62 | // only add functions that are defined in the same module (file) |
| 63 | if(sf.expr != null && name.equals(new IOFile(sf.info.path()).name())) { |
| 64 | final RestXqFunction rxf = new RestXqFunction(sf, this, qc); |
| 65 | if(rxf.parseAnnotations(null)) functions.add(rxf); |
| 66 | final WsFunction wxq = new WsFunction(sf, this, qc); |
| 67 | if(wxq.parseAnnotations(null)) wsFunctions.add(wxq); |
| 68 | } |
| 69 | } |
| 70 | } catch(final QueryException ex) { |
| 71 | if(ctx.soptions.get(StaticOptions.RESTXQERRORS)) throw ex; |
| 72 | // ignore modules that cannot be parsed |
| 73 | ctx.log.writeServer(LogType.ERROR, Util.message(ex)); |
| 74 | Util.debug(ex); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Returns all RESTXQ functions. |