Skip to content

Commit ba8cd26

Browse files
committed
joran.spi.Pattern split into spi.ElementPath and spi.ElementSelector
1 parent 10d4757 commit ba8cd26

41 files changed

Lines changed: 502 additions & 538 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

logback-access/src/main/java/ch/qos/logback/access/joran/JoranConfigurator.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import ch.qos.logback.core.joran.conditional.IfAction;
3232
import ch.qos.logback.core.joran.conditional.ThenAction;
3333
import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
34-
import ch.qos.logback.core.joran.spi.Pattern;
34+
import ch.qos.logback.core.joran.spi.ElementSelector;
3535
import ch.qos.logback.core.joran.spi.RuleStore;
3636
import ch.qos.logback.core.net.ssl.SSLNestedComponentRegistryRules;
3737

@@ -48,22 +48,22 @@ public class JoranConfigurator extends JoranConfiguratorBase {
4848
public void addInstanceRules(RuleStore rs) {
4949
super.addInstanceRules(rs);
5050

51-
rs.addRule(new Pattern("configuration"), new ConfigurationAction());
52-
rs.addRule(new Pattern("configuration/appender-ref"), new AppenderRefAction());
51+
rs.addRule(new ElementSelector("configuration"), new ConfigurationAction());
52+
rs.addRule(new ElementSelector("configuration/appender-ref"), new AppenderRefAction());
5353

54-
rs.addRule(new Pattern("configuration/appender/sift"), new SiftAction());
55-
rs.addRule(new Pattern("configuration/appender/sift/*"), new NOPAction());
54+
rs.addRule(new ElementSelector("configuration/appender/sift"), new SiftAction());
55+
rs.addRule(new ElementSelector("configuration/appender/sift/*"), new NOPAction());
5656

57-
rs.addRule(new Pattern("configuration/evaluator"), new EvaluatorAction());
57+
rs.addRule(new ElementSelector("configuration/evaluator"), new EvaluatorAction());
5858

5959
// add if-then-else support
60-
rs.addRule(new Pattern("*/if"), new IfAction());
61-
rs.addRule(new Pattern("*/if/then"), new ThenAction());
62-
rs.addRule(new Pattern("*/if/then/*"), new NOPAction());
63-
rs.addRule(new Pattern("*/if/else"), new ElseAction());
64-
rs.addRule(new Pattern("*/if/else/*"), new NOPAction());
60+
rs.addRule(new ElementSelector("*/if"), new IfAction());
61+
rs.addRule(new ElementSelector("*/if/then"), new ThenAction());
62+
rs.addRule(new ElementSelector("*/if/then/*"), new NOPAction());
63+
rs.addRule(new ElementSelector("*/if/else"), new ElseAction());
64+
rs.addRule(new ElementSelector("*/if/else/*"), new NOPAction());
6565

66-
rs.addRule(new Pattern("configuration/include"), new IncludeAction());
66+
rs.addRule(new ElementSelector("configuration/include"), new IncludeAction());
6767
}
6868

6969
@Override

logback-access/src/main/java/ch/qos/logback/access/sift/SiftingJoranConfigurator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import ch.qos.logback.core.Appender;
2222
import ch.qos.logback.core.joran.action.ActionConst;
2323
import ch.qos.logback.core.joran.action.AppenderAction;
24-
import ch.qos.logback.core.joran.spi.Pattern;
24+
import ch.qos.logback.core.joran.spi.ElementSelector;
2525
import ch.qos.logback.core.joran.spi.RuleStore;
2626
import ch.qos.logback.core.sift.SiftingJoranConfiguratorBase;
2727

@@ -35,13 +35,13 @@ public class SiftingJoranConfigurator extends
3535
}
3636

3737
@Override
38-
protected Pattern initialPattern() {
39-
return new Pattern("configuration");
38+
protected ElementSelector initialPattern() {
39+
return new ElementSelector("configuration");
4040
}
4141

4242
@Override
4343
protected void addInstanceRules(RuleStore rs) {
44-
rs.addRule(new Pattern("configuration/appender"), new AppenderAction());
44+
rs.addRule(new ElementSelector("configuration/appender"), new AppenderAction());
4545
}
4646

4747
@Override

logback-classic/src/main/java/ch/qos/logback/classic/joran/JoranConfigurator.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import ch.qos.logback.core.joran.conditional.IfAction;
2626
import ch.qos.logback.core.joran.conditional.ThenAction;
2727
import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
28-
import ch.qos.logback.core.joran.spi.Pattern;
28+
import ch.qos.logback.core.joran.spi.ElementSelector;
2929
import ch.qos.logback.core.joran.spi.RuleStore;
3030

3131
/**
32-
* This JoranConfiguratorclass adds rules specific to logback-classic.
32+
* JoranConfigurator class adds rules specific to logback-classic.
3333
*
3434
* @author Ceki Gülcü
3535
*/
@@ -40,49 +40,49 @@ public void addInstanceRules(RuleStore rs) {
4040
// parent rules already added
4141
super.addInstanceRules(rs);
4242

43-
rs.addRule(new Pattern("configuration"), new ConfigurationAction());
43+
rs.addRule(new ElementSelector("configuration"), new ConfigurationAction());
4444

45-
rs.addRule(new Pattern("configuration/contextName"),
45+
rs.addRule(new ElementSelector("configuration/contextName"),
4646
new ContextNameAction());
47-
rs.addRule(new Pattern("configuration/contextListener"),
47+
rs.addRule(new ElementSelector("configuration/contextListener"),
4848
new LoggerContextListenerAction());
49-
rs.addRule(new Pattern("configuration/insertFromJNDI"),
49+
rs.addRule(new ElementSelector("configuration/insertFromJNDI"),
5050
new InsertFromJNDIAction());
51-
rs.addRule(new Pattern("configuration/evaluator"), new EvaluatorAction());
51+
rs.addRule(new ElementSelector("configuration/evaluator"), new EvaluatorAction());
5252

53-
rs.addRule(new Pattern("configuration/appender/sift"), new SiftAction());
54-
rs.addRule(new Pattern("configuration/appender/sift/*"), new NOPAction());
53+
rs.addRule(new ElementSelector("configuration/appender/sift"), new SiftAction());
54+
rs.addRule(new ElementSelector("configuration/appender/sift/*"), new NOPAction());
5555

56-
rs.addRule(new Pattern("configuration/logger"), new LoggerAction());
57-
rs.addRule(new Pattern("configuration/logger/level"), new LevelAction());
56+
rs.addRule(new ElementSelector("configuration/logger"), new LoggerAction());
57+
rs.addRule(new ElementSelector("configuration/logger/level"), new LevelAction());
5858

59-
rs.addRule(new Pattern("configuration/root"), new RootLoggerAction());
60-
rs.addRule(new Pattern("configuration/root/level"), new LevelAction());
61-
rs.addRule(new Pattern("configuration/logger/appender-ref"),
59+
rs.addRule(new ElementSelector("configuration/root"), new RootLoggerAction());
60+
rs.addRule(new ElementSelector("configuration/root/level"), new LevelAction());
61+
rs.addRule(new ElementSelector("configuration/logger/appender-ref"),
6262
new AppenderRefAction());
63-
rs.addRule(new Pattern("configuration/root/appender-ref"),
63+
rs.addRule(new ElementSelector("configuration/root/appender-ref"),
6464
new AppenderRefAction());
6565

6666
// add if-then-else support
67-
rs.addRule(new Pattern("*/if"), new IfAction());
68-
rs.addRule(new Pattern("*/if/then"), new ThenAction());
69-
rs.addRule(new Pattern("*/if/then/*"), new NOPAction());
70-
rs.addRule(new Pattern("*/if/else"), new ElseAction());
71-
rs.addRule(new Pattern("*/if/else/*"), new NOPAction());
67+
rs.addRule(new ElementSelector("*/if"), new IfAction());
68+
rs.addRule(new ElementSelector("*/if/then"), new ThenAction());
69+
rs.addRule(new ElementSelector("*/if/then/*"), new NOPAction());
70+
rs.addRule(new ElementSelector("*/if/else"), new ElseAction());
71+
rs.addRule(new ElementSelector("*/if/else/*"), new NOPAction());
7272

7373
// add jmxConfigurator only if we have JMX available.
7474
// If running under JDK 1.4 (retrotranslateed logback) then we
7575
// might not have JMX.
7676
if (PlatformInfo.hasJMXObjectName()) {
77-
rs.addRule(new Pattern("configuration/jmxConfigurator"),
77+
rs.addRule(new ElementSelector("configuration/jmxConfigurator"),
7878
new JMXConfiguratorAction());
7979
}
80-
rs.addRule(new Pattern("configuration/include"), new IncludeAction());
80+
rs.addRule(new ElementSelector("configuration/include"), new IncludeAction());
8181

82-
rs.addRule(new Pattern("configuration/consolePlugin"),
82+
rs.addRule(new ElementSelector("configuration/consolePlugin"),
8383
new ConsolePluginAction());
8484

85-
rs.addRule(new Pattern("configuration/receiver"),
85+
rs.addRule(new ElementSelector("configuration/receiver"),
8686
new ReceiverAction());
8787

8888
}

logback-classic/src/main/java/ch/qos/logback/classic/sift/SiftingJoranConfigurator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import ch.qos.logback.core.joran.action.ActionConst;
2424
import ch.qos.logback.core.joran.action.AppenderAction;
2525
import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
26-
import ch.qos.logback.core.joran.spi.Pattern;
26+
import ch.qos.logback.core.joran.spi.ElementSelector;
2727
import ch.qos.logback.core.joran.spi.RuleStore;
2828
import ch.qos.logback.core.sift.SiftingJoranConfiguratorBase;
2929

@@ -35,14 +35,14 @@ public class SiftingJoranConfigurator extends SiftingJoranConfiguratorBase<ILog
3535
}
3636

3737
@Override
38-
protected Pattern initialPattern() {
39-
return new Pattern("configuration");
38+
protected ElementSelector initialPattern() {
39+
return new ElementSelector("configuration");
4040
}
4141

4242
@Override
4343
protected void addInstanceRules(RuleStore rs) {
4444
super.addInstanceRules(rs);
45-
rs.addRule(new Pattern("configuration/appender"), new AppenderAction());
45+
rs.addRule(new ElementSelector("configuration/appender"), new AppenderAction());
4646
}
4747

4848

logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ protected void addDefaultNestedComponentRegistryRules(DefaultNestedComponentRegi
107107

108108
}
109109

110-
protected Pattern initialPattern() {
111-
return new Pattern();
110+
protected ElementSelector initialPattern() {
111+
return new ElementSelector();
112112
}
113113

114114
protected void buildInterpreter() {

logback-core/src/main/java/ch/qos/logback/core/joran/JoranConfiguratorBase.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import ch.qos.logback.core.joran.action.PropertyAction;
3131
import ch.qos.logback.core.joran.action.StatusListenerAction;
3232
import ch.qos.logback.core.joran.action.TimestampAction;
33+
import ch.qos.logback.core.joran.spi.ElementSelector;
3334
import ch.qos.logback.core.joran.spi.InterpretationContext;
3435
import ch.qos.logback.core.joran.spi.Interpreter;
35-
import ch.qos.logback.core.joran.spi.Pattern;
3636
import ch.qos.logback.core.joran.spi.RuleStore;
3737

3838
// Based on 310985 revision 310985 as attested by http://tinyurl.com/8njps
@@ -58,32 +58,32 @@ public List getErrorList() {
5858
protected void addInstanceRules(RuleStore rs) {
5959

6060
// is "configuration/variable" referenced in the docs?
61-
rs.addRule(new Pattern("configuration/variable"), new PropertyAction());
62-
rs.addRule(new Pattern("configuration/property"), new PropertyAction());
61+
rs.addRule(new ElementSelector("configuration/variable"), new PropertyAction());
62+
rs.addRule(new ElementSelector("configuration/property"), new PropertyAction());
6363

64-
rs.addRule(new Pattern("configuration/substitutionProperty"),
64+
rs.addRule(new ElementSelector("configuration/substitutionProperty"),
6565
new PropertyAction());
6666

67-
rs.addRule(new Pattern("configuration/timestamp"), new TimestampAction());
67+
rs.addRule(new ElementSelector("configuration/timestamp"), new TimestampAction());
6868

69-
rs.addRule(new Pattern("configuration/define"), new DefinePropertyAction());
69+
rs.addRule(new ElementSelector("configuration/define"), new DefinePropertyAction());
7070

7171
// the contextProperty pattern is deprecated. It is undocumented
7272
// and will be dropped in future versions of logback
73-
rs.addRule(new Pattern("configuration/contextProperty"),
73+
rs.addRule(new ElementSelector("configuration/contextProperty"),
7474
new ContextPropertyAction());
7575

76-
rs.addRule(new Pattern("configuration/conversionRule"),
76+
rs.addRule(new ElementSelector("configuration/conversionRule"),
7777
new ConversionRuleAction());
7878

79-
rs.addRule(new Pattern("configuration/statusListener"),
79+
rs.addRule(new ElementSelector("configuration/statusListener"),
8080
new StatusListenerAction());
8181

82-
rs.addRule(new Pattern("configuration/appender"), new AppenderAction());
83-
rs.addRule(new Pattern("configuration/appender/appender-ref"),
82+
rs.addRule(new ElementSelector("configuration/appender"), new AppenderAction());
83+
rs.addRule(new ElementSelector("configuration/appender/appender-ref"),
8484
new AppenderRefAction());
85-
rs.addRule(new Pattern("configuration/newRule"), new NewRuleAction());
86-
rs.addRule(new Pattern("*/param"), new ParamAction());
85+
rs.addRule(new ElementSelector("configuration/newRule"), new NewRuleAction());
86+
rs.addRule(new ElementSelector("*/param"), new ParamAction());
8787
}
8888

8989
@Override

logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public abstract class Action extends ContextAwareBase {
5050

5151
/**
5252
* Called when the parser encounters an element matching a
53-
* {@link ch.qos.logback.core.joran.spi.Pattern Pattern}.
53+
* {@link ch.qos.logback.core.joran.spi.ElementSelector Pattern}.
5454
*/
5555
public abstract void begin(InterpretationContext ic, String name,
5656
Attributes attributes) throws ActionException;

logback-core/src/main/java/ch/qos/logback/core/joran/action/ImplicitAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
package ch.qos.logback.core.joran.action;
1515

1616

17+
import ch.qos.logback.core.joran.spi.ElementPath;
1718
import org.xml.sax.Attributes;
1819

1920
import ch.qos.logback.core.joran.spi.InterpretationContext;
20-
import ch.qos.logback.core.joran.spi.Pattern;
2121

2222

2323
/**
@@ -34,14 +34,14 @@ public abstract class ImplicitAction extends Action {
3434
/**
3535
* Check whether this implicit action is appropriate in the current context.
3636
*
37-
* @param currentPattern This pattern contains the tag name of the current
37+
* @param currentElementPath This pattern contains the tag name of the current
3838
* element being parsed at the top of the stack.
3939
* @param attributes The attributes of the current element to process.
4040
* @param ec
4141
* @return Whether the implicit action is applicable in the current context
4242
*/
4343
public abstract boolean isApplicable(
44-
Pattern currentPattern, Attributes attributes, InterpretationContext ec);
44+
ElementPath currentElementPath, Attributes attributes, InterpretationContext ec);
4545

4646

4747
}

logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
import java.util.Stack;
1717

18+
import ch.qos.logback.core.joran.spi.ElementPath;
1819
import org.xml.sax.Attributes;
1920

2021
import ch.qos.logback.core.joran.spi.InterpretationContext;
21-
import ch.qos.logback.core.joran.spi.Pattern;
2222
import ch.qos.logback.core.joran.util.PropertySetter;
2323
import ch.qos.logback.core.util.AggregationType;
2424

@@ -40,11 +40,11 @@ public class NestedBasicPropertyIA extends ImplicitAction {
4040
// be followed by the corresponding pop.
4141
Stack<IADataForBasicProperty> actionDataStack = new Stack<IADataForBasicProperty>();
4242

43-
public boolean isApplicable(Pattern pattern, Attributes attributes,
43+
public boolean isApplicable(ElementPath elementPath, Attributes attributes,
4444
InterpretationContext ec) {
4545
// System.out.println("in NestedSimplePropertyIA.isApplicable [" + pattern +
4646
// "]");
47-
String nestedElementTagName = pattern.peekLast();
47+
String nestedElementTagName = elementPath.peekLast();
4848

4949
// no point in attempting if there is no parent object
5050
if (ec.isEmpty()) {

logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
import java.util.Stack;
1717

18+
import ch.qos.logback.core.joran.spi.ElementPath;
1819
import org.xml.sax.Attributes;
1920

2021
import ch.qos.logback.core.joran.spi.InterpretationContext;
2122
import ch.qos.logback.core.joran.spi.NoAutoStartUtil;
22-
import ch.qos.logback.core.joran.spi.Pattern;
2323
import ch.qos.logback.core.joran.util.PropertySetter;
2424
import ch.qos.logback.core.spi.ContextAware;
2525
import ch.qos.logback.core.spi.LifeCycle;
@@ -44,10 +44,10 @@ public class NestedComplexPropertyIA extends ImplicitAction {
4444
// be followed by a corresponding pop.
4545
Stack<IADataForComplexProperty> actionDataStack = new Stack<IADataForComplexProperty>();
4646

47-
public boolean isApplicable(Pattern pattern, Attributes attributes,
47+
public boolean isApplicable(ElementPath elementPath, Attributes attributes,
4848
InterpretationContext ic) {
4949

50-
String nestedElementTagName = pattern.peekLast();
50+
String nestedElementTagName = elementPath.peekLast();
5151

5252
// calling ic.peekObject with an empty stack will throw an exception
5353
if (ic.isEmpty()) {

0 commit comments

Comments
 (0)