01: /*
02: * LogPipeManager.java
03: *
04: * Created on 24. November 2003, 21:04
05: */
06:
07: package org.jzonic.jlo;
08:
09: import org.jzonic.jlo.processor.LogProcessor;
10: import org.jzonic.jlo.processor.LogProcessorFactory;
11:
12: import java.util.Vector;
13:
14: /**
15: * This class manager all pipes. The Logger will call
16: * the processLogRequest and send over the current logrequest.
17: * If there are any pipes then the LogPipeManager will send them
18: * to the LogProcessor. The request can be filtered by a LogFilter.
19: *
20: * @author Andreas Mecky andreasmecky@yahoo.de
21: */
22: public class LogPipeManager {
23:
24: private static final LogProcessor processor = LogProcessorFactory
25: .getLogProcessor();
26: private static LogPipeManager pipeManager = new LogPipeManager();
27: private Vector pipes;
28:
29: private LogPipeManager() {
30: pipes = new Vector();
31: }
32:
33: public static LogPipeManager getInstance() {
34: return pipeManager;
35: }
36:
37: public void addLogPipe(LogPipe pipe) {
38: pipes.add(pipe);
39: }
40:
41: public boolean hasPipes() {
42: if (pipes.size() > 0) {
43: return true;
44: }
45: return false;
46: }
47:
48: public void processLogRequest(LogRecord record) {
49: for (int i = 0; i < pipes.size(); i++) {
50: LogPipe pipe = (LogPipe) pipes.get(i);
51: if (pipe.getFilter() != null) {
52: // TODO: when the filter is done then call it here
53: } else {
54: processor.processEvent(pipe.getGenerator(), record);
55: }
56: }
57: }
58:
59: }
|