use of ratpack.func.Action in project ratpack by ratpack.
the class DefaultContext method start.
public static void start(EventLoop eventLoop, final RequestConstants requestConstants, Registry registry, Handler[] handlers, Action<? super Execution> onComplete) {
ChainIndex index = new ChainIndex(handlers, registry, true);
requestConstants.indexes.push(index);
DefaultContext context = new DefaultContext(requestConstants);
requestConstants.context = context;
context.pathBindings = new PathBindingStorage(new RootPathBinding(requestConstants.request.getPath()));
requestConstants.applicationConstants.execController.fork().onError(throwable -> requestConstants.context.error(throwable instanceof HandlerException ? throwable.getCause() : throwable)).onComplete(onComplete).register(s -> s.add(Context.TYPE, context).add(Request.TYPE, requestConstants.request).add(Response.TYPE, requestConstants.response).add(PathBindingStorage.TYPE, context.pathBindings).addLazy(RequestId.TYPE, () -> registry.get(RequestId.Generator.TYPE).generate(requestConstants.request))).eventLoop(eventLoop).onStart(e -> DefaultRequest.setDelegateRegistry(requestConstants.request, e)).start(e -> {
requestConstants.execution = e;
context.joinedRegistry = new ContextRegistry(context).join(requestConstants.execution);
context.next();
});
}
use of ratpack.func.Action in project ratpack by ratpack.
the class ChainConfigurers method execute.
@Override
public void execute(Chain chain) throws Exception {
List<Action<Chain>> delegates = new ArrayList<>(this.delegates);
for (RatpackServerCustomizer customizer : customizers) {
delegates.addAll(customizer.getHandlers());
}
if (handlers.size() == 1 || delegates.isEmpty()) {
delegates.add(singleHandlerAction());
}
delegates.add(staticResourcesAction(chain.getServerConfig()));
AnnotationAwareOrderComparator.sort(delegates);
for (Action<Chain> delegate : delegates) {
if (!(delegate instanceof ChainConfigurers)) {
delegate.execute(chain);
}
}
}
Aggregations