24
24
import ch .qos .logback .core .model .processor .ModelHandlerException ;
25
25
import ch .qos .logback .core .model .processor .ModelInterpretationContext ;
26
26
import ch .qos .logback .core .model .processor .ResourceHandlerBase ;
27
+ import ch .qos .logback .core .spi .ContextAwarePropertyContainer ;
27
28
import ch .qos .logback .core .util .OptionHelper ;
28
29
29
30
import java .io .InputStream ;
@@ -44,6 +45,21 @@ static public PropertiesConfiguratorModelHandler makeInstance(Context context, M
44
45
45
46
@ Override
46
47
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
+
47
63
PropertiesConfiguratorModel propertyConfiguratorModel = (PropertiesConfiguratorModel ) model ;
48
64
49
65
this .optional = OptionHelper .toBoolean (propertyConfiguratorModel .getOptional (), false );
@@ -53,27 +69,27 @@ public void handle(ModelInterpretationContext mic, Model model) throws ModelHand
53
69
return ;
54
70
}
55
71
56
- InputStream in = getInputStream (mic , propertyConfiguratorModel );
57
- if (in == null ) {
72
+ InputStream in = getInputStream (capc , propertyConfiguratorModel );
73
+ if (in == null ) {
58
74
inError = true ;
59
75
return ;
60
76
}
61
77
62
- addInfo ("Reading configuration from [" + getAttribureInUse ()+ "]" );
78
+ addInfo ("Reading configuration from [" + getAttribureInUse () + "]" );
63
79
64
80
PropertiesConfigurator propertiesConfigurator = new PropertiesConfigurator ();
65
- propertiesConfigurator .setContext (mic .getContext ());
81
+ propertiesConfigurator .setContext (capc .getContext ());
66
82
try {
67
83
propertiesConfigurator .doConfigure (in );
68
84
} catch (JoranException e ) {
69
- addError ("Could not configure from " + getAttribureInUse ());
85
+ addError ("Could not configure from " + getAttribureInUse ());
70
86
throw new ModelHandlerException (e );
71
87
}
72
88
73
89
}
74
90
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 );
77
93
if (inputURL == null )
78
94
return null ;
79
95
0 commit comments