1 package de.webman.acl; 2 3 import com.teamkonzept.lib.ConfigurationManager; 4 import com.teamkonzept.lib.TKException; 5 import com.teamkonzept.lib.TKVector; 6 import de.webman.acl.db.*; 7 import de.webman.acl.resolver.ResolverFactory; 8 9 16 public class ContextFactory 17 extends ObjectFactoryBase 18 implements ObjectFactory 19 { 20 21 23 25 28 private static ContextFactory SINGLETON = null; 29 30 31 33 36 private ContextFactory () 37 { 38 super(); 39 } 40 41 42 44 50 public static synchronized final ContextFactory getInstance () 51 throws TKException 52 { 53 if (SINGLETON == null) 54 { 55 SINGLETON = new ContextFactory(); 56 SINGLETON.configurationChanged(); 57 ConfigurationManager.getInstance() 58 .registerConfigurationListener(SINGLETON, 59 PROPERTY_GROUP_NAME); 60 } 61 62 return SINGLETON; 63 } 64 65 66 68 73 public final ObjectDBInterface getDBInterface () 74 { 75 return ContextDBInterface.getInstance(); 76 } 77 78 84 public final ObjectDBData getDBData (Integer id) 85 { 86 return new ContextDBData(id, null, null); 87 } 88 89 95 public final ObjectDBData getDBData (WMObject object) 96 { 97 return new ContextDBData((Context) object); 98 } 99 100 106 public final WMObject buildObject (ObjectDBData data) 107 { 108 return new Context((ContextDBData) data); 109 } 110 111 112 114 121 public final Context getContext (Integer id) 122 throws TKException 123 { 124 return (Context) getObject(id); 125 } 126 127 133 public final TKVector getContexts () 134 throws TKException 135 { 136 return getObjects(); 137 } 138 139 147 public final Context createContext (String name, 148 String shortcut) 149 throws TKException 150 { 151 return (Context) createObject(new ContextDBData(null, 152 name, 153 shortcut)); 154 } 155 156 162 public final void modifyContext (Context context) 163 throws TKException 164 { 165 if (context.isModifiedAssociations()) 166 { 167 ResolverFactory.getInstance().removeResolvers(); 168 } 169 170 modifyObject(context); 171 } 172 173 179 public final void deleteContext (Context context) 180 throws TKException 181 { 182 ResolverFactory.getInstance().removeResolvers(); 183 184 deleteObject(context); 185 } 186 187 } 188 | Popular Tags |