jmcnally    01/05/30 15:31:33

  Modified:    src/java/org/apache/turbine/services/security
                        BaseSecurityService.java
  Log:
  move the Class.forName method call into init, so that it is only done once.
  Should always cache the Class not the String class name.
  
  Revision  Changes    Path
  1.23      +27 -11    
jakarta-turbine/src/java/org/apache/turbine/services/security/BaseSecurityService.java
  
  Index: BaseSecurityService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/security/BaseSecurityService.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- BaseSecurityService.java  2001/04/17 22:51:31     1.22
  +++ BaseSecurityService.java  2001/05/30 22:31:31     1.23
  @@ -101,7 +101,7 @@
    * </ul>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
  - * @version $Id: BaseSecurityService.java,v 1.22 2001/04/17 22:51:31 jvanzyl Exp $
  + * @version $Id: BaseSecurityService.java,v 1.23 2001/05/30 22:31:31 jmcnally Exp $
    */
   public abstract class BaseSecurityService 
       extends TurbineBaseService implements SecurityService
  @@ -122,6 +122,9 @@
   
       /** The instance of UserManager the SecurityService uses */
       private UserManager userManager = null;
  +
  +    /** The class of User the SecurityService uses */
  +    private Class userClass = null;
      
       /**
        * The Group object that represents the <a href="#global">global group</a>. 
  @@ -186,6 +189,21 @@
           String userManagerClassName = getProperties().getProperty(
               SecurityService.USER_MANAGER_KEY,
               SecurityService.USER_MANAGER_DEFAULT);
  +
  +        String userClassName = getProperties().getProperty(
  +            SecurityService.USER_CLASS_KEY,
  +            SecurityService.USER_CLASS_DEFAULT);
  +
  +        try
  +        {
  +            userClass = Class.forName(userClassName);
  +        }
  +        catch(Exception e)
  +        {
  +            throw new InitializationException(
  +                "Failed create a Class object for User implementation", e);
  +        }
  +
           try
           {
               userManager =  (UserManager)Class.
  @@ -196,8 +214,11 @@
           {
               throw new InitializationException("BaseSecurityService.init: Failed to 
instantiate UserManager" ,e);
           }
  +
       }
   
  +
  +
       /**
        * Return a Class object representing the system's chosen implementation of
        * of User interface.
  @@ -209,17 +230,12 @@
       public Class getUserClass()
           throws UnknownEntityException
       {
  -        String userClassName = getProperties().getProperty(
  -            SecurityService.USER_CLASS_KEY,
  -            SecurityService.USER_CLASS_DEFAULT);
  -        try
  -        {
  -            return Class.forName(userClassName);
  -        }
  -        catch(Exception e)
  -        {
  -            throw new UnknownEntityException("Failed create a Class object for User 
implementation", e);
  +        if ( userClass == null ) 
  +        {        
  +            throw new UnknownEntityException(
  +                "Failed to create a Class object for User implementation");
           }
  +        return userClass;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to