2424import ch .qos .logback .core .model .processor .ModelHandlerException ;
2525import ch .qos .logback .core .model .processor .ModelInterpretationContext ;
2626import ch .qos .logback .core .model .processor .ResourceHandlerBase ;
27+ import ch .qos .logback .core .spi .ContextAwarePropertyContainer ;
2728import ch .qos .logback .core .util .OptionHelper ;
2829
2930import java .io .InputStream ;
@@ -44,6 +45,21 @@ static public PropertiesConfiguratorModelHandler makeInstance(Context context, M
4445
4546 @ Override
4647 public void handle (ModelInterpretationContext mic , Model model ) throws ModelHandlerException {
48+ detachedHandle (mic , model );
49+ }
50+
51+ /**
52+ *
53+ * Used by {@link #handle(ModelInterpretationContext, Model)} as well as logback-tyler. Note the widening of the
54+ * base from {@link ModelInterpretationContext} to {@link ContextAwarePropertyContainer}.
55+ *
56+ * @param capc
57+ * @param model
58+ * @throws ModelHandlerException
59+ * @since 1.5.10
60+ */
61+ public void detachedHandle (ContextAwarePropertyContainer capc , Model model ) throws ModelHandlerException {
62+
4763 PropertiesConfiguratorModel propertyConfiguratorModel = (PropertiesConfiguratorModel ) model ;
4864
4965 this .optional = OptionHelper .toBoolean (propertyConfiguratorModel .getOptional (), false );
@@ -53,27 +69,27 @@ public void handle(ModelInterpretationContext mic, Model model) throws ModelHand
5369 return ;
5470 }
5571
56- InputStream in = getInputStream (mic , propertyConfiguratorModel );
57- if (in == null ) {
72+ InputStream in = getInputStream (capc , propertyConfiguratorModel );
73+ if (in == null ) {
5874 inError = true ;
5975 return ;
6076 }
6177
62- addInfo ("Reading configuration from [" + getAttribureInUse ()+ "]" );
78+ addInfo ("Reading configuration from [" + getAttribureInUse () + "]" );
6379
6480 PropertiesConfigurator propertiesConfigurator = new PropertiesConfigurator ();
65- propertiesConfigurator .setContext (mic .getContext ());
81+ propertiesConfigurator .setContext (capc .getContext ());
6682 try {
6783 propertiesConfigurator .doConfigure (in );
6884 } catch (JoranException e ) {
69- addError ("Could not configure from " + getAttribureInUse ());
85+ addError ("Could not configure from " + getAttribureInUse ());
7086 throw new ModelHandlerException (e );
7187 }
7288
7389 }
7490
75- protected InputStream getInputStream (ModelInterpretationContext mic , ResourceModel resourceModel ) {
76- URL inputURL = getInputURL (mic , resourceModel );
91+ protected InputStream getInputStream (ContextAwarePropertyContainer capc , ResourceModel resourceModel ) {
92+ URL inputURL = getInputURL (capc , resourceModel );
7793 if (inputURL == null )
7894 return null ;
7995
0 commit comments