| 1 23 package com.sun.appserv.management.client.prefs; 24 25 import java.util.Arrays ; 26 27 30 public class LoginInfoStoreFactory { 31 32 34 private LoginInfoStoreFactory() { 35 } 36 37 46 public static LoginInfoStore getStore(final String storeImplClassName) 47 throws StoreException, ClassNotFoundException , IllegalAccessException , InstantiationException { 48 LoginInfoStore store = null; 49 if (storeImplClassName == null) 50 store = getDefaultStore(); 51 else 52 store = getCustomStore(storeImplClassName); 53 return ( store ); 54 } 55 56 private static LoginInfoStore getDefaultStore() throws StoreException { 57 return ( new MemoryHashLoginInfoStore() ); 58 } 59 60 private static LoginInfoStore getCustomStore(final String icn) 61 throws ClassNotFoundException , IllegalAccessException , InstantiationException { 62 final Class ic = Class.forName(icn); 63 final String in = LoginInfoStore.class.getName(); 64 if (ic == null || !isStore(ic)) 65 throw new IllegalArgumentException ("Class: " + ic.getName() + " does not implement: " + in); 66 final LoginInfoStore store = (LoginInfoStore) ic.newInstance(); 67 return ( store ); 68 } 69 70 private static boolean isStore(final Class c) { 71 final Class [] ifs = c.getInterfaces(); 72 final Class sc = LoginInfoStore.class; 73 return ( Arrays.asList(ifs).contains(sc) ); 74 } 75 } | Popular Tags |