/*
* Copyright (C) 2020 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.wehotel.fizz;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.wehotel.constants.CommonConstants;
/**
*
* @author linwaiwai
* @author francis
*
* @param
* @param
*/
@SuppressWarnings("unchecked")
public class StepContext extends ConcurrentHashMap {
public static final String ELAPSED_TIMES = "elapsedTimes";
public static final String DEBUG = "debug";
public static final String RETURN_CONTEXT = "returnContext";
public void setDebug(Boolean debug) {
this.put((K)DEBUG, (V)debug);
}
public String getTraceId() {
return (String) this.get(CommonConstants.TRACE_ID);
}
public void setTraceId(String traceId) {
this.put((K)CommonConstants.TRACE_ID, (V)traceId);
}
/**
* 是否调试模式
* @return
*/
public Boolean isDebug() {
return this.get(DEBUG) == null ? false : (Boolean) this.get(DEBUG);
}
/**
* 是否在响应体里返回上下文
* @return
*/
public boolean returnContext() {
return Boolean.valueOf((String)getInputReqHeader(RETURN_CONTEXT));
}
public synchronized void addElapsedTime(String actionName, Long milliSeconds) {
List