ch.qos.logback.core.joran.spi.InterpretationContext Java Examples

The following examples show how to use ch.qos.logback.core.joran.spi.InterpretationContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringPropertyAction.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #2
Source File: SpringProfileAction.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public void begin(InterpretationContext ic, String name, Attributes attributes) throws ActionException {
	this.depth++;
	if (this.depth != 1) {
		return;
	}
	ic.pushObject(this);
	this.acceptsProfile = acceptsProfiles(ic, attributes);
	this.events = new ArrayList<SaxEvent>();
	ic.addInPlayListener(this);
}
 
Example #3
Source File: SpringProfileAction.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
private boolean acceptsProfiles(InterpretationContext ic, Attributes attributes) {
	String[] profileNames = StringUtils
			.trimArrayElements(StringUtils.commaDelimitedListToStringArray(attributes.getValue(NAME_ATTRIBUTE)));
	if (profileNames.length != 0) {
		for (String profileName : profileNames) {
			OptionHelper.substVars(profileName, ic, this.context);
		}
		return this.environment != null && this.environment.acceptsProfiles(profileNames);
	}
	return false;
}
 
Example #4
Source File: SpringProfileAction.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public void end(InterpretationContext ic, String name) throws ActionException {
	this.depth--;
	if (this.depth != 0) {
		return;
	}
	ic.removeInPlayListener(this);
	verifyAndPop(ic);
	if (this.acceptsProfile) {
		addEventsToPlayer(ic);
	}
}
 
Example #5
Source File: SpringProfileAction.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
private void verifyAndPop(InterpretationContext ic) {
	Object o = ic.peekObject();
	Assert.state(o != null, "Unexpected null object on stack");
	Assert.isInstanceOf(SpringProfileAction.class, o, "logback stack error");
	Assert.state(o == this, "ProfileAction different than current one on stack");
	ic.popObject();
}
 
Example #6
Source File: LogConfigurator.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void end(InterpretationContext ec, String arg1) {
	Object o = ec.peekObject();
	if (o != className) {
		addWarn("The object on the top the of the stack is not the logreader classname pushed earlier.");
	} else {
		ec.popObject();
		Appender<?> appender = (Appender<?>) ec.peekObject();
		logReaderClassNames.put(appender.getName(), className);
		appenders.put(appender.getName(), appender);
		if (def) {
			defaultAppender = appender.getName();
		}
	}
}
 
Example #7
Source File: LogbackAccessJoranConfigurator.java    From logback-access-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void begin(InterpretationContext ic, String name, Attributes attributes) throws ActionException {
    depth++;
    if (depth != 1) {
        return;
    }
    String profiles = OptionHelper.substVars(attributes.getValue(NAME_ATTRIBUTE), ic, context);
    String[] normalizedProfiles = StringUtils.commaDelimitedListToStringArray(profiles);
    normalizedProfiles = StringUtils.trimArrayElements(normalizedProfiles);
    accepts = normalizedProfiles.length > 0 && environment.acceptsProfiles(normalizedProfiles);
    ic.addInPlayListener(this);
}
 
Example #8
Source File: LogbackAccessJoranConfigurator.java    From logback-access-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void end(InterpretationContext ic, String name) throws ActionException {
    depth--;
    if (depth != 0) {
        return;
    }
    ic.removeInPlayListener(this);
    if (accepts) {
        events.remove(0);
        events.remove(events.size() - 1);
        ic.getJoranInterpreter().getEventPlayer().addEventsDynamically(events, 1);
    }
    events.clear();
}
 
Example #9
Source File: LogbackAccessJoranConfigurator.java    From logback-access-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/** {@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);
}
 
Example #10
Source File: SpringPropertyAction.java    From super-cloudops with Apache License 2.0 4 votes vote down vote up
@Override
public void end(InterpretationContext ic, String name) throws ActionException {
}
 
Example #11
Source File: SpringProfileAction.java    From super-cloudops with Apache License 2.0 4 votes vote down vote up
private void addEventsToPlayer(InterpretationContext ic) {
	Interpreter interpreter = ic.getJoranInterpreter();
	this.events.remove(0);
	this.events.remove(this.events.size() - 1);
	interpreter.getEventPlayer().addEventsDynamically(this.events, 1);
}
 
Example #12
Source File: LogConfigurator.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void begin(InterpretationContext ec, String name, Attributes attributes) {
	className = attributes.getValue(CLASS_ATTRIBUTE);
	def = (attributes.getValue("default") != null) && attributes.getValue("default").equalsIgnoreCase("true");
	ec.pushObject(className);
}
 
Example #13
Source File: LogbackAccessJoranConfigurator.java    From logback-access-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void end(InterpretationContext ic, String name) throws ActionException {
}