KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > LogPipeManager


1 /*
2  * LogPipeManager.java
3  *
4  * Created on 24. November 2003, 21:04
5  */

6
7 package org.jzonic.jlo;
8
9 import org.jzonic.jlo.processor.LogProcessor;
10 import org.jzonic.jlo.processor.LogProcessorFactory;
11
12 import java.util.Vector JavaDoc;
13 /**
14  * This class manager all pipes. The Logger will call
15  * the processLogRequest and send over the current logrequest.
16  * If there are any pipes then the LogPipeManager will send them
17  * to the LogProcessor. The request can be filtered by a LogFilter.
18  *
19  * @author Andreas Mecky andreasmecky@yahoo.de
20  */

21 public class LogPipeManager {
22     
23     private static final LogProcessor processor = LogProcessorFactory.getLogProcessor();
24     private static LogPipeManager pipeManager = new LogPipeManager();
25     private Vector JavaDoc pipes;
26         
27     private LogPipeManager() {
28         pipes = new Vector JavaDoc();
29     }
30     
31     public static LogPipeManager getInstance() {
32         return pipeManager;
33     }
34     
35     public void addLogPipe(LogPipe pipe) {
36         pipes.add(pipe);
37     }
38     
39     public boolean hasPipes() {
40         if ( pipes.size() > 0 ) {
41             return true;
42         }
43         return false;
44     }
45     
46     public void processLogRequest(LogRecord record) {
47         for ( int i = 0; i < pipes.size(); i++) {
48             LogPipe pipe = (LogPipe)pipes.get(i);
49             if ( pipe.getFilter() != null ) {
50                 // TODO: when the filter is done then call it here
51
}
52             else {
53                 processor.processEvent(pipe.getGenerator(), record);
54             }
55         }
56     }
57     
58 }
59
Popular Tags