From 8bcfd9a09af71dfe505026ff4c3be990db031d45 Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Tue, 15 Oct 2024 12:14:26 +0200 Subject: [PATCH] allow for InsertFromJNDIModelHandler to be callable from logback-tyler Signed-off-by: Ceki Gulcu --- .../ConfigurationModelHandlerFull.java | 4 +++- .../processor/InsertFromJNDIModelHandler.java | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/model/processor/ConfigurationModelHandlerFull.java b/logback-classic/src/main/java/ch/qos/logback/classic/model/processor/ConfigurationModelHandlerFull.java index 90a4c50340..749c92b872 100755 --- a/logback-classic/src/main/java/ch/qos/logback/classic/model/processor/ConfigurationModelHandlerFull.java +++ b/logback-classic/src/main/java/ch/qos/logback/classic/model/processor/ConfigurationModelHandlerFull.java @@ -49,12 +49,14 @@ static public ModelHandlerBase makeInstance2(Context context, ModelInterpretatio @Override protected void processScanAttrib(ModelInterpretationContext mic, ConfigurationModel configurationModel) { - + // override parent to do nothing } @Override public void postHandle(ModelInterpretationContext mic, Model model) throws ModelHandlerException { ConfigurationModel configurationModel = (ConfigurationModel) model; + // post handling of scan attribute works even we need to watch for included files because the main url is + // set in GenericXMLConfigurator very early in the configuration process postProcessScanAttrib(mic, configurationModel); } diff --git a/logback-core/src/main/java/ch/qos/logback/core/model/processor/InsertFromJNDIModelHandler.java b/logback-core/src/main/java/ch/qos/logback/core/model/processor/InsertFromJNDIModelHandler.java index 24a8740d31..febe6c1773 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/model/processor/InsertFromJNDIModelHandler.java +++ b/logback-core/src/main/java/ch/qos/logback/core/model/processor/InsertFromJNDIModelHandler.java @@ -8,6 +8,7 @@ import ch.qos.logback.core.model.InsertFromJNDIModel; import ch.qos.logback.core.model.Model; import ch.qos.logback.core.model.util.PropertyModelHandlerHelper; +import ch.qos.logback.core.spi.ContextAwarePropertyContainer; import ch.qos.logback.core.util.JNDIUtil; import ch.qos.logback.core.util.OptionHelper; @@ -28,14 +29,22 @@ protected Class getSupportedModelClass() { @Override public void handle(ModelInterpretationContext mic, Model model) throws ModelHandlerException { - int errorCount = 0; - InsertFromJNDIModel ifjm = (InsertFromJNDIModel) model; + detachedHandle(mic, ifjm); + } - String envEntryName = mic.subst(ifjm.getEnvEntryName()); - String asKey = mic.subst(ifjm.getAs()); + /** + * + * @param capc + * @param ifjm + * @since 1.5.11 + */ + public void detachedHandle(ContextAwarePropertyContainer capc, InsertFromJNDIModel ifjm) { + int errorCount = 0; + String envEntryName = capc.subst(ifjm.getEnvEntryName()); + String asKey = capc.subst(ifjm.getAs()); - String scopeStr = mic.subst(ifjm.getScopeStr()); + String scopeStr = capc.subst(ifjm.getScopeStr()); Scope scope = ActionUtil.stringToScope(scopeStr); String envEntryValue; @@ -61,7 +70,7 @@ public void handle(ModelInterpretationContext mic, Model model) throws ModelHand addError("[" + envEntryName + "] has null or empty value"); } else { addInfo("Setting variable [" + asKey + "] to [" + envEntryValue + "] in [" + scope + "] scope"); - PropertyModelHandlerHelper.setProperty(mic, asKey, envEntryValue, scope); + PropertyModelHandlerHelper.setProperty(capc, asKey, envEntryValue, scope); } } catch (NamingException e) { addError("Failed to lookup JNDI env-entry [" + envEntryName + "]");