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