diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
index f5b6b67..28facf3 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
@@ -119,7 +119,7 @@
         String env = params.get("Environment");
         logger.info("Environmnet" + env);
         if (env.equals(StringUtils.EMPTY)) {
-            chefServerResult(new RequestContext(ctx), 200, "Skip Environment block ");
+            chefServerResult(ctx, 200, "Skip Environment block ");
         } else {
             String message;
             if (privateKeyChecker.doesExist(clientPrivatekey)) {
@@ -138,7 +138,7 @@
                         message = chefResponse.getBody();
                         logger.info("requestbody {}", chefResponse.getBody());
                     }
-                    chefServerResult(new RequestContext(ctx), code, message);
+                    chefServerResult(ctx, code, message);
                 } catch (JSONException e) {
                     code = 401;
                     logger.error(POSTING_REQUEST_JSON_ERROR_STR, e);
@@ -171,8 +171,6 @@
                 nodeListS = nodeListS.replace("\"", StringUtils.EMPTY);
                 nodeListS = nodeListS.replace(" ", StringUtils.EMPTY);
                 List<String> nodes = Arrays.asList(nodeListS.split("\\s*,\\s*"));
-                RequestContext rc = new RequestContext(ctx);
-                rc.isAlive();
                 code = 200;
                 String message = null;
                 if (privateKeyChecker.doesExist(clientPrivatekey)) {
@@ -196,7 +194,7 @@
                     message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
                     doFailure(ctx, code, message);
                 }
-                chefServerResult(rc, code, message);
+                chefServerResult(ctx, code, message);
             } else {
                 throw new SvcLogicException("Missing Mandatory param(s) Node , NodeList ");
             }
@@ -232,10 +230,6 @@
                     pushRequest = "{" + "\"command\": \"chef-client\"," + "\"run_timeout\": 300," + "\"nodes\":"
                         + nodeList + "," + "\"env\": {}," + "\"capture_output\": true" + "}";
                 }
-                RequestContext rc = new RequestContext(ctx);
-
-                rc.isAlive();
-                SvcLogicContext svcLogic = rc.getSvcLogicContext();
                 ChefApiClient cac = chefApiClientFactory.create(chefserver, organizations, username, clientPrivatekey);
                 ChefResponse chefResponse = cac.post(chefAction, pushRequest);
                 code = chefResponse.getStatusCode();
@@ -246,10 +240,10 @@
                     int startIndex = message.indexOf("jobs") + 5;
                     int endIndex = message.length() - 2;
                     String jobID = message.substring(startIndex, endIndex);
-                    svcLogic.setAttribute("jobID", jobID);
+                    ctx.setAttribute("jobID", jobID);
                     logger.info(jobID);
                 }
-                chefServerResult(rc, code, message);
+                chefServerResult(ctx, code, message);
             } else {
                 throw new SvcLogicException("Missing Mandatory param(s)  NodeList ");
             }
@@ -323,9 +317,7 @@
                     }
                 }
 
-                RequestContext rc = new RequestContext(ctx);
-                rc.isAlive();
-                chefServerResult(rc, code, returnMessage);
+                chefServerResult(ctx, code, returnMessage);
             } else {
                 throw new SvcLogicException("Missing Mandatory param(s)  NodeList ");
             }
@@ -430,8 +422,6 @@
         logger.info("chef get method");
         chefInfo(params, ctx);
         String chefAction = params.get(CHEF_ACTION_STR);
-        RequestContext rc = new RequestContext(ctx);
-        rc.isAlive();
         int code;
         String message;
 
@@ -443,7 +433,7 @@
             code = 500;
             message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
         }
-        chefServerResult(rc, code, message);
+        chefServerResult(ctx, code, message);
     }
 
     /**
@@ -456,8 +446,6 @@
         chefInfo(params, ctx);
         String chefAction = params.get(CHEF_ACTION_STR);
         String chefNodeStr = params.get("chefRequestBody");
-        RequestContext rc = new RequestContext(ctx);
-        rc.isAlive();
         int code;
         String message;
         if (privateKeyChecker.doesExist(clientPrivatekey)) {
@@ -471,7 +459,7 @@
             message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
         }
         logger.info(code + "   " + message);
-        chefServerResult(rc, code, message);
+        chefServerResult(ctx, code, message);
     }
 
     /**
@@ -485,8 +473,6 @@
         String chefNodeStr = params.get("chefRequestBody");
         String chefAction = params.get(CHEF_ACTION_STR);
 
-        RequestContext rc = new RequestContext(ctx);
-        rc.isAlive();
         int code;
         String message;
         // should load pem from somewhere else
@@ -503,7 +489,7 @@
             message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
         }
         logger.info(code + "   " + message);
-        chefServerResult(rc, code, message);
+        chefServerResult(ctx, code, message);
     }
 
     /**
@@ -514,8 +500,6 @@
         logger.info("chef delete method");
         chefInfo(params, ctx);
         String chefAction = params.get(CHEF_ACTION_STR);
-        RequestContext rc = new RequestContext(ctx);
-        rc.isAlive();
         int code;
         String message;
         if (privateKeyChecker.doesExist(clientPrivatekey)) {
@@ -528,7 +512,7 @@
             message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
         }
         logger.info(code + "   " + message);
-        chefServerResult(rc, code, message);
+        chefServerResult(ctx, code, message);
     }
 
     /**
@@ -538,12 +522,10 @@
     public void trigger(Map<String, String> params, SvcLogicContext svcLogicContext) {
         logger.info("Run trigger method");
         String tVmIp = params.get("ip");
-        RequestContext rc = new RequestContext(svcLogicContext);
-        rc.isAlive();
 
         try {
             ChefResponse chefResponse = chefApiClientFactory.create(tVmIp).get("");
-            chefClientResult(rc, chefResponse.getStatusCode(), chefResponse.getBody());
+            chefClientResult(svcLogicContext, chefResponse.getStatusCode(), chefResponse.getBody());
             svcLogicContext.setAttribute("chefAgent.code", "200");
         } catch (Exception e) {
             logger.error("An error occurred when executing trigger method", e);
@@ -568,9 +550,6 @@
 
                 String chefAction = "/pushy/jobs/" + jobID;
 
-                RequestContext rc = new RequestContext(ctx);
-                rc.isAlive();
-                SvcLogicContext svcLogic = rc.getSvcLogicContext();
                 String message = StringUtils.EMPTY;
                 String status = StringUtils.EMPTY;
                 for (int i = 0; i < retryTimes; i++) {
@@ -585,7 +564,7 @@
                         break;
                     }
                 }
-                resolveSvcLogicAttributes(svcLogic, message, status);
+                resolveSvcLogicAttributes(ctx, message, status);
             } else {
                 throw new SvcLogicException("Missing Mandatory param(s) retryTimes , retryInterval ");
             }
@@ -625,9 +604,6 @@
             chefInfo(params, ctx);
             String pushRequest = params.get("pushRequest");
             String chefAction = "/pushy/jobs";
-            RequestContext rc = new RequestContext(ctx);
-            rc.isAlive();
-            SvcLogicContext svcLogic = rc.getSvcLogicContext();
             ChefApiClient chefApiClient = chefApiClientFactory.create(chefserver, organizations, username, clientPrivatekey);
             ChefResponse chefResponse = chefApiClient.post(chefAction, pushRequest);
 
@@ -637,10 +613,10 @@
                 int startIndex = message.indexOf("jobs") + 6;
                 int endIndex = message.length() - 2;
                 String jobID = message.substring(startIndex, endIndex);
-                svcLogic.setAttribute("jobID", jobID);
+                ctx.setAttribute("jobID", jobID);
                 logger.info(jobID);
             }
-            chefServerResult(rc, code, message);
+            chefServerResult(ctx, code, message);
         } catch (Exception e) {
             code = 401;
             logger.error("An error occurred when executing pushJob method", e);
@@ -649,26 +625,25 @@
     }
 
     @SuppressWarnings("static-method")
-    private void chefServerResult(RequestContext rc, int code, String message) {
-        initSvcLogic(rc, code, message, "server");
+    private void chefServerResult(SvcLogicContext svcLogicContext, int code, String message) {
+        initSvcLogic(svcLogicContext, code, message, "server");
     }
 
     @SuppressWarnings("static-method")
-    private void chefClientResult(RequestContext rc, int code, String message) {
-        initSvcLogic(rc, code, message, "client");
+    private void chefClientResult(SvcLogicContext svcLogicContext, int code, String message) {
+        initSvcLogic(svcLogicContext, code, message, "client");
     }
 
-    private void initSvcLogic(RequestContext rc, int code, String message, String target) {
+    private void initSvcLogic(SvcLogicContext svcLogicContext, int code, String message, String target) {
 
-        SvcLogicContext svcLogic = rc.getSvcLogicContext();
         String codeStr = "server".equals(target) ? CHEF_SERVER_RESULT_CODE_STR : CHEF_CLIENT_RESULT_CODE_STR;
         String messageStr = "client".equals(target) ? CHEF_CLIENT_RESULT_MSG_STR : CHEF_SERVER_RESULT_MSG_STR;
 
-        svcLogic.setStatus(OUTCOME_SUCCESS);
-        svcLogic.setAttribute(codeStr, Integer.toString(code));
-        svcLogic.setAttribute(messageStr, message);
-        logger.info(codeStr + ": " + svcLogic.getAttribute(codeStr));
-        logger.info(messageStr + ": " + svcLogic.getAttribute(messageStr));
+        svcLogicContext.setStatus(OUTCOME_SUCCESS);
+        svcLogicContext.setAttribute(codeStr, Integer.toString(code));
+        svcLogicContext.setAttribute(messageStr, message);
+        logger.info(codeStr + ": " + svcLogicContext.getAttribute(codeStr));
+        logger.info(messageStr + ": " + svcLogicContext.getAttribute(messageStr));
     }
 
     @SuppressWarnings("static-method")
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/RequestContext.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/RequestContext.java
deleted file mode 100644
index 3c0e00a..0000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/RequestContext.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- * 
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.impl;
-
-import org.onap.appc.Constants;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
-/**
- * This class is used to track and maintain recovery and time-to-live information for a request as it is being
- * processed.
- */
-public class RequestContext {
-    /**
-     * The number of seconds of wait time between successive attempts to connect to the provider. This is used to
-     * recover from provider outages or failures. It is not used to recover from logical errors, such as an invalid
-     * request, server not found, etc.
-     */
-    private Integer retryDelay;
-
-    /**
-     * The number of times we will attempt to connect to the provider. This is used to recover from provider outages or
-     * failures. It is not used to recover from logical errors, such as an invalid request, server not found, etc.
-     */
-    private Integer retryLimit;
-
-    /**
-     * The total time, in milliseconds, that the provider can have to process this request. If the accumulated time
-     * exceeds the time to live, then the request is failed with a timeout exception, regardless of the state of the
-     * provider. Note that the caller may supply this as a value in seconds, in which case it must be converted to
-     * milliseconds for the request context.
-     */
-    private Long timeToLive;
-
-    /**
-     * The accumulated time, in milliseconds, that has been used so far to process the request. This is compared to the
-     * time to live each time it is updated. If the accumulated time exceeds the time to live, then the request is
-     * failed with a timeout exception, regardless of the state of the provider.
-     */
-    private long accumulatedTime;
-
-    /**
-     * The total number of retries attempted so far
-     */
-    private int attempt;
-
-    /**
-     * The time when the stopwatch was started
-     */
-    private long startTime = -1;
-
-    /**
-     * The service logic (DG) context from the SLI
-     */
-    private SvcLogicContext svcLogicContext;
-
-    /**
-     * The configuration
-     */
-    private Configuration configuration = ConfigurationFactory.getConfiguration();
-
-    /**
-     * Set to true whenever the retry limit has been exceeded, reset to false when reset() is called.
-     */
-    private boolean retryFailed;
-
-    /**
-     * Creates the request context
-     *
-     * @param context
-     *            The service logic (SLI) context associated with the current DG
-     */
-    public RequestContext(SvcLogicContext context) {
-        setSvcLogicContext(context);
-    }
-
-    /**
-     * @return The retry delay, in seconds. If zero, then no retry is to be performed
-     */
-    public int getRetryDelay() {
-        if (retryDelay == null) {
-            int value = configuration.getIntegerProperty(Constants.PROPERTY_RETRY_DELAY);
-            retryDelay = Integer.valueOf(value);
-        }
-
-        return retryDelay.intValue();
-    }
-
-    /**
-     * This method is a helper that allows the caller to delay for the retry interval time and not have to handle the
-     * thread interruption, timer handling, etc.
-     */
-    public void delay() {
-        long time = getRetryDelay() * 1000L;
-        long future = System.currentTimeMillis() + time;
-        if (time != 0) {
-            while (System.currentTimeMillis() < future && time > 0) {
-                try {
-                    Thread.sleep(time);
-                } catch (InterruptedException e) {
-                    /*
-                     * This is rare, but it can happen if another thread interrupts us while we are sleeping. In that
-                     * case, the thread is resumed before the delay time has actually expired, so re-calculate the
-                     * amount of delay time needed and reenter the sleep until we get to the future time.
-                     */
-                    time = future - System.currentTimeMillis();
-                }
-            }
-        }
-    }
-
-    /**
-     * @return The number of retries that are allowed per connection
-     */
-    public int getRetryLimit() {
-        if (retryLimit == null) {
-            int value = configuration.getIntegerProperty(Constants.PROPERTY_RETRY_LIMIT);
-            retryLimit = Integer.valueOf(value);
-        }
-
-        return retryLimit.intValue();
-    }
-
-    /**
-     * Check and count the connection attempt.
-     *
-     * @return True if the connection should be attempted. False indicates that the number of retries has been exhausted
-     *         and it should NOT be attempted.
-     */
-    public boolean attempt() {
-        if (retryFailed || attempt >= getRetryLimit()) {
-            retryFailed = true;
-            return false;
-        }
-        attempt++;
-
-        return true;
-    }
-
-    /**
-     * @return The number of retry attempts so far
-     */
-    public int getAttempts() {
-        return attempt;
-    }
-
-    /**
-     * @return True if the retry limit has been exceeded, false otherwise
-     */
-    public boolean isFailed() {
-        return retryFailed;
-    }
-
-    /**
-     * This method both checks the time to live to see if it has been exceeded and accumulates the total time used so
-     * far.
-     * <p>
-     * Each time this method is called it accumulates the total duration since the last time it was called to the total
-     * time accumulator. It then checks the total time to the time to live and if greater, it returns false. As long as
-     * the total time used is less than or equal to the time to live limit, the method returns true. It is important to
-     * call this method at the very beginning of the process so that all parts of the process are tracked.
-     * </p>
-     *
-     * @return True if the total time to live has not been exceeded. False indicates that the total time to live has
-     *         been exceeded and no further processing should be performed.
-     */
-    public boolean isAlive() {
-        long now = System.currentTimeMillis();
-        if (startTime == -1) {
-            startTime = now;
-            return true;
-        }
-        accumulatedTime += (now - startTime);
-        startTime = now;
-        if (accumulatedTime > timeToLive) {
-            return false;
-        }
-        return true;
-    }
-
-    /**
-     * @return The total amount of time used, in milliseconds.
-     */
-    public long getTotalDuration() {
-        return accumulatedTime;
-    }
-
-    /**
-     * This method is called to reset the retry counters. It has no effect on the time to live accumulator.
-     */
-    public void reset() {
-        attempt = 0;
-    }
-
-    /**
-     * Sets the time to live to the value, expressed in seconds
-     *
-     * @param time
-     *            The time to live, in seconds
-     */
-    public void setTimeToLiveSeconds(int time) {
-        setTimeToLiveMS(time * 1000L);
-    }
-
-    /**
-     * Sets the time to live to the value, expressed in milliseconds
-     *
-     * @param time
-     *            The time to live, in milliseconds
-     */
-    public void setTimeToLiveMS(long time) {
-        this.timeToLive = time;
-    }
-
-    /**
-     * @return The service logic context associated with this request
-     */
-    public SvcLogicContext getSvcLogicContext() {
-        return svcLogicContext;
-    }
-
-    /**
-     * @param svcLogicContext
-     *            The service logic context to be associated with this request
-     */
-    public void setSvcLogicContext(SvcLogicContext svcLogicContext) {
-        this.svcLogicContext = svcLogicContext;
-    }
-}
