org.aoju.bus.http.plugin.httpz.TextCallback Maven / Gradle / Ivy
/*********************************************************************************
* *
* The MIT License (MIT) *
* *
* Copyright (c) 2015-2022 aoju.org and other contributors. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy *
* of this software and associated documentation files (the "Software"), to deal *
* in the Software without restriction, including without limitation the rights *
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
* copies of the Software, and to permit persons to whom the Software is *
* furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
* THE SOFTWARE. *
* *
********************************************************************************/
package org.aoju.bus.http.plugin.httpz;
import org.aoju.bus.http.Callback;
import org.aoju.bus.http.NewCall;
import org.aoju.bus.http.Response;
import org.aoju.bus.logger.Logger;
import java.io.IOException;
/**
* 回调处理
*
* @author Kimi Liu
* @since Java 17+
*/
public abstract class TextCallback implements Callback {
@Override
public void onResponse(NewCall call, Response response, String id) {
try {
onSuccess(call, response.body().string(), id);
} catch (IOException e) {
Logger.error(e.getMessage(), e);
}
}
@Override
public void onFailure(NewCall call, Exception e, String id) {
Logger.error("onFailure id:{}", id);
Logger.error(e.getMessage(), e);
}
/**
* @param call 回调
* @param response 响应信息
* @param id 当前请求标识
*/
public abstract void onSuccess(NewCall call, String response, String id);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy