All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.up.uca.web.anima.CodexScatter Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.up.uca.web.anima;

import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.up.eon.FileSuffix;
import io.vertx.up.eon.Info;
import io.vertx.up.eon.Strings;
import io.vertx.up.log.Annal;
import io.vertx.up.util.Ut;
import io.vertx.up.exception.heart.EmptyStreamException;
import io.vertx.up.runtime.ZeroCodex;

import java.util.List;

public class CodexScatter implements Scatter {

    private static final Annal LOGGER = Annal.get(CodexScatter.class);

    @Override
    public void connect(final Vertx vertx) {
        // 1. Load rules
        final List rules = Ut.ioFiles("codex", FileSuffix.YML);
        LOGGER.info(Info.SCANED_RULE, rules.size());
        // 2. Load request from rules
        for (final String rule : rules) {
            try {
                final String filename = "codex/" + rule;
                final JsonObject ruleData = Ut.ioYaml(filename);
                if (null != ruleData && !ruleData.isEmpty()) {
                    // File the codex map about the rule definitions.
                    ZeroCodex.getCodex().put(rule.substring(0, rule.lastIndexOf(Strings.DOT)), ruleData);
                }
            } catch (final EmptyStreamException ex) {
                LOGGER.vertx(ex);
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy