1 19 20 package com.sslexplorer.policyframework; 21 22 import org.apache.commons.logging.Log; 23 import org.apache.commons.logging.LogFactory; 24 25 import com.sslexplorer.core.AbstractFactory; 26 27 28 33 public class LaunchSessionFactory extends AbstractFactory { 34 35 static Log log = LogFactory.getLog(LaunchSessionFactory.class); 36 37 static LaunchSessionManager instance; 38 static Class launchSessionManagerImpl = LaunchSessionManager.class; 39 private static boolean locked = false; 40 41 47 public static LaunchSessionManager getInstance() { 48 try { 49 return instance == null ? instance = (LaunchSessionManager) launchSessionManagerImpl.newInstance() : instance; 50 } catch (Exception e) { 51 log.error("Could not create instance of class " + launchSessionManagerImpl.getCanonicalName(), e); 52 return instance == null ? instance = new LaunchSessionManager() : instance; 53 } 54 } 55 56 57 64 public static void setFactoryImpl(Class launchSessionManagerImpl, boolean lock) throws IllegalStateException { 65 if (locked) { 66 throw new IllegalStateException ("Policy database factory has been locked by another plugin."); 67 } 68 LaunchSessionFactory.launchSessionManagerImpl = launchSessionManagerImpl; 69 locked = lock; 70 } 71 } 72 | Popular Tags |