Skip to content

Commit 8bcfd9a

Browse files
committed
allow for InsertFromJNDIModelHandler to be callable from logback-tyler
Signed-off-by: Ceki Gulcu <[email protected]>
1 parent 75bee86 commit 8bcfd9a

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

logback-classic/src/main/java/ch/qos/logback/classic/model/processor/ConfigurationModelHandlerFull.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ static public ModelHandlerBase makeInstance2(Context context, ModelInterpretatio
4949

5050
@Override
5151
protected void processScanAttrib(ModelInterpretationContext mic, ConfigurationModel configurationModel) {
52-
52+
// override parent to do nothing
5353
}
5454

5555
@Override
5656
public void postHandle(ModelInterpretationContext mic, Model model) throws ModelHandlerException {
5757
ConfigurationModel configurationModel = (ConfigurationModel) model;
58+
// post handling of scan attribute works even we need to watch for included files because the main url is
59+
// set in GenericXMLConfigurator very early in the configuration process
5860
postProcessScanAttrib(mic, configurationModel);
5961
}
6062

logback-core/src/main/java/ch/qos/logback/core/model/processor/InsertFromJNDIModelHandler.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import ch.qos.logback.core.model.InsertFromJNDIModel;
99
import ch.qos.logback.core.model.Model;
1010
import ch.qos.logback.core.model.util.PropertyModelHandlerHelper;
11+
import ch.qos.logback.core.spi.ContextAwarePropertyContainer;
1112
import ch.qos.logback.core.util.JNDIUtil;
1213
import ch.qos.logback.core.util.OptionHelper;
1314

@@ -28,14 +29,22 @@ protected Class<InsertFromJNDIModel> getSupportedModelClass() {
2829

2930
@Override
3031
public void handle(ModelInterpretationContext mic, Model model) throws ModelHandlerException {
31-
int errorCount = 0;
32-
3332
InsertFromJNDIModel ifjm = (InsertFromJNDIModel) model;
33+
detachedHandle(mic, ifjm);
34+
}
3435

35-
String envEntryName = mic.subst(ifjm.getEnvEntryName());
36-
String asKey = mic.subst(ifjm.getAs());
36+
/**
37+
*
38+
* @param capc
39+
* @param ifjm
40+
* @since 1.5.11
41+
*/
42+
public void detachedHandle(ContextAwarePropertyContainer capc, InsertFromJNDIModel ifjm) {
43+
int errorCount = 0;
44+
String envEntryName = capc.subst(ifjm.getEnvEntryName());
45+
String asKey = capc.subst(ifjm.getAs());
3746

38-
String scopeStr = mic.subst(ifjm.getScopeStr());
47+
String scopeStr = capc.subst(ifjm.getScopeStr());
3948
Scope scope = ActionUtil.stringToScope(scopeStr);
4049

4150
String envEntryValue;
@@ -61,7 +70,7 @@ public void handle(ModelInterpretationContext mic, Model model) throws ModelHand
6170
addError("[" + envEntryName + "] has null or empty value");
6271
} else {
6372
addInfo("Setting variable [" + asKey + "] to [" + envEntryValue + "] in [" + scope + "] scope");
64-
PropertyModelHandlerHelper.setProperty(mic, asKey, envEntryValue, scope);
73+
PropertyModelHandlerHelper.setProperty(capc, asKey, envEntryValue, scope);
6574
}
6675
} catch (NamingException e) {
6776
addError("Failed to lookup JNDI env-entry [" + envEntryName + "]");

0 commit comments

Comments
 (0)