1 package org.jzonic.jlo.formatter; 2 3 import org.jzonic.jlo.error.ErrorHandler; 4 5 import java.lang.reflect.Constructor ; 6 16 17 public class FormatterFactory { 18 19 22 private FormatterFactory() { 23 } 24 25 31 public static Formatter getFormatter(String name,String configurationName) { 32 if ( name.indexOf(".") == -1 ) { 34 name = "org.jzonic.jlo.formatter."+name; 36 } 37 try { 38 Class c = Class.forName(name); 40 Constructor con = c.getDeclaredConstructor(new Class []{String .class}); 41 Formatter fmt = (Formatter)con.newInstance(new Object []{new String (configurationName)}); 42 return fmt; 43 } catch (Exception e) { 44 ErrorHandler.reportError("Exception while instantiating the formatter: " + name, e); 46 return new SimpleFormatter("Default"); 47 } 48 } 49 } | Popular Tags |