xworker.debug.DebugAction Maven / Gradle / Ivy
/*******************************************************************************
* Copyright 2007-2013 See AUTHORS file.
*
* 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.
******************************************************************************/
package xworker.debug;
import java.util.ArrayList;
import java.util.List;
import org.xmeta.Action;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
public class DebugAction {
public static void init(ActionContext actionContext){
//上下文所在动作上下文
Thing context = (Thing) actionContext.get("self");
if(!context.getBoolean("enabled")) return;
context.put("startTime", System.nanoTime());
//要执行的动作上下文
ActionContext acContext = (ActionContext) actionContext.get("acContext");
//取最后一个Action
List actions = acContext.getActions();
Action action = actions.get(actions.size() - 1);
DebugInfo debugInfo = Debuger.getDebugInfo(Thread.currentThread());
Debuger debuger = Debuger.getDebuger();
if(debugInfo.status == DebugInfo.STATUS_DEBUG || debuger.getActionDebugInfo(action.getThing(), "initBreakPoint")){
debugInfo.startDebug(acContext, DebugInfo.ACTION_STATUS_INIT);
}
}
public static void success(ActionContext actionContext){
long endTime = System.nanoTime();
//上下文所在动作上下文
Thing context = (Thing) actionContext.get("self");
if(!context.getBoolean("enabled")) return;
long time = endTime - (Long) context.get("startTime");
//要执行的动作上下文
ActionContext acContext = (ActionContext) actionContext.get("acContext");
//取最后一个Action
List actions = acContext.getActions();
Action action = actions.get(actions.size() - 1);
Debuger.getDebuger().record(action.getThing().getMetadata().getPath(), time, true);
DebugInfo debugInfo = Debuger.getDebugInfo(Thread.currentThread());
Debuger debuger = Debuger.getDebuger();
if(debugInfo.status == DebugInfo.STATUS_DEBUG || debuger.getActionDebugInfo(action.getThing(), "successBreakPoint")){
debugInfo.startDebug(acContext, DebugInfo.ACTION_STATUS_SUCCESS);
}
}
public static void exception(ActionContext actionContext){
long endTime = System.nanoTime();
//上下文所在动作上下文
Thing context = (Thing) actionContext.get("self");
if(!context.getBoolean("enabled")) return;
long time = endTime - (Long) context.get("startTime");
//要执行的动作上下文
ActionContext acContext = (ActionContext) actionContext.get("acContext");
//取最后一个Action
List actions = acContext.getActions();
Action action = actions.get(actions.size() - 1);
Debuger.getDebuger().record(action.getThing().getMetadata().getPath(), time, false);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy