use of io.vertx.up.tool.mirror.Instance 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"));
}
use of io.vertx.up.tool.mirror.Instance in project vertx-zero by silentbalanceyh.
the class RpcHelper method getRecord.
static Record getRecord(final JsonObject config) {
/**
* Config Verify *
*/
Fn.flingUp(() -> Fn.shuntZero(() -> Ruler.verify(Key.RULE_KEY, config), config), LOGGER);
// Connect remote etcd to check service
final ConcurrentMap<String, Record> registryData = ORIGIN.getRegistryData();
final String name = config.getString(Key.NAME);
final String address = config.getString(Key.ADDR);
LOGGER.debug(Info.RPC_SERVICE, name, address);
// Empty Found
Fn.flingWeb(registryData.values().isEmpty(), LOGGER, _424RpcServiceException.class, RpcHelper.class, name, address);
// Service status checking
final RxHod container = new RxHod();
// Lookup Record instance
Observable.fromIterable(registryData.values()).filter(Objects::nonNull).filter(item -> Ut.notNil(item.getName())).filter(item -> name.equals(item.getName()) && address.equals(item.getMetadata().getString(Key.PATH))).subscribe(container::add);
// Service Not Found
Fn.flingWeb(!container.successed(), LOGGER, _424RpcServiceException.class, RpcHelper.class, name, address);
// Address Not Found
Fn.flingWeb(!container.successed(), LOGGER, _424RpcServiceException.class, RpcHelper.class, name, address);
final Record record = container.get();
LOGGER.debug(Info.RPC_FOUND, record.toJson());
return container.get();
}
Aggregations