acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java
public final Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects,
			List<Sid> sids) {
		Assert.isTrue(batchSize >= 1, "BatchSize must be >= 1");
		Assert.notEmpty(objects, "Objects to lookup required");

		// Map<ObjectIdentity,Acl>
		Map<ObjectIdentity, Acl> result = new HashMap<>(); // contains
																				// FULLY
																				// loaded
																				// Acl
																				// objects

		Set<ObjectIdentity> currentBatchToLoad = new HashSet<>();

		for (int i = 0; i < objects.size(); i++) {
			final ObjectIdentity oid = objects.get(i);
			boolean aclFound = false;

			// Check we don't already have this ACL in the results
			if (result.containsKey(oid)) {
				aclFound = true;
			}

			// Check cache for the present ACL entry
			if (!aclFound) {
				Acl acl = aclCache.getFromCache(oid);

				// Ensure any cached element supports all the requested SIDs
				// (they should always, as our base impl doesn't filter on SID)
				if (acl != null) {
					if (acl.isSidLoaded(sids)) {
						result.put(acl.getObjectIdentity(), acl);
						aclFound = true;
					}
					else {
						throw new IllegalStateException(
								"Error: SID-filtered element detected when implementation does not perform SID filtering "
										+ "- have you added something to the cache manually?");
					}
				}
			}

			// Load the ACL from the database
			if (!aclFound) {
				currentBatchToLoad.add(oid);
			}

			// Is it time to load from JDBC the currentBatchToLoad?
			if ((currentBatchToLoad.size() == this.batchSize)
					|| ((i + 1) == objects.size())) {
				if (currentBatchToLoad.size() > 0) {
					Map<ObjectIdentity, Acl> loadedBatch = lookupObjectIdentities(
							currentBatchToLoad, sids);

					// Add loaded batch (all elements 100% initialized) to results
					result.putAll(loadedBatch);

					// Add the loaded batch to the cache

					for (Acl loadedAcl : loadedBatch.values()) {
						aclCache.putInCache((AclImpl) loadedAcl);
					}

					currentBatchToLoad.clear();
				}
			}
		}

		return result;
	}
public final Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects,
			List<Sid> sids) {
		Assert.isTrue(batchSize >= 1, "BatchSize must be >= 1");
		Assert.notEmpty(objects, "Objects to lookup required");

		// Map<ObjectIdentity,Acl>
		Map<ObjectIdentity, Acl> result = new HashMap<>(); // contains
																				// FULLY
																				// loaded
																				// Acl
																				// objects

		Set<ObjectIdentity> currentBatchToLoad = new HashSet<>();

		for (int i = 0; i < objects.size(); i++) {
			final ObjectIdentity oid = objects.get(i);
			boolean aclFound = false;

			// Check we don't already have this ACL in the results
			if (result.containsKey(oid)) {
				aclFound = true;
			}

			// Check cache for the present ACL entry
			if (!aclFound) {
				Acl acl = aclCache.getFromCache(oid);

				// Ensure any cached element supports all the requested SIDs
				// (they should always, as our base impl doesn't filter on SID)
				if (acl != null) {
					if (acl.isSidLoaded(sids)) {
						result.put(acl.getObjectIdentity(), acl);
						aclFound = true;
					}
					else {
						throw new IllegalStateException(
								"Error: SID-filtered element detected when implementation does not perform SID filtering "
										+ "- have you added something to the cache manually?");
					}
				}
			}

			// Load the ACL from the database
			if (!aclFound) {
				currentBatchToLoad.add(oid);
			}

			// Is it time to load from JDBC the currentBatchToLoad?
			if ((currentBatchToLoad.size() == this.batchSize)
					|| ((i + 1) == objects.size())) {
				if (currentBatchToLoad.size() > 0) {
					Map<ObjectIdentity, Acl> loadedBatch = lookupObjectIdentities(
							currentBatchToLoad, sids);

					// Add loaded batch (all elements 100% initialized) to results
					result.putAll(loadedBatch);

					// Add the loaded batch to the cache

					for (Acl loadedAcl : loadedBatch.values()) {
						aclCache.putInCache((AclImpl) loadedAcl);
					}

					currentBatchToLoad.clear();
				}
			}
		}

		return result;
	}
public final Map < ObjectIdentity , Acl > readAclsById ( List < ObjectIdentity > objects , List < Sid > sids ) { Assert . isTrue ( batchSize >= 1 , "BatchSize must be >= 1" ) ; Assert . notEmpty ( objects , "Objects to lookup required" ) ; // Map<ObjectIdentity,Acl> Map < ObjectIdentity , Acl > result = new HashMap <> ( ) ; // contains // FULLY // loaded // Acl // objects Set < ObjectIdentity > currentBatchToLoad = new HashSet <> ( ) ; for ( int i = 0 ; i < objects . size ( ) ; i ++ ) { final ObjectIdentity oid = objects . get ( i ) ; boolean aclFound = false ; // Check we don't already have this ACL in the results if ( result . containsKey ( oid ) ) { aclFound = true ; } // Check cache for the present ACL entry if ( ! aclFound ) { Acl acl = aclCache . getFromCache ( oid ) ; // Ensure any cached element supports all the requested SIDs // (they should always, as our base impl doesn't filter on SID) if ( acl != null ) { if ( acl . isSidLoaded ( sids ) ) { result . put ( acl . getObjectIdentity ( ) , acl ) ; aclFound = true ; } else { throw new IllegalStateException ( "Error: SID-filtered element detected when implementation does not perform SID filtering " + "- have you added something to the cache manually?" ) ; } } } // Load the ACL from the database if ( ! aclFound ) { currentBatchToLoad . add ( oid ) ; } // Is it time to load from JDBC the currentBatchToLoad? if ( ( currentBatchToLoad . size ( ) == this . batchSize ) || ( ( i + 1 ) == objects . size ( ) ) ) { if ( currentBatchToLoad . size ( ) > 0 ) { Map < ObjectIdentity , Acl > loadedBatch = lookupObjectIdentities ( currentBatchToLoad , sids ) ; // Add loaded batch (all elements 100% initialized) to results result . putAll ( loadedBatch ) ; // Add the loaded batch to the cache for ( Acl loadedAcl : loadedBatch . values ( ) ) { aclCache . putInCache ( ( AclImpl ) loadedAcl ) ; } currentBatchToLoad . clear ( ) ; } } } return result ; }
The main method.
<p>
WARNING: This implementation completely disregards the "sids" argument! Every item
in the cache is expected to contain all SIDs. If you have serious performance needs
(e.g. a very large number of SIDs per object identity), you'll probably want to
develop a custom {@link LookupStrategy} implementation instead.
<p>
The implementation works in batch sizes specified by {@link #batchSize}.

@param objects the identities to lookup (required)
@param sids the SIDs for which identities are required (ignored by this
implementation)

@return a <tt>Map</tt> where keys represent the {@link ObjectIdentity} of the
located {@link Acl} and values are the located {@link Acl} (never <tt>null</tt>
although some entries may be missing; this method should not throw
{@link NotFoundException}, as a chain of {@link LookupStrategy}s may be used to
automatically create entries if required)
The main method . <p > WARNING : This implementation completely disregards the sids argument! Every item in the cache is expected to contain all SIDs . If you have serious performance needs ( e . g . a very large number of SIDs per object identity ) you ll probably want to develop a custom { @link LookupStrategy } implementation instead . <p > The implementation works in batch sizes specified by { @link #batchSize } .