org.tinygroup.context.Context类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(255)

本文整理了Java中org.tinygroup.context.Context类的一些代码示例,展示了Context类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context类的具体详情如下:
包路径:org.tinygroup.context.Context
类名称:Context

Context介绍

[英]多层环境
[中]多层环境

代码示例

代码示例来源:origin: org.tinygroup/context

public <T> T get(String contextName, String name) {
  Context subContext = subContextMap.get(contextName);
  if (subContext != null) {
    return (T) subContext.get(name);
  }
  return null;
}

代码示例来源:origin: org.tinygroup/context

public void putAll(Map<? extends String, ? extends Object> map) {
  for (String key : map.keySet()) {
    context.put(key, map.get(key));
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.beancontext

public <T> T get(String name) {
  if (context.exist(name)) {
    return (T) context.get(name);
  } else {
    //必须保存到上下文,否则每次返回不一定是同一个对象(scope可能是属性)
    T t = (T) beanContainer.getBean(name);
    context.put(name, t);
    return t;
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.imda

public void copyObject(Context context, String sourceKey, String destKey) {
  Object object = context.get(sourceKey);
  context.put(destKey, object);
}

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcore

/**
   * 从上下文中解出THREAD_CONTEXT_KEY,并设置为线程变量
   *
   * @param mainContext
   */
  public static void parseCurrentThreadContext(Context mainContext) {
    if (!mainContext.exist(THREAD_CONTEXT_KEY)) {
      return;
    }
    Map<String, Object> currentContext = mainContext.remove(THREAD_CONTEXT_KEY);
//        Context currentContext = mainContext.getSubContext(THREAD_CONTEXT_KEY);
    if (currentContext != null) {
      threadVariableMap.set(currentContext);
    }
  }
}

代码示例来源:origin: org.tinygroup/flowbasiccomponent

public void execute(Context context) {
  if (keyValues == null || "".equals(keyValues)) {
    String[] array = keyValues.split(",");
    for (String s : array) {
      String[] keyvalue = s.split(":");
      if (keyvalue.length == 2) {
        context.put(keyvalue[1], context.get(keyvalue[0]));
        if(replaceModel)
          context.remove(keyvalue[0]);
      }
    }
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorebase

public static void resetEventContext(Event event, CEPCore core,
                     Context oldContext) {
    oldContext.remove(IS_CHANGED);
    String serviceId = event.getServiceRequest().getServiceId();
    Context context = event.getServiceRequest().getContext();
    ServiceInfo service = core.getServiceInfo(serviceId);
    List<Parameter> outputs = service.getResults();
    if (outputs != null) {
      for (Parameter output : outputs) {
        String name = output.getName();
        if (context.exist(name)) {
          oldContext.put(name, context.get(name));
        }
      }
    }
    event.getServiceRequest().setContext(oldContext);
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.tinyscriptbase

/**
 * 获得标识变量的值
 * 
 * @param context
 * @param key
 * @return
 */
public static Object getVariableValue(Context context, Object key) {
  String name = key.toString();
  if(context.exist(name)){
    return context.get(name);
  }else{
    return getValueFromBean(name);
  }
}

代码示例来源:origin: org.tinygroup/velocity

context);
if (initContext != null) {
  context.putSubContext(BASE_CONTEXT, initContext);
getLayoutPaths(layoutPathList, pagePath, pageName);
for (String layoutPath : layoutPathList) {
  context.put(PATH_CONTENT, stringWriter.toString());
  stringWriter.close();
  Template layoutTemplate = velocity

代码示例来源:origin: org.tinygroup/org.tinygroup.templateengine

protected Macro getMacro(TemplateContext $context) {
  Macro $macro;
  $macro = getBodyContentMacro();
  if ($macro == null) {
    $macro = (Macro) $context.getItemMap().get("bodyContent");
  }
  if ($macro == null) {
    Context context = $context;
    while (context.getParent() != null) {
      if (context.get("bodyContent") != null && context.getItemMap().size() > 0 && !context.getItemMap().containsKey("isCalled")) {
        $macro = (Macro) context.getItemMap().get("bodyContent");
        return $macro;
      }
      context = context.getParent();
    }
  }
  return $macro;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorebase

public static void changeEventContext(Event event, CEPCore core,
                   ClassLoader loader) {
  Context oldContext = event.getServiceRequest().getContext();
  if (oldContext.exist(IS_CHANGED)) {
    return;
  }
  Context newContext = ContextFactory.getContext();
  newContext.put(IS_CHANGED, true);
  String serviceId = event.getServiceRequest().getServiceId();
  ServiceInfo service = core.getServiceInfo(serviceId);
  List<Parameter> inputs = service.getParameters();
  if (inputs != null) {
    for (Parameter input : inputs) {
      Object value = getParameterValue(loader, oldContext, input);
      newContext.put(input.getName(), value);
    }
  }
  event.getServiceRequest().setContext(newContext);
}

代码示例来源:origin: org.tinygroup/org.tinygroup.beancontext

public boolean exist(String name) {
  return context.exist(name);
}

代码示例来源:origin: org.tinygroup/org.tinygroup.context

protected boolean existNodeMap(String name, Context contextNode,
                Map<Context, String> nodeMap) {
  // 如果当前不存在,则查找父亲中有没有
  // 如果已经存在,则返回之
  if (contextNode.getItemMap().containsKey(name)) {
    return true;
  } else {
    nodeMap.put(contextNode, "");
  }
  if (!contextNode.getSubContextMap().isEmpty()) {
    for (Context context : contextNode.getSubContextMap().values()) {
      if (nodeMap.get(context) == null) {
        boolean exist = existNodeMap(name, context, nodeMap);
        if (exist) {
          return true;
        }
      }
    }
  }
  Context theParent = contextNode.getParent();
  if (theParent != null && nodeMap.get(theParent) == null) {
    return existNodeMap(name, theParent, nodeMap);
  }
  return false;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.beancontext

public <T> T remove(String contextName, String name) {
  return (T) context.remove(contextName, name);
}

代码示例来源:origin: org.tinygroup/org.tinygroup.beancontext

public Map<String, Object> getItemMap() {
  return context.getItemMap();
}

代码示例来源:origin: org.tinygroup/org.tinygroup.tinyscriptbase

/**
 * 自下往上递归查询包含key值的itemMap
 * @param context
 * @param key
 * @return
 */
private Map<String, Object> findItemMap(Context context,String key){
  if(context!= null){
    if(context.getItemMap().containsKey(key)){
     return context.getItemMap();
    }else{
     return findItemMap(context.getParent(),key);
    }
  }
  return null;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.beancontext

public Context putSubContext(String contextName, Context subContext) {
  return context.putSubContext(contextName, subContext);
}

代码示例来源:origin: org.tinygroup/ientity

protected Context buildParameter(EntityModel model,
    ModelRequestInfo modelRequestInfo, Context context) {
   Context newContext=super.buildParameter(model, modelRequestInfo, context);
   newContext.put(PAGE_SIZE, context.get(PAGE_SIZE));
   newContext.put(PAGE_NUMBER, context.get(PAGE_NUMBER));
   newContext.put(ORDER_BY_FIELD, context.get(ORDER_BY_FIELD));
   newContext.put(SORT_DIRECTION, context.get(SORT_DIRECTION));
   newContext.put(GROUP_BY_FIELD, context.get(GROUP_BY_FIELD));
   return newContext;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.flowbasiccomponent

public void execute(Context context) {
  if (!StringUtil.isBlank(keyValues)) {
    String[] array = keyValues.split(",");
    for (String s : array) {
      String[] keyvalue = s.split(":");
      if (keyvalue.length == 2) {
        context.put(keyvalue[1], context.get(keyvalue[0]));
        if (replaceModel)
          context.remove(keyvalue[0]);
      }
    }
  } else {
    LOGGER.logMessage(LogLevel.WARN, "keyValues为空");
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.tinydb

public static Bean context2Bean(Context c, Bean bean,
                List<String> properties) {
  for (String property : properties) {
    if (c.exist(property)) {
      bean.put(property, c.get(property));
    }
  }
  bean.put(Bean.SELECT_ITEMS_KEY, c.get(Bean.SELECT_ITEMS_KEY));
  bean.put(Bean.CONDITION_FIELD_KEY, c.get(Bean.CONDITION_FIELD_KEY));
  bean.put(Bean.CONDITION_MODE_KEY, c.get(Bean.CONDITION_MODE_KEY));
  bean.put(Bean.ORDER_BY_KEY, c.get(Bean.ORDER_BY_KEY));
  bean.put(Bean.SORT_DIRECTION_KEY, c.get(Bean.SORT_DIRECTION_KEY));
  bean.put(Bean.GROUP_BY_KEY, c.get(Bean.GROUP_BY_KEY));
  return bean;
}

相关文章