1 package org.jzonic.jlo.processor; 2 3 import java.io.InputStream ; 4 import java.util.Properties ; 5 21 public class LogProcessorFactory { 22 23 private static LogProcessor lp = null; 24 private static LogProcessorFactory lpf = null; 25 26 private LogProcessorFactory() { 27 try { 28 ClassLoader cl = this.getClass().getClassLoader(); 29 InputStream fis = cl.getResourceAsStream("jlo.properties"); 30 if ( fis == null ) { 31 lp = new AsynchronousLogProcessor(); 32 } 33 else { 34 Properties properties = new Properties (); 35 properties.load(fis); 36 String ptype = properties.getProperty("processor"); 37 if ( ptype != null ) { 38 if ( ptype.equalsIgnoreCase("direct") ) { 39 lp = new DirectLogProcessor(); 40 } 41 else { 42 lp = new AsynchronousLogProcessor(); 43 } 44 } 45 else { 46 lp = new AsynchronousLogProcessor(); 47 } 48 } 49 } 50 catch (Exception e) { 51 lp = new AsynchronousLogProcessor(); 52 } 53 54 } 55 56 public static LogProcessor getLogProcessor() { 57 if ( lpf == null ) { 58 lpf = new LogProcessorFactory(); 59 } 60 return lp; 61 } 62 63 public void flush() { 64 lp.flush(); 65 } 66 67 } 68 | Popular Tags |