1 package com.sslexplorer.security; 2 3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5 6 import com.sslexplorer.jdbc.JDBCSystemDatabase; 7 8 15 public class SystemDatabaseFactory { 16 static Log log = LogFactory.getLog(SystemDatabaseFactory.class); 17 18 static SystemDatabase instance; 19 static Class systemDatabaseImpl = JDBCSystemDatabase.class; 20 private static boolean locked = false; 21 22 25 public static SystemDatabase getInstance() { 26 try { 27 return instance == null ? instance = (SystemDatabase) systemDatabaseImpl.newInstance() : instance; 28 } catch (Exception e) { 29 log.error("Could not create instance of class " + systemDatabaseImpl.getCanonicalName(), e); 30 return instance == null ? instance = new JDBCSystemDatabase() : instance; 31 } 32 } 33 34 35 40 public static void setFactoryImpl(Class systemDatabaseImpl, boolean lock) throws IllegalStateException { 41 if (locked) { 42 throw new IllegalStateException ("System database factory has been locked by another plugin."); 43 } 44 SystemDatabaseFactory.systemDatabaseImpl = systemDatabaseImpl; 45 locked = lock; 46 } 47 } 48 | Popular Tags |