use of io.vertx.up.eon.Plugins in project vertx-zero by silentbalanceyh.
the class InfixScatter method connect.
@Override
public void connect(final Vertx vertx) {
final ConcurrentMap<String, Class<?>> wholeInjections = ZeroAmbient.getInjections();
/**
* Enabled *
*/
final ConcurrentMap<String, Class<?>> enabled = Ut.reduce(node.read().keySet(), wholeInjections);
/**
* Scan all Infix *
*/
final ConcurrentMap<Class<? extends Annotation>, Class<?>> injections = Ut.reduce(Plugins.INFIX_MAP, enabled);
injections.values().stream().forEach(item -> {
if (null != item && item.isAnnotationPresent(Plugin.class)) {
final Method method = this.findInit(item);
Fn.flingUp(null == method, LOGGER, PluginSpecificationException.class, this.getClass(), item.getName());
Fn.safeJvm(() -> method.invoke(null, vertx), LOGGER);
}
});
/**
* Scan all extension Infix *
*/
Observable.fromIterable(wholeInjections.keySet()).filter(key -> !Plugins.Infix.STANDAND.contains(key)).map(wholeInjections::get).filter(item -> null != item && item.isAnnotationPresent(Plugin.class)).subscribe(item -> {
final Method method = this.findInit(item);
Fn.flingUp(null == method, LOGGER, PluginSpecificationException.class, this.getClass(), item.getName());
Fn.safeJvm(() -> method.invoke(null, vertx), LOGGER);
});
/**
* After infix inject plugins *
*/
Fn.itSet(PLUGINS, (clazz, index) -> Runner.run(() -> {
/**
* Instance reference *
*/
final Object reference = Instance.singleton(clazz);
/**
* Injects scanner *
*/
PLUGIN.inject(reference);
}, "injects-plugin-scannner"));
}
Aggregations