Collection getAttributes()

in plugin-acl/plugin/src/main/groovy/grails/plugin/springsecurity/acl/access/method/ProxyAwareDelegatingMethodSecurityMetadataSource.groovy [49:87]


	Collection<ConfigAttribute> getAttributes(Method m, Class<?> tc) {

		Method method = ProxyUtils.unproxy(m)
		Class<?> targetClass = ProxyUtils.unproxy(tc)

		DefaultCacheKey cacheKey = new DefaultCacheKey(method, targetClass)
		synchronized (cache) {
			Collection<ConfigAttribute> cached = cache[cacheKey]
			// Check for canonical value indicating there is no config attribute,
			if (cached == NULL_CONFIG_ATTRIBUTE) {
				return null
			}

			if (cached != null) {
				return cached
			}

			// No cached value, so query the sources to find a result
			Collection<ConfigAttribute> attributes
			for (MethodSecurityMetadataSource s in methodSecurityMetadataSources) {
				attributes = s.getAttributes(method, targetClass)
				if (attributes) {
					break
				}
			}

			// Put it in the cache.
			if (attributes == null) {
				cache[cacheKey] = NULL_CONFIG_ATTRIBUTE
				return null
			}

			logger.debug "Adding security method [$cacheKey] with attributes $attributes"

			cache[cacheKey] = attributes

			attributes
		}
	}