01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02 *
03 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
04 *
05 * "Hilbert II" is free software; you can redistribute
06 * it and/or modify it under the terms of the GNU General Public
07 * License as published by the Free Software Foundation; either
08 * version 2 of the License, or (at your option) any later version.
09 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16 package org.qedeq.kernel.bo.log;
17
18 import java.io.PrintStream;
19
20 import org.qedeq.base.utility.DateUtility;
21 import org.qedeq.kernel.bo.common.QedeqBo;
22
23 /**
24 * Listener that writes events to a stream.
25 *
26 * @author Michael Meyling
27 */
28 public class DefaultModuleEventListener implements ModuleEventListener {
29
30 /** Stream for output. */
31 private PrintStream out = System.out;
32
33 /**
34 * Constructor.
35 */
36 public DefaultModuleEventListener() {
37 this(System.out);
38 }
39
40 /**
41 * Constructor.
42 *
43 * @param stream Print to this stream.
44 */
45 public DefaultModuleEventListener(final PrintStream stream) {
46 this.out = stream;
47 }
48
49 /**
50 * Set output stream.
51 *
52 * @param stream Output stream.
53 */
54 public final void setPrintStream(final PrintStream stream) {
55 this.out = stream;
56 }
57
58 public void addModule(final QedeqBo prop) {
59 out.println(DateUtility.getTimestamp() + " Module added. "
60 + prop.getStateDescription() + "\n\t" + prop.getUrl());
61 }
62
63 public void stateChanged(final QedeqBo prop) {
64 out.println(DateUtility.getTimestamp() + " Module state changed. "
65 + prop.getStateDescription() + "\n\t" + prop.getUrl());
66 }
67
68 public void removeModule(final QedeqBo prop) {
69 out.println(DateUtility.getTimestamp() + " Module removed. "
70 + prop.getStateDescription() + "\n\t" + prop.getUrl());
71 }
72
73 }
|