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

io.vertx.up.uca.web.origin.AffluxInquirer Maven / Gradle / Ivy

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

import io.vertx.up.eon.Info;
import io.vertx.up.eon.Plugins;
import io.vertx.up.log.Annal;
import io.vertx.up.uca.web.thread.AffluxThread;
import io.vertx.up.runtime.Anno;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;

public class AffluxInquirer implements
        Inquirer, ConcurrentMap>>> {

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

    @Override
    public ConcurrentMap, ConcurrentMap>> scan(final Set> classes) {
        // Find condition ok
        final Set> enabled = classes.stream()
                .filter(item -> Anno.isMark(item, Plugins.INJECT_ANNOTATIONS))
                .collect(Collectors.toSet());
        // Scan each class.
        final List threadReference = new ArrayList<>();
        for (final Class clazz : enabled) {
            final AffluxThread thread = new
                    AffluxThread(clazz, classes);
            threadReference.add(thread);
            thread.start();
        }
        threadReference.forEach(thread -> {
            try {
                thread.join();
            } catch (final InterruptedException ex) {
                LOGGER.jvm(ex);
            }
        });
        final ConcurrentMap, ConcurrentMap>> affluxes
                = new ConcurrentHashMap<>();
        for (final AffluxThread thread : threadReference) {
            if (!thread.isEmpty()) {
                final Class key = thread.getClassKey();
                final ConcurrentMap> fields = thread.getFieldMap();
                affluxes.put(key, fields);
                LOGGER.info(Info.SCANED_INJECTION, key.getName(), fields.size());
            }
        }
        return affluxes;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy