protected final void initBindings(Polysupplier<EventsListener> listenersSupp) { listenersSupp.forEach( listener -> { EventBinding[] bindings = listener.getBindings(); for (EventBinding binding : bindings) { List<EventHandler<?>> handlers = eventsBindings.computeIfAbsent(binding.getEventClass(), c -> new ArrayList<>()); handlers.add(binding.getHandler()); } }, null ); }
default void forEach(Consumer<? super T> action, Object message) { if (isNotEmpty()) { Iterator<T> it = iterator(message); while (it.hasNext()) { action.accept(it.next()); } } } }
protected void loadRoutes(Polysupplier<TeleFacade> teleFacadeSupp) { log.debug("Lookup routing tele-facades... "); routeTrie = new RouteTrie<>(null); routesIndex = new RoutesIndex(); Iterator<TeleFacade> it = teleFacadeSupp.iterator(null); while (it.hasNext()) { TeleFacade teleFacade = it.next(); log.debug("Found routing tele-facade: " + teleFacade.getClass().getName()); RoutingLigature ligature = (RoutingLigature) teleFacade.getLigature(); for (RoutingLigature.RouteInfo routeInfo : ligature.getRoutesIno()) { if (log.isDebugEnabled()) { log.debug("Route '" + routeInfo.getRoute() + "' mapped to tele-method '" + ligature.getFramletClass().getName() + "->" + routeInfo.getTeleMethodName()); } RouteTrie.Node<TeleMethod> node = routeTrie.addRoute( routeInfo.getRoute(), routeInfo.getTeleMethod() ); HttpMethod httpMethod = HttpMethod.valueOf(node.getRoot().getName()); routesIndex.addNode(toRouteId(ligature.getFramletClass(), routeInfo.getTeleMethodName(), httpMethod), node); } } }
@Inject public ResourceKitImpl(LocalizingTool localizingTool, RewritingTool rewritingTool, EvaluationTool evaluationTool, Polysupplier<ResourceConfig> configs) { this.localizingTool = localizingTool; this.rewritingTool = rewritingTool; this.evaluationTool = evaluationTool; final QualifiersBinderImpl qualifiersBinder = new QualifiersBinderImpl(localizingTool); final RewritingsBinderImpl rewritingsBinder = new RewritingsBinderImpl(rewritingTool); final PropertiesBinderImpl propertiesBinder = new PropertiesBinderImpl(evaluationTool); configs.forEach(c -> { c.bindQualifiers(qualifiersBinder); c.bindRewritings(rewritingsBinder); c.bindProperties(propertiesBinder); }, null); }