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.RoleException; 23 import org.apache.jetspeed.services.security.JetspeedSecurityService; 24 25 30 public class JetspeedRoleFactory 31 { 32 private static final String CONFIG_ROLE_CLASSNAME = "role.class"; 33 34 private static String roleClassName = null; 35 private static Class roleClass = null; 36 37 44 public static Role getInstance() 45 throws RoleException 46 { 47 return getInstance(true); 48 } 49 50 public static Role getInstance(boolean isNew) 51 throws RoleException 52 { 53 Role role = null; 54 55 if (null == roleClassName) 56 { 57 try 58 { 59 ResourceService serviceConf = ((TurbineServices)TurbineServices.getInstance()) 60 .getResources(JetspeedSecurityService.SERVICE_NAME); 61 roleClassName = serviceConf.getString(CONFIG_ROLE_CLASSNAME); 62 roleClass = Class.forName(roleClassName); 63 } 64 catch(Exception e) 65 { 66 throw new RoleException( 67 "RoleFactory: Failed to create a Class object for Role implementation: " + e.toString()); 68 } 69 } 70 71 try 72 { 73 role = (Role)roleClass.newInstance(); 74 if (role instanceof BaseJetspeedRole) 75 { 76 ((BaseJetspeedRole)role).setNew(isNew); 77 } 78 } 79 catch(Exception e) 80 { 81 throw new RoleException("Failed instantiate an Role implementation object: " + e.toString()); 82 } 83 84 return role; 85 } 86 87 88 } 89 90 91 | Popular Tags |