Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.rapidoid.http.fast;
/*
* #%L
* rapidoid-http-fast
* %%
* Copyright (C) 2014 - 2015 Nikolche Mihajlovski and contributors
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.Map;
import java.util.concurrent.Future;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.cls.Cls;
import org.rapidoid.concurrent.Callback;
import org.rapidoid.ctx.Ctx;
import org.rapidoid.lambda.Mapper;
import org.rapidoid.net.abstracts.Channel;
import org.rapidoid.u.U;
import org.rapidoid.util.UTILS;
@Authors("Nikolche Mihajlovski")
@Since("4.3.0")
public abstract class AbstractAsyncHttpHandler extends AbstractFastHttpHandler {
private final FastHttp http;
private final byte[] contentType;
protected final HttpWrapper[] wrappers;
public AbstractAsyncHttpHandler(FastHttp http, byte[] contentType, HttpWrapper[] wrappers) {
this.http = http;
this.contentType = contentType;
this.wrappers = wrappers;
}
@Override
public HttpStatus handle(Channel ctx, boolean isKeepAlive, Map params) {
try {
ctx.async();
execHandlerJob(ctx, isKeepAlive, params);
} catch (Throwable e) {
return http.error(ctx, isKeepAlive, e);
}
return HttpStatus.ASYNC;
}
@SuppressWarnings("unchecked")
protected Object postprocessResult(Object result) throws Exception {
if (result instanceof Future>) {
result = ((Future