Java 类ch.qos.logback.core.joran.action.ActionUtil.Scope 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringPropertyAction.java   
@Override
public void begin(InterpretationContext ic, String elementName, Attributes attributes)
        throws ActionException {
    String name = attributes.getValue(NAME_ATTRIBUTE);
    String source = attributes.getValue(SOURCE_ATTRIBUTE);
    Scope scope = ActionUtil.stringToScope(attributes.getValue(SCOPE_ATTRIBUTE));
    String defaultValue = attributes.getValue(DEFAULT_VALUE_ATTRIBUTE);
    if (OptionHelper.isEmpty(name) || OptionHelper.isEmpty(source)) {
        addError(
                "The \"name\" and \"source\" attributes of <springProperty> must be set");
    }
    ActionUtil.setProperty(ic, name, getValue(source, defaultValue), scope);
}
项目:spring-boot-concourse    文件:SpringPropertyAction.java   
@Override
public void begin(InterpretationContext ic, String elementName, Attributes attributes)
        throws ActionException {
    String name = attributes.getValue(NAME_ATTRIBUTE);
    String source = attributes.getValue(SOURCE_ATTRIBUTE);
    Scope scope = ActionUtil.stringToScope(attributes.getValue(SCOPE_ATTRIBUTE));
    String defaultValue = attributes.getValue(DEFAULT_VALUE_ATTRIBUTE);
    if (OptionHelper.isEmpty(name) || OptionHelper.isEmpty(source)) {
        addError(
                "The \"name\" and \"source\" attributes of <springProperty> must be set");
    }
    ActionUtil.setProperty(ic, name, getValue(source, defaultValue), scope);
}
项目:bartleby    文件:PropertyAction.java   
void loadAndSetProperties(InterpretationContext ec, InputStream istream, Scope scope)
    throws IOException {
  Properties props = new Properties();
  props.load(istream);
  istream.close();
  ActionUtil.setProperties(ec, props, scope);
}
项目:bartleby    文件:TimestampAction.java   
@Override
public void begin(InterpretationContext ec, String name, Attributes attributes)
    throws ActionException {
  String keyStr = attributes.getValue(KEY_ATTRIBUTE);
  if (OptionHelper.isEmpty(keyStr)) {
    addError("Attribute named [" + KEY_ATTRIBUTE + "] cannot be empty");
    inError = true;
  }
  String datePatternStr = attributes.getValue(DATE_PATTERN_ATTRIBUTE);
  if (OptionHelper.isEmpty(datePatternStr)) {
    addError("Attribute named [" + DATE_PATTERN_ATTRIBUTE
        + "] cannot be empty");
    inError = true;
  }

  String timeReferenceStr = attributes.getValue(TIME_REFERENCE_ATTRIBUTE);
  long timeReference;
  if (CONTEXT_BIRTH.equalsIgnoreCase(timeReferenceStr)) {
    addInfo("Using context birth as time reference.");
    timeReference = context.getBirthTime();
  } else {
    timeReference =  System.currentTimeMillis();
    addInfo("Using current interpretation time, i.e. now, as time reference.");
  }


  if (inError)
    return;

  String scopeStr = attributes.getValue(SCOPE_ATTRIBUTE);
  Scope scope = ActionUtil.stringToScope(scopeStr);

  CachingDateFormatter sdf = new CachingDateFormatter(datePatternStr);
  String val = sdf.format(timeReference);

  addInfo("Adding property to the context with key=\"" + keyStr
      + "\" and value=\"" + val + "\" to the " + scope + " scope");
  ActionUtil.setProperty(ec, keyStr, val, scope);
}
项目:contestparser    文件:SpringPropertyAction.java   
@Override
public void begin(InterpretationContext ic, String elementName, Attributes attributes)
        throws ActionException {
    String name = attributes.getValue(NAME_ATTRIBUTE);
    String source = attributes.getValue(SOURCE_ATTRIBUTE);
    Scope scope = ActionUtil.stringToScope(attributes.getValue(SCOPE_ATTRIBUTE));
    if (OptionHelper.isEmpty(name) || OptionHelper.isEmpty(source)) {
        addError(
                "The \"name\" and \"source\" attributes of <springProperty> must be set");
    }
    ActionUtil.setProperty(ic, name, getValue(source), scope);
}
项目:logback-access-spring-boot-starter    文件:LogbackAccessJoranConfigurator.java   
/** {@inheritDoc} */
@Override
public void begin(InterpretationContext ic, String name, Attributes attributes) throws ActionException {
    String key = attributes.getValue(NAME_ATTRIBUTE);
    Scope scope = ActionUtil.stringToScope(attributes.getValue(SCOPE_ATTRIBUTE));
    String source = attributes.getValue("source");
    String defaultValue = attributes.getValue("defaultValue");
    String value = environment.getProperty(source, defaultValue);
    ActionUtil.setProperty(ic, key, value, scope);
}