Search in sources :

Example 1 with SaxEventRecorder

use of ch.qos.logback.core.joran.event.SaxEventRecorder in project sling by apache.

the class OsgiInternalAction method begin.

@SuppressWarnings("unchecked")
@Override
public void begin(InterpretationContext ec, String name, Attributes attributes) throws ActionException {
    ec.addInPlayListener(new ConfigCompleteListener(ec));
    populateSubstitutionProperties(ec);
    // TO CHECK Should we add the config fragment at end
    final Collection<ConfigSourceInfo> providers = getFragmentProviders();
    List<SaxEvent> consolidatedEventList = new ArrayList<SaxEvent>();
    for (ConfigSourceInfo cp : providers) {
        InputSource is = cp.getConfigProvider().getConfigSource();
        try {
            SaxEventRecorder recorder = new SaxEventRecorder(context);
            recorder.recordEvents(is);
            // remove the <included> tag from the beginning and </included>
            // from the end
            trimHeadAndTail(recorder);
            consolidatedEventList.addAll(recorder.getSaxEventList());
        } catch (JoranException e) {
            addError("Error while parsing xml obtained from  [" + cp + "]", e);
        } finally {
            Util.close(is);
        }
    }
    // offset = 2, because we need to get past this element as well as the
    // end element
    ec.getJoranInterpreter().getEventPlayer().addEventsDynamically(consolidatedEventList, 2);
}
Also used : InputSource(org.xml.sax.InputSource) ConfigSourceInfo(org.apache.sling.commons.log.logback.internal.ConfigSourceTracker.ConfigSourceInfo) SaxEventRecorder(ch.qos.logback.core.joran.event.SaxEventRecorder) JoranException(ch.qos.logback.core.joran.spi.JoranException) SaxEvent(ch.qos.logback.core.joran.event.SaxEvent) ArrayList(java.util.ArrayList)

Aggregations

SaxEvent (ch.qos.logback.core.joran.event.SaxEvent)1 SaxEventRecorder (ch.qos.logback.core.joran.event.SaxEventRecorder)1 JoranException (ch.qos.logback.core.joran.spi.JoranException)1 ArrayList (java.util.ArrayList)1 ConfigSourceInfo (org.apache.sling.commons.log.logback.internal.ConfigSourceTracker.ConfigSourceInfo)1 InputSource (org.xml.sax.InputSource)1