Use JDK 1.6's Collections.newSetFromMap instead of manually accessing Maps with dummy Boolean values
This commit is contained in:
		
							parent
							
								
									e0c56a124a
								
							
						
					
					
						commit
						853826a774
					
				|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
|  * Copyright 2002-2012 the original author or authors. | ||||
|  * Copyright 2002-2013 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  | @ -20,8 +20,10 @@ import java.beans.PropertyDescriptor; | |||
| import java.lang.reflect.Constructor; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| 
 | ||||
| import org.aopalliance.aop.Advice; | ||||
|  | @ -136,11 +138,11 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig | |||
| 
 | ||||
| 	private final Map<Object, Boolean> advisedBeans = new ConcurrentHashMap<Object, Boolean>(64); | ||||
| 
 | ||||
| 	// using a ConcurrentHashMap as a Set | ||||
| 	private final Map<String, Boolean> targetSourcedBeans = new ConcurrentHashMap<String, Boolean>(16); | ||||
| 	private final Set<String> targetSourcedBeans = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16)); | ||||
| 
 | ||||
| 	// using a ConcurrentHashMap as a Set | ||||
| 	private final Map<Object, Boolean> earlyProxyReferences = new ConcurrentHashMap<Object, Boolean>(16); | ||||
| 	private final Set<Object> earlyProxyReferences = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<Object, Boolean>(16)); | ||||
| 
 | ||||
| 	private final Map<Object, Class<?>> proxyTypes = new ConcurrentHashMap<Object, Class<?>>(16); | ||||
| 
 | ||||
|  | @ -262,14 +264,14 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig | |||
| 
 | ||||
| 	public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException { | ||||
| 		Object cacheKey = getCacheKey(bean.getClass(), beanName); | ||||
| 		this.earlyProxyReferences.put(cacheKey, Boolean.TRUE); | ||||
| 		this.earlyProxyReferences.add(cacheKey); | ||||
| 		return wrapIfNecessary(bean, beanName, cacheKey); | ||||
| 	} | ||||
| 
 | ||||
| 	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException { | ||||
| 		Object cacheKey = getCacheKey(beanClass, beanName); | ||||
| 
 | ||||
| 		if (beanName == null || !this.targetSourcedBeans.containsKey(beanName)) { | ||||
| 		if (beanName == null || !this.targetSourcedBeans.contains(beanName)) { | ||||
| 			if (this.advisedBeans.containsKey(cacheKey)) { | ||||
| 				return null; | ||||
| 			} | ||||
|  | @ -285,7 +287,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig | |||
| 		if (beanName != null) { | ||||
| 			TargetSource targetSource = getCustomTargetSource(beanClass, beanName); | ||||
| 			if (targetSource != null) { | ||||
| 				this.targetSourcedBeans.put(beanName, Boolean.TRUE); | ||||
| 				this.targetSourcedBeans.add(beanName); | ||||
| 				Object[] specificInterceptors = getAdvicesAndAdvisorsForBean(beanClass, beanName, targetSource); | ||||
| 				Object proxy = createProxy(beanClass, beanName, specificInterceptors, targetSource); | ||||
| 				this.proxyTypes.put(cacheKey, proxy.getClass()); | ||||
|  | @ -318,7 +320,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig | |||
| 	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { | ||||
| 		if (bean != null) { | ||||
| 			Object cacheKey = getCacheKey(bean.getClass(), beanName); | ||||
| 			if (!this.earlyProxyReferences.containsKey(cacheKey)) { | ||||
| 			if (!this.earlyProxyReferences.contains(cacheKey)) { | ||||
| 				return wrapIfNecessary(bean, beanName, cacheKey); | ||||
| 			} | ||||
| 		} | ||||
|  | @ -344,7 +346,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyConfig | |||
| 	 * @return a proxy wrapping the bean, or the raw bean instance as-is | ||||
| 	 */ | ||||
| 	protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey) { | ||||
| 		if (beanName != null && this.targetSourcedBeans.containsKey(beanName)) { | ||||
| 		if (beanName != null && this.targetSourcedBeans.contains(beanName)) { | ||||
| 			return bean; | ||||
| 		} | ||||
| 		if (Boolean.FALSE.equals(this.advisedBeans.get(cacheKey))) { | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
|  * Copyright 2002-2012 the original author or authors. | ||||
|  * Copyright 2002-2013 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  | @ -20,8 +20,9 @@ import java.beans.PropertyDescriptor; | |||
| import java.lang.annotation.Annotation; | ||||
| import java.lang.reflect.Method; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| 
 | ||||
| import org.springframework.beans.BeansException; | ||||
|  | @ -90,9 +91,9 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP | |||
| 
 | ||||
| 	/** | ||||
| 	 * Cache for validated bean names, skipping re-validation for the same bean | ||||
| 	 * (using a ConcurrentHashMap as a Set) | ||||
| 	 */ | ||||
| 	private final Map<String, Boolean> validatedBeanNames = new ConcurrentHashMap<String, Boolean>(64); | ||||
| 	private final Set<String> validatedBeanNames = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(64)); | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
|  | @ -139,7 +140,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP | |||
| 			PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) | ||||
| 			throws BeansException { | ||||
| 
 | ||||
| 		if (!this.validatedBeanNames.containsKey(beanName)) { | ||||
| 		if (!this.validatedBeanNames.contains(beanName)) { | ||||
| 			if (!shouldSkip(this.beanFactory, beanName)) { | ||||
| 				List<String> invalidProperties = new ArrayList<String>(); | ||||
| 				for (PropertyDescriptor pd : pds) { | ||||
|  | @ -151,7 +152,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP | |||
| 					throw new BeanInitializationException(buildExceptionMessage(invalidProperties, beanName)); | ||||
| 				} | ||||
| 			} | ||||
| 			this.validatedBeanNames.put(beanName, Boolean.TRUE); | ||||
| 			this.validatedBeanNames.add(beanName); | ||||
| 		} | ||||
| 		return pvs; | ||||
| 	} | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
|  * Copyright 2002-2012 the original author or authors. | ||||
|  * Copyright 2002-2013 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  | @ -16,9 +16,10 @@ | |||
| 
 | ||||
| package org.springframework.beans.factory.config; | ||||
| 
 | ||||
| import java.util.Collections; | ||||
| import java.util.Enumeration; | ||||
| import java.util.Map; | ||||
| import java.util.Properties; | ||||
| import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| 
 | ||||
| import org.springframework.beans.BeansException; | ||||
|  | @ -72,9 +73,8 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer { | |||
| 
 | ||||
| 	/** | ||||
| 	 * Contains names of beans that have overrides | ||||
| 	 * (using a ConcurrentHashMap as a Set) | ||||
| 	 */ | ||||
| 	private Map<String, Boolean> beanNames = new ConcurrentHashMap<String, Boolean>(16); | ||||
| 	private final Set<String> beanNames = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16)); | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
|  | @ -130,7 +130,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer { | |||
| 		} | ||||
| 		String beanName = key.substring(0, separatorIndex); | ||||
| 		String beanProperty = key.substring(separatorIndex+1); | ||||
| 		this.beanNames.put(beanName, Boolean.TRUE); | ||||
| 		this.beanNames.add(beanName); | ||||
| 		applyPropertyValue(factory, beanName, beanProperty, value); | ||||
| 		if (logger.isDebugEnabled()) { | ||||
| 			logger.debug("Property '" + key + "' set to value [" + value + "]"); | ||||
|  | @ -161,7 +161,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer { | |||
| 	 * the named bean | ||||
| 	 */ | ||||
| 	public boolean hasPropertyOverridesFor(String beanName) { | ||||
| 		return this.beanNames.containsKey(beanName); | ||||
| 		return this.beanNames.contains(beanName); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -24,6 +24,7 @@ import java.security.PrivilegedActionException; | |||
| import java.security.PrivilegedExceptionAction; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.LinkedHashSet; | ||||
|  | @ -161,9 +162,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp | |||
| 
 | ||||
| 	/** | ||||
| 	 * Names of beans that have already been created at least once | ||||
| 	 * (using a ConcurrentHashMap as a Set) | ||||
| 	 */ | ||||
| 	private final Map<String, Boolean> alreadyCreated = new ConcurrentHashMap<String, Boolean>(64); | ||||
| 	private final Set<String> alreadyCreated = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(64)); | ||||
| 
 | ||||
| 	/** Names of beans that are currently in creation */ | ||||
| 	private final ThreadLocal<Object> prototypesCurrentlyInCreation = | ||||
|  | @ -1379,7 +1379,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp | |||
| 	 * @param beanName the name of the bean | ||||
| 	 */ | ||||
| 	protected void markBeanAsCreated(String beanName) { | ||||
| 		this.alreadyCreated.put(beanName, Boolean.TRUE); | ||||
| 		this.alreadyCreated.add(beanName); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
|  | @ -1390,7 +1390,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp | |||
| 	 * at this point already | ||||
| 	 */ | ||||
| 	protected boolean isBeanEligibleForMetadataCaching(String beanName) { | ||||
| 		return this.alreadyCreated.containsKey(beanName); | ||||
| 		return this.alreadyCreated.contains(beanName); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
|  | @ -1400,7 +1400,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp | |||
| 	 * @return {@code true} if actually removed, {@code false} otherwise | ||||
| 	 */ | ||||
| 	protected boolean removeSingletonIfCreatedForTypeCheckOnly(String beanName) { | ||||
| 		if (!this.alreadyCreated.containsKey(beanName)) { | ||||
| 		if (!this.alreadyCreated.contains(beanName)) { | ||||
| 			removeSingleton(beanName); | ||||
| 			return true; | ||||
| 		} | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
|  * Copyright 2002-2012 the original author or authors. | ||||
|  * Copyright 2002-2013 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  | @ -16,6 +16,7 @@ | |||
| 
 | ||||
| package org.springframework.beans.factory.support; | ||||
| 
 | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.LinkedHashMap; | ||||
|  | @ -92,11 +93,13 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements | |||
| 	/** Set of registered singletons, containing the bean names in registration order */ | ||||
| 	private final Set<String> registeredSingletons = new LinkedHashSet<String>(64); | ||||
| 
 | ||||
| 	/** Names of beans that are currently in creation (using a ConcurrentHashMap as a Set) */ | ||||
| 	private final Map<String, Boolean> singletonsCurrentlyInCreation = new ConcurrentHashMap<String, Boolean>(16); | ||||
| 	/** Names of beans that are currently in creation */ | ||||
| 	private final Set<String> singletonsCurrentlyInCreation = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16)); | ||||
| 
 | ||||
| 	/** Names of beans currently excluded from in creation checks (using a ConcurrentHashMap as a Set) */ | ||||
| 	private final Map<String, Boolean> inCreationCheckExclusions = new ConcurrentHashMap<String, Boolean>(16); | ||||
| 	/** Names of beans currently excluded from in creation checks */ | ||||
| 	private final Set<String> inCreationCheckExclusions = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16)); | ||||
| 
 | ||||
| 	/** List of suppressed Exceptions, available for associating related causes */ | ||||
| 	private Set<Exception> suppressedExceptions; | ||||
|  | @ -290,7 +293,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements | |||
| 	public void setCurrentlyInCreation(String beanName, boolean inCreation) { | ||||
| 		Assert.notNull(beanName, "Bean name must not be null"); | ||||
| 		if (!inCreation) { | ||||
| 			this.inCreationCheckExclusions.put(beanName, Boolean.TRUE); | ||||
| 			this.inCreationCheckExclusions.add(beanName); | ||||
| 		} | ||||
| 		else { | ||||
| 			this.inCreationCheckExclusions.remove(beanName); | ||||
|  | @ -299,7 +302,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements | |||
| 
 | ||||
| 	public boolean isCurrentlyInCreation(String beanName) { | ||||
| 		Assert.notNull(beanName, "Bean name must not be null"); | ||||
| 		return (!this.inCreationCheckExclusions.containsKey(beanName) && isActuallyInCreation(beanName)); | ||||
| 		return (!this.inCreationCheckExclusions.contains(beanName) && isActuallyInCreation(beanName)); | ||||
| 	} | ||||
| 
 | ||||
| 	protected boolean isActuallyInCreation(String beanName) { | ||||
|  | @ -312,18 +315,18 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements | |||
| 	 * @param beanName the name of the bean | ||||
| 	 */ | ||||
| 	public boolean isSingletonCurrentlyInCreation(String beanName) { | ||||
| 		return this.singletonsCurrentlyInCreation.containsKey(beanName); | ||||
| 		return this.singletonsCurrentlyInCreation.contains(beanName); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Callback before singleton creation. | ||||
| 	 * <p>Default implementation register the singleton as currently in creation. | ||||
| 	 * <p>The default implementation register the singleton as currently in creation. | ||||
| 	 * @param beanName the name of the singleton about to be created | ||||
| 	 * @see #isSingletonCurrentlyInCreation | ||||
| 	 */ | ||||
| 	protected void beforeSingletonCreation(String beanName) { | ||||
| 		if (!this.inCreationCheckExclusions.containsKey(beanName) && | ||||
| 				this.singletonsCurrentlyInCreation.put(beanName, Boolean.TRUE) != null) { | ||||
| 		if (!this.inCreationCheckExclusions.contains(beanName) && | ||||
| 				!this.singletonsCurrentlyInCreation.add(beanName)) { | ||||
| 			throw new BeanCurrentlyInCreationException(beanName); | ||||
| 		} | ||||
| 	} | ||||
|  | @ -335,7 +338,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements | |||
| 	 * @see #isSingletonCurrentlyInCreation | ||||
| 	 */ | ||||
| 	protected void afterSingletonCreation(String beanName) { | ||||
| 		if (!this.inCreationCheckExclusions.containsKey(beanName) && | ||||
| 		if (!this.inCreationCheckExclusions.contains(beanName) && | ||||
| 				!this.singletonsCurrentlyInCreation.remove(beanName)) { | ||||
| 			throw new IllegalStateException("Singleton '" + beanName + "' isn't currently in creation"); | ||||
| 		} | ||||
|  |  | |||
|  | @ -18,7 +18,8 @@ package org.springframework.beans.factory.support; | |||
| 
 | ||||
| import java.lang.reflect.Member; | ||||
| import java.lang.reflect.Method; | ||||
| import java.util.Map; | ||||
| import java.util.Collections; | ||||
| import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| 
 | ||||
| import org.springframework.beans.MutablePropertyValues; | ||||
|  | @ -48,14 +49,14 @@ import org.springframework.util.Assert; | |||
| @SuppressWarnings("serial") | ||||
| public class RootBeanDefinition extends AbstractBeanDefinition { | ||||
| 
 | ||||
| 	// using a ConcurrentHashMap as a Set | ||||
| 	private final Map<Member, Boolean> externallyManagedConfigMembers = new ConcurrentHashMap<Member, Boolean>(0); | ||||
| 	private final Set<Member> externallyManagedConfigMembers = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<Member, Boolean>(0)); | ||||
| 
 | ||||
| 	// using a ConcurrentHashMap as a Set | ||||
| 	private final Map<String, Boolean> externallyManagedInitMethods = new ConcurrentHashMap<String, Boolean>(0); | ||||
| 	private final Set<String> externallyManagedInitMethods = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(0)); | ||||
| 
 | ||||
| 	// using a ConcurrentHashMap as a Set | ||||
| 	private final Map<String, Boolean> externallyManagedDestroyMethods = new ConcurrentHashMap<String, Boolean>(0); | ||||
| 	private final Set<String> externallyManagedDestroyMethods = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(0)); | ||||
| 
 | ||||
| 	private BeanDefinitionHolder decoratedDefinition; | ||||
| 
 | ||||
|  | @ -299,27 +300,27 @@ public class RootBeanDefinition extends AbstractBeanDefinition { | |||
| 
 | ||||
| 
 | ||||
| 	public void registerExternallyManagedConfigMember(Member configMember) { | ||||
| 		this.externallyManagedConfigMembers.put(configMember, Boolean.TRUE); | ||||
| 		this.externallyManagedConfigMembers.add(configMember); | ||||
| 	} | ||||
| 
 | ||||
| 	public boolean isExternallyManagedConfigMember(Member configMember) { | ||||
| 		return this.externallyManagedConfigMembers.containsKey(configMember); | ||||
| 		return this.externallyManagedConfigMembers.contains(configMember); | ||||
| 	} | ||||
| 
 | ||||
| 	public void registerExternallyManagedInitMethod(String initMethod) { | ||||
| 		this.externallyManagedInitMethods.put(initMethod, Boolean.TRUE); | ||||
| 		this.externallyManagedInitMethods.add(initMethod); | ||||
| 	} | ||||
| 
 | ||||
| 	public boolean isExternallyManagedInitMethod(String initMethod) { | ||||
| 		return this.externallyManagedInitMethods.containsKey(initMethod); | ||||
| 		return this.externallyManagedInitMethods.contains(initMethod); | ||||
| 	} | ||||
| 
 | ||||
| 	public void registerExternallyManagedDestroyMethod(String destroyMethod) { | ||||
| 		this.externallyManagedDestroyMethods.put(destroyMethod, Boolean.TRUE); | ||||
| 		this.externallyManagedDestroyMethods.add(destroyMethod); | ||||
| 	} | ||||
| 
 | ||||
| 	public boolean isExternallyManagedDestroyMethod(String destroyMethod) { | ||||
| 		return this.externallyManagedDestroyMethods.containsKey(destroyMethod); | ||||
| 		return this.externallyManagedDestroyMethods.contains(destroyMethod); | ||||
| 	} | ||||
| 
 | ||||
| 	public void setDecoratedDefinition(BeanDefinitionHolder decoratedDefinition) { | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
|  * Copyright 2002-2012 the original author or authors. | ||||
|  * Copyright 2002-2013 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  | @ -19,9 +19,9 @@ package org.springframework.web.bind.annotation.support; | |||
| import java.lang.reflect.Method; | ||||
| import java.lang.reflect.Proxy; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.HashSet; | ||||
| import java.util.LinkedHashSet; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| 
 | ||||
|  | @ -65,8 +65,8 @@ public class HandlerMethodResolver { | |||
| 
 | ||||
| 	private final Set<Class> sessionAttributeTypes = new HashSet<Class>(); | ||||
| 
 | ||||
| 	// using a ConcurrentHashMap as a Set | ||||
| 	private final Map<String, Boolean> actualSessionAttributeNames = new ConcurrentHashMap<String, Boolean>(4); | ||||
| 	private final Set<String> actualSessionAttributeNames = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(4)); | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
|  | @ -154,7 +154,7 @@ public class HandlerMethodResolver { | |||
| 
 | ||||
| 	public boolean isSessionAttribute(String attrName, Class attrType) { | ||||
| 		if (this.sessionAttributeNames.contains(attrName) || this.sessionAttributeTypes.contains(attrType)) { | ||||
| 			this.actualSessionAttributeNames.put(attrName, Boolean.TRUE); | ||||
| 			this.actualSessionAttributeNames.add(attrName); | ||||
| 			return true; | ||||
| 		} | ||||
| 		else { | ||||
|  | @ -163,7 +163,7 @@ public class HandlerMethodResolver { | |||
| 	} | ||||
| 
 | ||||
| 	public Set<String> getActualSessionAttributeNames() { | ||||
| 		return this.actualSessionAttributeNames.keySet(); | ||||
| 		return this.actualSessionAttributeNames; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
|  * Copyright 2002-2012 the original author or authors. | ||||
|  * Copyright 2002-2013 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  | @ -17,6 +17,7 @@ | |||
| package org.springframework.web.method.annotation; | ||||
| 
 | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.Map; | ||||
|  | @ -50,8 +51,8 @@ public class SessionAttributesHandler { | |||
| 
 | ||||
| 	private final Set<Class<?>> attributeTypes = new HashSet<Class<?>>(); | ||||
| 
 | ||||
| 	// using a ConcurrentHashMap as a Set | ||||
| 	private final Map<String, Boolean> knownAttributeNames = new ConcurrentHashMap<String, Boolean>(4); | ||||
| 	private final Set<String> knownAttributeNames = | ||||
| 			Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(4)); | ||||
| 
 | ||||
| 	private final SessionAttributeStore sessionAttributeStore; | ||||
| 
 | ||||
|  | @ -74,7 +75,7 @@ public class SessionAttributesHandler { | |||
| 		} | ||||
| 
 | ||||
| 		for (String attributeName : this.attributeNames) { | ||||
| 			this.knownAttributeNames.put(attributeName, Boolean.TRUE); | ||||
| 			this.knownAttributeNames.add(attributeName); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | @ -100,7 +101,7 @@ public class SessionAttributesHandler { | |||
| 	public boolean isHandlerSessionAttribute(String attributeName, Class<?> attributeType) { | ||||
| 		Assert.notNull(attributeName, "Attribute name must not be null"); | ||||
| 		if (this.attributeNames.contains(attributeName) || this.attributeTypes.contains(attributeType)) { | ||||
| 			this.knownAttributeNames.put(attributeName, Boolean.TRUE); | ||||
| 			this.knownAttributeNames.add(attributeName); | ||||
| 			return true; | ||||
| 		} | ||||
| 		else { | ||||
|  | @ -134,7 +135,7 @@ public class SessionAttributesHandler { | |||
| 	 */ | ||||
| 	public Map<String, Object> retrieveAttributes(WebRequest request) { | ||||
| 		Map<String, Object> attributes = new HashMap<String, Object>(); | ||||
| 		for (String name : this.knownAttributeNames.keySet()) { | ||||
| 		for (String name : this.knownAttributeNames) { | ||||
| 			Object value = this.sessionAttributeStore.retrieveAttribute(request, name); | ||||
| 			if (value != null) { | ||||
| 				attributes.put(name, value); | ||||
|  | @ -150,7 +151,7 @@ public class SessionAttributesHandler { | |||
| 	 * @param request the current request | ||||
| 	 */ | ||||
| 	public void cleanupAttributes(WebRequest request) { | ||||
| 		for (String attributeName : this.knownAttributeNames.keySet()) { | ||||
| 		for (String attributeName : this.knownAttributeNames) { | ||||
| 			this.sessionAttributeStore.cleanupAttribute(request, attributeName); | ||||
| 		} | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue