You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ma...@apache.org on 2005/01/21 21:44:15 UTC

cvs commit: jakarta-slide/src/stores/org/apache/slide/store/txjndi JNDIPrincipalStore.java

masonjm     2005/01/21 12:44:15

  Modified:    src/stores/org/apache/slide/store/txjndi
                        JNDIPrincipalStore.java
  Log:
  Allow a separate cache for each JNDIPrincipalStore instead of a shared cache for all.
  
  Revision  Changes    Path
  1.10      +40 -17    jakarta-slide/src/stores/org/apache/slide/store/txjndi/JNDIPrincipalStore.java
  
  Index: JNDIPrincipalStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/txjndi/JNDIPrincipalStore.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JNDIPrincipalStore.java	27 Oct 2004 05:12:39 -0000	1.9
  +++ JNDIPrincipalStore.java	21 Jan 2005 20:44:15 -0000	1.10
  @@ -107,6 +107,15 @@
    * Parameters used in Domain.xml when setting up the Store.
    * </p>
    * <dl>
  + * <dt>cache.name</dt>
  + * <dd>
  + * The name of the EHCache cache that should be used for this Store. If more
  + * than one JNDIPrincipalStore is used in a single Namespace this parameter
  + * can be used to make each one use a different cache. The default value is
  + * <em>org.apache.slide.store.txjndi.JNDIPrincipalStore</em>.
  + * See <a href="#cacherefreshing">Caching</a> for more information.
  + * </dd>
  + * 
    * <dt>cache.refresh.checkrate</dt>
    * <dd>
    * How often, in <em>seconds</em>, the cache refresh thread should check for Uris in the cache
  @@ -177,10 +186,10 @@
    * 
    * <h3><a name="caching">Caching</a></h3>
    * <p>
  - * This Store makes use of <a href="http://ehcache.sourceforge.net/">EHCache</a>. You will
  - * need ehcache.jar in order to use this Store. When initialized the default CacheManager is
  - * used to find a Cache named "org.apache.slide.store.txjndi.JNDIPrincipalStore". If there is
  - * no Cache found with this name then a Cache is created with these default values:
  + * This Store makes use of <a href="http://ehcache.sourceforge.net/">EHCache</a>. 
  + * When initialized the default CacheManager is used to find the Cache named
  + * in the <em>cache.name</em> parameter. If there is no Cache found with this
  + * name then a Cache is created with these default values:
    * </p>
    * <ul>
    * 	<li>name = org.apache.slide.store.txjndi.JNDIPrincipalStore</li>
  @@ -191,8 +200,8 @@
    * 	<li>overflowToDisk = true</li>
    * </ul>
    * <p>
  - * To override these values you will need to create a configuration file for EHCache with a
  - * cache named "org.apache.slide.store.txjndi.JNDIPrincipalStore" that has the settings you
  + * To override these values you will need to create a configuration file for EHCache with
  + * the cache named by the <em>cache.name</em> parameter that has the settings you
    * wish. See the documentation at the <a href="http://ehcache.sourceforge.net/">EHCache website</a>
    * for instructions.
    * </p>
  @@ -238,13 +247,13 @@
   		implements ContentStore, LockStore, NodeStore, RevisionDescriptorStore,
   			RevisionDescriptorsStore, SecurityStore {
   
  -	public static final String CACHE_NAME              = JNDIPrincipalStore.class.getName();
   	public static final String CACHE_OBJECT_PREFIX     = "object: ";
   	public static final String CACHE_DESCRIPTOR_PREFIX = "descriptor: ";
   	
   	public static final String JNDI_PROPERTY_PREFIX = "java.naming";
   
   	// Parameter keys
  +    public static final String PARAM_CACHE_NAME               = "cache.name";
   	public static final String PARAM_CACHE_REFRESH_CHECK_RATE = "cache.refresh.checkrate";
   	public static final String PARAM_CACHE_REFRESH_RATE       = "cache.refresh.rate";
   	public static final String PARAM_CACHE_REFRESH_THRESHOLD  = "cache.refresh.threshold";
  @@ -260,6 +269,7 @@
   	public static final String PARAM_LOG_VALIDATION_ERRORS = "log.validationerrors";
       
   	// Default values
  +    public static final String  DEFAULT_CACHE_NAME               = JNDIPrincipalStore.class.getName();
   	public static final int     DEFAULT_CACHE_SIZE               = 200;
   	public static final boolean DEFAULT_CACHE_OVERFLOW_TO_DISK   = true;
   	public static final boolean DEFAULT_CACHE_ETERNAL            = false;
  @@ -296,6 +306,7 @@
   	protected int searchScope;
   	protected String principalNameAttribute;
   
  +    private String cacheName = DEFAULT_CACHE_NAME;
   	private String name;
   	private String usersPath;
   	private Map objectNameMap; // Uri-String -> LDAP lookup name
  @@ -303,7 +314,6 @@
   	
   	public JNDIPrincipalStore() {
   		ctxParameters = new Hashtable();
  -		cache = getCache();
   		name = "";
   		refreshList = new TreeSet();
   		refresher = new RefreshThread();
  @@ -427,6 +437,15 @@
   
   		//Set attribute which contains the user principal name for authentication
   		principalNameAttribute = (String)parameters.get(PARAM_JNDI_USERPRINCIPALNAME);
  +
  +        // Set cacheName
  +        temp = (String)parameters.get( PARAM_CACHE_NAME );
  +        if ( temp != null ) {
  +            cacheName = temp;
  +        } else {
  +            cacheName = DEFAULT_CACHE_NAME;
  +        }
  +        cache = getCache();
   	}
   	
   	public boolean cacheResults() {
  @@ -658,7 +677,11 @@
   	 */
   	public Enumeration enumeratePermissions(Uri uri) throws ServiceAccessException {
   		Vector permissions = new Vector();
  -		permissions.add( new NodePermission( uri.toString(), "all", "/actions/read" ) );
  +		permissions.add(
  +            new NodePermission(
  +                uri.toString(),
  +                "all",
  +                uri.getNamespace().getConfig().getReadObjectAction().getUri() ) );
   		return permissions.elements();
   	}
   	
  @@ -1126,10 +1149,10 @@
   				Logger.ERROR );
   			return null;
   		}
  -		cache = cacheManager.getCache( CACHE_NAME );
  +		cache = cacheManager.getCache( cacheName );
   		if ( cache == null ) {
   			cache = new Cache(
  -				CACHE_NAME,
  +                cacheName,
   				DEFAULT_CACHE_SIZE,
   				DEFAULT_CACHE_OVERFLOW_TO_DISK,
   				DEFAULT_CACHE_ETERNAL,
  @@ -1139,19 +1162,19 @@
   				cacheManager.addCache(cache);
   			} catch ( IllegalStateException e ) {
   				getLogger().log(
  -					name + ": Error adding cache \"" + CACHE_NAME + "\" to CacheManager.",
  +					name + ": Error adding cache \"" + cacheName + "\" to CacheManager.",
   					e,
   					LOG_CHANNEL,
   					Logger.ERROR);
   			} catch ( ObjectExistsException e ) {
   				getLogger().log(
  -					name + ": Error adding cache \"" + CACHE_NAME + "\" to CacheManager.",
  +					name + ": Error adding cache \"" + cacheName + "\" to CacheManager.",
   					e,
   					LOG_CHANNEL,
   					Logger.ERROR);
   			} catch ( CacheException e ) {
   				getLogger().log(
  -					name + ": Error adding cache \"" + CACHE_NAME + "\" to CacheManager.",
  +					name + ": Error adding cache \"" + cacheName + "\" to CacheManager.",
   					e,
   					LOG_CHANNEL,
   					Logger.ERROR);
  
  
  

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