2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.client.impl.core;
27 import com.att.eelf.configuration.EELFLogger;
28 import com.att.eelf.configuration.EELFManager;
30 import java.util.concurrent.TimeoutException;
32 /** Handles async responses
34 class AsyncRequestResponseHandler extends AbstractRequestResponseHandler {
36 private final EELFLogger LOG = EELFManager.getInstance().getLogger(AsyncRequestResponseHandler.class);
38 AsyncRequestResponseHandler(String corrID,
39 ICoreResponseHandler businessCallback,
40 CoreManager coreManager)
42 super(corrID, businessCallback, coreManager);
46 * Calls API callback for sending response to consumer's listener. in case of complete response cleans timer and
47 * unregisters the handler.
48 * @param response - Response
49 * @param type - Type of Response
51 public void runTask(String response, String type) {
52 boolean finalTask = false;
54 finalTask = ((ICoreAsyncResponseHandler) businessCallback).onResponse(response, type);
55 } catch (Exception e){
56 LOG.error("Error on API layer, for request with correlation-id " + corrID, e);
59 coreManager.cancelTimer(corrID);
60 coreManager.unregisterHandler(corrID);
69 * Calls to API layer for sending timeout exception.
72 public void onTimeOut() {
73 LOG.info("timeout for request with correlation-id " + corrID);
74 ((ICoreAsyncResponseHandler)businessCallback).onException(new TimeoutException("timeout for request with correlation-id " + corrID));