From 4e55780e7c414648333cf5d7aba6d6b5e2618485 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Fri, 20 May 2005 00:00:22 +0000 Subject: [PATCH] Performance optimisations thanks to Paulo Neves. --- ...InvocationCollectionFilteringProvider.java | 20 ++++++++++++++----- doc/xdocs/changes.xml | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProvider.java b/core/src/main/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProvider.java index ec6b4192cc..555bb41a05 100644 --- a/core/src/main/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProvider.java +++ b/core/src/main/java/org/acegisecurity/afterinvocation/BasicAclEntryAfterInvocationCollectionFilteringProvider.java @@ -1,4 +1,4 @@ -/* Copyright 2004 Acegi Technology Pty Limited +/* Copyright 2004, 2005 Acegi Technology Pty Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.InitializingBean; + import org.springframework.util.Assert; import java.lang.reflect.Array; @@ -98,6 +99,7 @@ import java.util.Set; *

* * @author Ben Alex + * @author Paulo Neves * @version $Id$ */ public class BasicAclEntryAfterInvocationCollectionFilteringProvider @@ -139,11 +141,13 @@ public class BasicAclEntryAfterInvocationCollectionFilteringProvider } public void afterPropertiesSet() throws Exception { - Assert.notNull(processConfigAttribute, "A processConfigAttribute is mandatory"); + Assert.notNull(processConfigAttribute, + "A processConfigAttribute is mandatory"); Assert.notNull(aclManager, "An aclManager is mandatory"); if ((requirePermission == null) || (requirePermission.length == 0)) { - throw new IllegalArgumentException("One or more requirePermission entries is mandatory"); + throw new IllegalArgumentException( + "One or more requirePermission entries is mandatory"); } } @@ -302,6 +306,10 @@ class CollectionFilterer implements Filterer { //~ Instance fields ======================================================== private Collection collection; + + // collectionIter offers significant performance optimisations (as + // per acegisecurity-developer mailing list conversation 19/5/05) + private Iterator collectionIter; private Set removeList; //~ Constructors =========================================================== @@ -346,14 +354,16 @@ class CollectionFilterer implements Filterer { * @see net.sf.acegisecurity.afterinvocation.Filterer#iterator() */ public Iterator iterator() { - return collection.iterator(); + collectionIter = collection.iterator(); + + return collectionIter; } /** * @see net.sf.acegisecurity.afterinvocation.Filterer#remove(java.lang.Object) */ public void remove(Object object) { - removeList.add(object); + collectionIter.remove(); } } diff --git a/doc/xdocs/changes.xml b/doc/xdocs/changes.xml index 7863dc7634..f4f887cadd 100644 --- a/doc/xdocs/changes.xml +++ b/doc/xdocs/changes.xml @@ -26,6 +26,7 @@ + Greatly improve BasicAclEntryAfterInvocationCollectionFilteringProvider performance with large collections (if the principal has access to relatively few collection elements) Reorder DaoAuthenticationProvider exception logic as per developer list discussion ContextHolder refactored and replaced by SecurityContextHolder Made AclEntry Serializable (correct issue with BasicAclEntryCache)