You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2003/10/21 10:33:33 UTC

cvs commit: jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/adapter/osuser BaseFulcrumProvider.java

epugh       2003/10/21 01:33:33

  Modified:    security/src/java/org/apache/fulcrum/security/adapter/osuser
                        BaseFulcrumProvider.java
  Log:
  Supports Avalon now..
  
  Revision  Changes    Path
  1.2       +46 -4     jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/adapter/osuser/BaseFulcrumProvider.java
  
  Index: BaseFulcrumProvider.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/security/src/java/org/apache/fulcrum/security/adapter/osuser/BaseFulcrumProvider.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseFulcrumProvider.java	20 Oct 2003 18:28:47 -0000	1.1
  +++ BaseFulcrumProvider.java	21 Oct 2003 08:33:33 -0000	1.2
  @@ -54,9 +54,16 @@
    */
   import java.util.Properties;
   
  +import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.fulcrum.security.SecurityService;
  +import org.apache.fulcrum.security.util.DataBackendException;
   
   import com.opensymphony.user.Entity.Accessor;
   import com.opensymphony.user.provider.UserProvider;
  @@ -70,13 +77,14 @@
    * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
    * @version $Id$
    */
  -public abstract class BaseFulcrumProvider implements UserProvider
  +public abstract class BaseFulcrumProvider extends AbstractLogEnabled implements UserProvider,Composable, Disposable,Component
   {
  -
  +	/** Component Manager to query for the SecurityService through */
  +	protected ComponentManager manager = null;
   	/** Logging */
   	private static Log log = LogFactory.getLog(BaseFulcrumProvider.class);
   	/** Our Fulcrum Security Service to use */
  -	protected SecurityService securityService;
  +	private SecurityService securityService;
   
   	/*
   	 * Does nothing for now.
  @@ -144,6 +152,27 @@
   	}
   
   	/**
  +	  * Lazy loads the SecurityService.
  +	  * 
  +	  * @return
  +	  */
  +	 SecurityService getSecurityService() throws DataBackendException
  +	 {
  +		 if (securityService == null)
  +		 {
  +			 try
  +			 {
  +				securityService = (SecurityService) manager.lookup(SecurityService.ROLE);
  +			 }
  +			 catch (ComponentException ce)
  +			 {
  +				 throw new DataBackendException(ce.getMessage(), ce);
  +			 }
  +		 }
  +		 return securityService;
  +	 }
  +	
  +	/**
   	 * The Fulcrum Security Service that will back the Fulcrum
   	 * providers.
   	 * 
  @@ -155,4 +184,17 @@
   		this.securityService = securityService;
   	}
   
  +	/**
  +	  * Avalon component lifecycle method
  +	  */
  +	public void compose(ComponentManager manager) throws ComponentException
  +	{
  +		this.manager = manager;
  +	}
  +	public void dispose()
  +	{
  +		manager = null;
  +		securityService = null;
  +		
  +	}
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org