1 16 17 package org.apache.jetspeed.om.security; 18 19 import org.apache.turbine.services.TurbineServices; 20 import org.apache.turbine.services.resources.ResourceService; 21 22 import org.apache.jetspeed.services.security.GroupException; 23 import org.apache.jetspeed.services.security.JetspeedSecurityService; 24 25 32 public class JetspeedGroupFactory 33 { 34 private static final String CONFIG_GROUP_CLASSNAME = "group.class"; 35 36 private static String groupClassName = null; 37 private static Class groupClass = null; 38 39 46 public static Group getInstance() 47 throws GroupException 48 { 49 return getInstance(true); 50 } 51 52 public static Group getInstance(boolean isNew) 53 throws GroupException 54 { 55 Group group = null; 56 57 if (null == groupClassName) 58 { 59 try 60 { 61 ResourceService serviceConf = ((TurbineServices)TurbineServices.getInstance()) 62 .getResources(JetspeedSecurityService.SERVICE_NAME); 63 groupClassName = serviceConf.getString(CONFIG_GROUP_CLASSNAME); 64 groupClass = Class.forName(groupClassName); 65 } 66 catch(Exception e) 67 { 68 throw new GroupException( 69 "GroupFactory: Failed to create a Class object for Group implementation: " + e.toString()); 70 } 71 } 72 73 try 74 { 75 group = (Group)groupClass.newInstance(); 76 if (group instanceof BaseJetspeedGroup) 77 { 78 ((BaseJetspeedGroup)group).setNew(isNew); 79 } 80 } 81 catch(Exception e) 82 { 83 throw new GroupException("Failed instantiate an Group implementation object: " + e.toString()); 84 } 85 86 return group; 87 } 88 89 90 } 91 92 93 94 | Popular Tags |