org.apache.juli.logging.ch.qos.logback.core.model.processor.ChainedModelFilter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tomcat85-slf4j-logback Show documentation
Show all versions of tomcat85-slf4j-logback Show documentation
Tomcat85 Slf4j Logback Integration
package org.apache.juli.logging.ch.qos.logback.core.model.processor;
import java.util.ArrayList;
import java.util.List;
import org.apache.juli.logging.ch.qos.logback.core.model.Model;
import org.apache.juli.logging.ch.qos.logback.core.spi.FilterReply;
public class ChainedModelFilter implements ModelFilter {
List modelFilters = new ArrayList<>();
public ChainedModelFilter() {
}
static public ChainedModelFilter newInstance() {
return new ChainedModelFilter();
}
public ChainedModelFilter allow(Class allowedType) {
modelFilters.add(new AllowModelFilter(allowedType));
return this;
}
public ChainedModelFilter deny(Class allowedType) {
modelFilters.add(new DenyModelFilter(allowedType));
return this;
}
public ChainedModelFilter denyAll() {
modelFilters.add(new DenyAllModelFilter());
return this;
}
public ChainedModelFilter allowAll() {
modelFilters.add(new AllowAllModelFilter());
return this;
}
@Override
public FilterReply decide(Model model) {
for (ModelFilter modelFilter : modelFilters) {
FilterReply reply = modelFilter.decide(model);
switch (reply) {
case ACCEPT:
case DENY:
return reply;
case NEUTRAL:
// next
}
}
return FilterReply.NEUTRAL;
}
}