....This means that even if not "added" to the StatusManager, the "OnConsoleStatusListener" will print its retrospective ...
Change of plan:
Add a boolean to "OnPrintStreamStatusListenerBase" that says whether the "retrospective" should be printed on "start()",
and check its value in "start()":
Then BasicStatusManager.addIt() is coded as follows:
-----------
public void add(StatusListener listener) {
if (listener != null) {
synchronized (statusListenerListLock) {
boolean addIt = true;
// Check that there is no OnConsoleStatusListener already
// If tere is not, start it (calling Lifecycle.start()) before adding it
if (listener instanceof OnConsoleStatusListener) {
for (StatusListener cur : statusListenerList) {
if (cur instanceof OnConsoleStatusListener) {
addIt = false; break;
}
}
// always "start" but only "print retrospective" if "addIt"
OnConsoleStatusListener ocl = (OnConsoleStatusListener) listener;
ocl.setPrintRetrospectiveOnStart(addIt);
ocl.start();
}
if (addIt) { statusListenerList.add(listener); }
}
}
}
1) at the start of SAX Event "configuration" with call stack:
JoranConfigurator.doConfigure(URL)
JoranConfigurator.doConfigure(InputStream)
JoranConfigurator.doConfigure(InputSource)
JoranConfigurator.doConfigure(List<SaxEvent>)
EventPlayer.play(List<SaxEvent>)
Interpreter.startElement(StartEvent)
Interpreter.startElement(String, String, String, Attributes)
Interpreter.callBeginAction(List, String, Attributes)
ConfigurationAction.begin(InterpretationContext, String, Attributes)
OnConsoleStatusListener.addNewInstanceToContext(Context)
BasicStatusManager.add(StatusListener) --- which due to the modification above calls...
OnConsoleStatusListener.start()
OnConsoleStatusListener(OnPrintStreamStatusListenerBase).start()
2) at the *end* of SAX event "statusListener" because "OnConsoleStatusListener" implements "LifeCycle", with call stack:
JoranConfigurator.doConfigure(URL)
JoranConfigurator.doConfigure(InputStream)
JoranConfigurator.doConfigure(InputSource)
JoranConfigurator.doConfigure(List<SaxEvent>)
EventPlayer.play(List<SaxEvent>)
Interpreter.endElement(StartEvent)
Interpreter.endElement(String, String, String)
Interpreter.callEndAction(List, String)
StatusListenerAction.end(InterpretationContext, String) -- "if (statusListener instanceof LifeCycle) { ((LifeCycle) statusListener).start(); }"
OnConsoleStatusListener.start()
OnConsoleStatusListener(OnPrintStreamStatusListenerBase).start()
....This means that even if not "added" to the StatusManager, the "OnConsoleStatusListener" will print its retrospective ...
Change of plan:
Add a boolean to "OnPrintStreamStatusListenerBase" that says whether the "retrospective" should be printed on "start()",
and check its value in "start()":
-----------
abstract class OnPrintStreamStatusListenerBase {
private boolean printRetrospectiveOnStart = true;
public void setPrintRetrospectiveOnStart(boolean x) { printRetrospectiveOnStart = x; }
public void start() { isStarted = true; if (retrospective > 0 && printRetrospectiveOnStart) { retrospectivePrint(); } }
----------
Then BasicStatusManager.addIt() is coded as follows:
-----------
public void add(StatusListener listener) {
if (listener != null) {
synchronized (statusListenerListLock) {
boolean addIt = true;
// Check that there is no OnConsoleStatusListener already
// If tere is not, start it (calling Lifecycle.start()) before adding it
if (listener instanceof OnConsoleStatusListener) {
for (StatusListener cur : statusListenerList) {
if (cur instanceof OnConsoleStatusListener) {
addIt = false; break;
}
}
// always "start" but only "print retrospective" if "addIt"
OnConsoleStatusListener ocl = (OnConsoleStatusListener) listener;
ocl.setPrintRetrospectiveOnStart(addIt);
ocl.start();
}
if (addIt) { statusListenerList.add(listener); }
}
}
}
-----------