1 19 20 package com.sslexplorer.webforwards; 21 22 import org.apache.commons.logging.Log; 23 import org.apache.commons.logging.LogFactory; 24 25 32 public class WebForwardDatabaseFactory { 33 static Log log = LogFactory.getLog(WebForwardDatabaseFactory.class); 34 35 static WebForwardDatabase instance; 36 static Class webForwardDatabaseImpl = JDBCWebForwardDatabase.class; 37 private static boolean locked = false; 38 39 42 public static WebForwardDatabase getInstance() { 43 try { 44 return instance == null ? instance = (WebForwardDatabase) webForwardDatabaseImpl.newInstance() : instance; 45 } catch (Exception e) { 46 log.error("Could not create instance of class " + webForwardDatabaseImpl.getCanonicalName(), e); 47 return instance == null ? instance = new JDBCWebForwardDatabase() : instance; 48 } 49 } 50 51 52 57 public static void setFactoryImpl(Class webForwardDatabaseImpl, boolean lock) throws IllegalStateException { 58 if (locked) { 59 throw new IllegalStateException ("WebForward database factory has been locked by another plugin."); 60 } 61 WebForwardDatabaseFactory.webForwardDatabaseImpl = webForwardDatabaseImpl; 62 locked = lock; 63 } 64 } 65 | Popular Tags |