1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package ch.qos.logback.classic.joran;
16
17 import ch.qos.logback.classic.LoggerContext;
18 import ch.qos.logback.core.contention.AbstractMultiThreadedHarness;
19 import ch.qos.logback.core.status.InfoStatus;
20
21 import java.util.concurrent.CountDownLatch;
22
23 class ReconfigureOnChangeTaskHarness extends AbstractMultiThreadedHarness {
24
25 private final LoggerContext loggerContext;
26
27 private final CountDownLatch countDownLatch;
28
29 ReconfigureOnChangeTaskHarness(LoggerContext loggerContext, int aChangeCountLimit) {
30 this.loggerContext = loggerContext;
31 this.countDownLatch = new CountDownLatch(aChangeCountLimit);
32 ChangeDetectedListener cdl = new ChangeDetectedListener(countDownLatch);
33 loggerContext.addConfigurationEventListener(cdl);
34 }
35
36 public void waitUntilEndCondition() throws InterruptedException {
37
38 String classname = this.getClass().getSimpleName();
39
40 loggerContext.getStatusManager()
41 .add(new InfoStatus("Entering " + classname + ".waitUntilEndCondition()", this));
42 countDownLatch.await();
43 loggerContext.getStatusManager()
44 .add(new InfoStatus("*****Exiting " + classname + ".waitUntilEndCondition()", this));
45 }
46
47 }