Java 5 code style

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@342 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller 2008-11-27 17:35:44 +00:00
parent a0dfb69aaa
commit e4ce547934
49 changed files with 353 additions and 477 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
package org.springframework.aop.aspectj; package org.springframework.aop.aspectj;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,7 +31,6 @@ import org.aspectj.weaver.tools.PointcutParser;
import org.aspectj.weaver.tools.PointcutPrimitive; import org.aspectj.weaver.tools.PointcutPrimitive;
import org.springframework.core.ParameterNameDiscoverer; import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -118,8 +118,6 @@ import org.springframework.util.StringUtils;
*/ */
public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscoverer { public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscoverer {
private static final String ANNOTATION_CLASS_NAME = "java.lang.annotation.Annotation";
private static final String THIS_JOIN_POINT = "thisJoinPoint"; private static final String THIS_JOIN_POINT = "thisJoinPoint";
private static final String THIS_JOIN_POINT_STATIC_PART = "thisJoinPointStaticPart"; private static final String THIS_JOIN_POINT_STATIC_PART = "thisJoinPointStaticPart";
@ -133,10 +131,8 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
private static final int STEP_REFERENCE_PCUT_BINDING = 7; private static final int STEP_REFERENCE_PCUT_BINDING = 7;
private static final int STEP_FINISHED = 8; private static final int STEP_FINISHED = 8;
private static final Set singleValuedAnnotationPcds = new HashSet(); private static final Set<String> singleValuedAnnotationPcds = new HashSet<String>();
private static final Set nonReferencePointcutTokens = new HashSet(); private static final Set<String> nonReferencePointcutTokens = new HashSet<String>();
private static Class annotationClass;
static { static {
@ -157,15 +153,6 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
nonReferencePointcutTokens.add("and"); nonReferencePointcutTokens.add("and");
nonReferencePointcutTokens.add("or"); nonReferencePointcutTokens.add("or");
nonReferencePointcutTokens.add("not"); nonReferencePointcutTokens.add("not");
try {
annotationClass = ClassUtils.forName(ANNOTATION_CLASS_NAME,
AspectJAdviceParameterNameDiscoverer.class.getClassLoader());
}
catch (ClassNotFoundException ex) {
// Running on < JDK 1.5, this is OK...
annotationClass = null;
}
} }
@ -192,8 +179,6 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
private int numberOfRemainingUnboundArguments; private int numberOfRemainingUnboundArguments;
private int algorithmicStep = STEP_JOIN_POINT_BINDING;
/** /**
* Create a new discoverer that attempts to discover parameter names * Create a new discoverer that attempts to discover parameter names
@ -241,7 +226,6 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
this.argumentTypes = method.getParameterTypes(); this.argumentTypes = method.getParameterTypes();
this.numberOfRemainingUnboundArguments = this.argumentTypes.length; this.numberOfRemainingUnboundArguments = this.argumentTypes.length;
this.parameterNameBindings = new String[this.numberOfRemainingUnboundArguments]; this.parameterNameBindings = new String[this.numberOfRemainingUnboundArguments];
this.algorithmicStep = STEP_JOIN_POINT_BINDING;
int minimumNumberUnboundArgs = 0; int minimumNumberUnboundArgs = 0;
if (this.returningName != null) { if (this.returningName != null) {
@ -256,8 +240,9 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
} }
try { try {
while ((this.numberOfRemainingUnboundArguments > 0) && (this.algorithmicStep < STEP_FINISHED)) { int algorithmicStep = STEP_JOIN_POINT_BINDING;
switch (this.algorithmicStep++) { while ((this.numberOfRemainingUnboundArguments > 0) && algorithmicStep < STEP_FINISHED) {
switch (algorithmicStep++) {
case STEP_JOIN_POINT_BINDING: case STEP_JOIN_POINT_BINDING:
if (!maybeBindThisJoinPoint()) { if (!maybeBindThisJoinPoint()) {
maybeBindThisJoinPointStaticPart(); maybeBindThisJoinPointStaticPart();
@ -282,7 +267,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
maybeBindReferencePointcutParameter(); maybeBindReferencePointcutParameter();
break; break;
default: default:
throw new IllegalStateException("Unknown algorithmic step: " + (this.algorithmicStep - 1)); throw new IllegalStateException("Unknown algorithmic step: " + (algorithmicStep - 1));
} }
} }
} }
@ -429,7 +414,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
* <p>Some more support from AspectJ in doing this exercise would be nice... :) * <p>Some more support from AspectJ in doing this exercise would be nice... :)
*/ */
private void maybeBindAnnotationsFromPointcutExpression() { private void maybeBindAnnotationsFromPointcutExpression() {
List varNames = new ArrayList(); List<String> varNames = new ArrayList<String>();
String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " "); String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " ");
for (int i = 0; i < tokens.length; i++) { for (int i = 0; i < tokens.length; i++) {
String toMatch = tokens[i]; String toMatch = tokens[i];
@ -458,7 +443,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
/** /**
* Match the given list of extracted variable names to argument slots. * Match the given list of extracted variable names to argument slots.
*/ */
private void bindAnnotationsFromVarNames(List varNames) { private void bindAnnotationsFromVarNames(List<String> varNames) {
if (!varNames.isEmpty()) { if (!varNames.isEmpty()) {
// we have work to do... // we have work to do...
int numAnnotationSlots = countNumberOfUnboundAnnotationArguments(); int numAnnotationSlots = countNumberOfUnboundAnnotationArguments();
@ -470,7 +455,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
else if (numAnnotationSlots == 1) { else if (numAnnotationSlots == 1) {
if (varNames.size() == 1) { if (varNames.size() == 1) {
// it's a match // it's a match
findAndBind(annotationClass, (String) varNames.get(0)); findAndBind(Annotation.class, varNames.get(0));
} }
else { else {
// multiple candidate vars, but only one slot // multiple candidate vars, but only one slot
@ -495,8 +480,8 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
if (Character.isJavaIdentifierStart(candidateToken.charAt(0)) && if (Character.isJavaIdentifierStart(candidateToken.charAt(0)) &&
Character.isLowerCase(candidateToken.charAt(0))) { Character.isLowerCase(candidateToken.charAt(0))) {
char[] tokenChars = candidateToken.toCharArray(); char[] tokenChars = candidateToken.toCharArray();
for (int i = 0; i < tokenChars.length; i++) { for (char tokenChar : tokenChars) {
if (!Character.isJavaIdentifierPart(tokenChars[i])) { if (!Character.isJavaIdentifierPart(tokenChar)) {
return null; return null;
} }
} }
@ -511,11 +496,10 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
* Given an args pointcut body (could be <code>args</code> or <code>at_args</code>), * Given an args pointcut body (could be <code>args</code> or <code>at_args</code>),
* add any candidate variable names to the given list. * add any candidate variable names to the given list.
*/ */
private void maybeExtractVariableNamesFromArgs(String argsSpec, List varNames) { private void maybeExtractVariableNamesFromArgs(String argsSpec, List<String> varNames) {
if (argsSpec == null) { if (argsSpec == null) {
return; return;
} }
String[] tokens = StringUtils.tokenizeToStringArray(argsSpec, ","); String[] tokens = StringUtils.tokenizeToStringArray(argsSpec, ",");
for (int i = 0; i < tokens.length; i++) { for (int i = 0; i < tokens.length; i++) {
tokens[i] = StringUtils.trimWhitespace(tokens[i]); tokens[i] = StringUtils.trimWhitespace(tokens[i]);
@ -536,7 +520,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
+ " unbound args at this(),target(),args() binding stage, with no way to determine between them"); + " unbound args at this(),target(),args() binding stage, with no way to determine between them");
} }
List varNames = new ArrayList(); List<String> varNames = new ArrayList<String>();
String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " "); String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " ");
for (int i = 0; i < tokens.length; i++) { for (int i = 0; i < tokens.length; i++) {
if (tokens[i].equals("this") || if (tokens[i].equals("this") ||
@ -553,12 +537,11 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
else if (tokens[i].equals("args") || tokens[i].startsWith("args(")) { else if (tokens[i].equals("args") || tokens[i].startsWith("args(")) {
PointcutBody body = getPointcutBody(tokens, i); PointcutBody body = getPointcutBody(tokens, i);
i += body.numTokensConsumed; i += body.numTokensConsumed;
List candidateVarNames = new ArrayList(); List<String> candidateVarNames = new ArrayList<String>();
maybeExtractVariableNamesFromArgs(body.text, candidateVarNames); maybeExtractVariableNamesFromArgs(body.text, candidateVarNames);
// we may have found some var names that were bound in previous primitive args binding step, // we may have found some var names that were bound in previous primitive args binding step,
// filter them out... // filter them out...
for (Iterator iter = candidateVarNames.iterator(); iter.hasNext();) { for (String varName : candidateVarNames) {
String varName = (String) iter.next();
if (!alreadyBound(varName)) { if (!alreadyBound(varName)) {
varNames.add(varName); varNames.add(varName);
} }
@ -574,7 +557,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
else if (varNames.size() == 1) { else if (varNames.size() == 1) {
for (int j = 0; j < this.parameterNameBindings.length; j++) { for (int j = 0; j < this.parameterNameBindings.length; j++) {
if (isUnbound(j)) { if (isUnbound(j)) {
bindParameterName(j, (String) varNames.get(0)); bindParameterName(j, varNames.get(0));
break; break;
} }
} }
@ -588,7 +571,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
+ " unbound args at reference pointcut binding stage, with no way to determine between them"); + " unbound args at reference pointcut binding stage, with no way to determine between them");
} }
List varNames = new ArrayList(); List<String> varNames = new ArrayList<String>();
String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " "); String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " ");
for (int i = 0; i < tokens.length; i++) { for (int i = 0; i < tokens.length; i++) {
String toMatch = tokens[i]; String toMatch = tokens[i];
@ -634,7 +617,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
else if (varNames.size() == 1) { else if (varNames.size() == 1) {
for (int j = 0; j < this.parameterNameBindings.length; j++) { for (int j = 0; j < this.parameterNameBindings.length; j++) {
if (isUnbound(j)) { if (isUnbound(j)) {
bindParameterName(j, (String) varNames.get(0)); bindParameterName(j, varNames.get(0));
break; break;
} }
} }
@ -700,7 +683,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
} }
if (numUnboundPrimitives == 1) { if (numUnboundPrimitives == 1) {
// Look for arg variable and bind it if we find exactly one... // Look for arg variable and bind it if we find exactly one...
List varNames = new ArrayList(); List<String> varNames = new ArrayList<String>();
String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " "); String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " ");
for (int i = 0; i < tokens.length; i++) { for (int i = 0; i < tokens.length; i++) {
if (tokens[i].equals("args") || tokens[i].startsWith("args(")) { if (tokens[i].equals("args") || tokens[i].startsWith("args(")) {
@ -751,14 +734,9 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
} }
private int countNumberOfUnboundAnnotationArguments() { private int countNumberOfUnboundAnnotationArguments() {
if (annotationClass == null) {
// We're running on a JDK < 1.5
return 0;
}
int count = 0; int count = 0;
for (int i = 0; i < this.argumentTypes.length; i++) { for (int i = 0; i < this.argumentTypes.length; i++) {
if (isUnbound(i) && isSubtypeOf(annotationClass, i)) { if (isUnbound(i) && isSubtypeOf(Annotation.class, i)) {
count++; count++;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,15 +19,14 @@ package org.springframework.aop.config;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
import org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator; import org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator;
import org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator; import org.springframework.aop.framework.autoproxy.InfrastructureAdvisorAutoProxyCreator;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.JdkVersion;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/** /**
* Utility class for handling registration of AOP auto-proxy creators. * Utility class for handling registration of AOP auto-proxy creators.
@ -52,26 +51,18 @@ public abstract class AopConfigUtils {
public static final String AUTO_PROXY_CREATOR_BEAN_NAME = public static final String AUTO_PROXY_CREATOR_BEAN_NAME =
"org.springframework.aop.config.internalAutoProxyCreator"; "org.springframework.aop.config.internalAutoProxyCreator";
/**
* The class name of the <code>AnnotationAwareAspectJAutoProxyCreator</code> class.
* Only available with AspectJ and Java 5.
*/
private static final String ASPECTJ_ANNOTATION_AUTO_PROXY_CREATOR_CLASS_NAME =
"org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator";
/** /**
* Stores the auto proxy creator classes in escalation order. * Stores the auto proxy creator classes in escalation order.
*/ */
private static final List APC_PRIORITY_LIST = new ArrayList(); private static final List<Class> APC_PRIORITY_LIST = new ArrayList<Class>();
/** /**
* Setup the escalation list. * Setup the escalation list.
*/ */
static { static {
APC_PRIORITY_LIST.add(InfrastructureAdvisorAutoProxyCreator.class.getName()); APC_PRIORITY_LIST.add(InfrastructureAdvisorAutoProxyCreator.class);
APC_PRIORITY_LIST.add(AspectJAwareAdvisorAutoProxyCreator.class.getName()); APC_PRIORITY_LIST.add(AspectJAwareAdvisorAutoProxyCreator.class);
APC_PRIORITY_LIST.add(ASPECTJ_ANNOTATION_AUTO_PROXY_CREATOR_CLASS_NAME); APC_PRIORITY_LIST.add(AnnotationAwareAspectJAutoProxyCreator.class);
} }
@ -96,8 +87,7 @@ public abstract class AopConfigUtils {
} }
public static BeanDefinition registerAspectJAnnotationAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry, Object source) { public static BeanDefinition registerAspectJAnnotationAutoProxyCreatorIfNecessary(BeanDefinitionRegistry registry, Object source) {
Class cls = getAspectJAnnotationAutoProxyCreatorClassIfPossible(); return registerOrEscalateApcAsRequired(AnnotationAwareAspectJAutoProxyCreator.class, registry, source);
return registerOrEscalateApcAsRequired(cls, registry, source);
} }
public static void forceAutoProxyCreatorToUseClassProxying(BeanDefinitionRegistry registry) { public static void forceAutoProxyCreatorToUseClassProxying(BeanDefinitionRegistry registry) {
@ -114,7 +104,7 @@ public abstract class AopConfigUtils {
BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME); BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
if (!cls.getName().equals(apcDefinition.getBeanClassName())) { if (!cls.getName().equals(apcDefinition.getBeanClassName())) {
int currentPriority = findPriorityForClass(apcDefinition.getBeanClassName()); int currentPriority = findPriorityForClass(apcDefinition.getBeanClassName());
int requiredPriority = findPriorityForClass(cls.getName()); int requiredPriority = findPriorityForClass(cls);
if (currentPriority < requiredPriority) { if (currentPriority < requiredPriority) {
apcDefinition.setBeanClassName(cls.getName()); apcDefinition.setBeanClassName(cls.getName());
} }
@ -123,32 +113,20 @@ public abstract class AopConfigUtils {
} }
RootBeanDefinition beanDefinition = new RootBeanDefinition(cls); RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
beanDefinition.setSource(source); beanDefinition.setSource(source);
beanDefinition.getPropertyValues().addPropertyValue("order", new Integer(Ordered.HIGHEST_PRECEDENCE)); beanDefinition.getPropertyValues().addPropertyValue("order", Ordered.HIGHEST_PRECEDENCE);
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
registry.registerBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME, beanDefinition); registry.registerBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME, beanDefinition);
return beanDefinition; return beanDefinition;
} }
private static Class getAspectJAnnotationAutoProxyCreatorClassIfPossible() { private static int findPriorityForClass(Class clazz) {
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) { return APC_PRIORITY_LIST.indexOf(clazz);
throw new IllegalStateException(
"AnnotationAwareAspectJAutoProxyCreator is only available on Java 1.5 and higher");
}
try {
return ClassUtils.forName(
ASPECTJ_ANNOTATION_AUTO_PROXY_CREATOR_CLASS_NAME, AopConfigUtils.class.getClassLoader());
}
catch (Throwable ex) {
throw new IllegalStateException("Unable to load Java 1.5 dependent class [" +
ASPECTJ_ANNOTATION_AUTO_PROXY_CREATOR_CLASS_NAME + "]", ex);
}
} }
private static int findPriorityForClass(String className) { private static int findPriorityForClass(String className) {
Assert.notNull(className, "Class name must not be null");
for (int i = 0; i < APC_PRIORITY_LIST.size(); i++) { for (int i = 0; i < APC_PRIORITY_LIST.size(); i++) {
String str = (String) APC_PRIORITY_LIST.get(i); Class clazz = APC_PRIORITY_LIST.get(i);
if (className.equals(str)) { if (clazz.getName().equals(className)) {
return i; return i;
} }
} }

View File

@ -61,68 +61,37 @@ import org.springframework.util.xml.DomUtils;
class ConfigBeanDefinitionParser implements BeanDefinitionParser { class ConfigBeanDefinitionParser implements BeanDefinitionParser {
private static final String ASPECT = "aspect"; private static final String ASPECT = "aspect";
private static final String EXPRESSION = "expression"; private static final String EXPRESSION = "expression";
private static final String ID = "id"; private static final String ID = "id";
private static final String POINTCUT = "pointcut"; private static final String POINTCUT = "pointcut";
private static final String ADVICE_BEAN_NAME = "adviceBeanName"; private static final String ADVICE_BEAN_NAME = "adviceBeanName";
private static final String ADVISOR = "advisor"; private static final String ADVISOR = "advisor";
private static final String ADVICE_REF = "advice-ref"; private static final String ADVICE_REF = "advice-ref";
private static final String POINTCUT_REF = "pointcut-ref"; private static final String POINTCUT_REF = "pointcut-ref";
private static final String REF = "ref"; private static final String REF = "ref";
private static final String BEFORE = "before"; private static final String BEFORE = "before";
private static final String DECLARE_PARENTS = "declare-parents"; private static final String DECLARE_PARENTS = "declare-parents";
private static final String TYPE_PATTERN = "types-matching"; private static final String TYPE_PATTERN = "types-matching";
private static final String DEFAULT_IMPL = "default-impl"; private static final String DEFAULT_IMPL = "default-impl";
private static final String DELEGATE_REF = "delegate-ref"; private static final String DELEGATE_REF = "delegate-ref";
private static final String IMPLEMENT_INTERFACE = "implement-interface"; private static final String IMPLEMENT_INTERFACE = "implement-interface";
private static final String AFTER = "after"; private static final String AFTER = "after";
private static final String AFTER_RETURNING_ELEMENT = "after-returning"; private static final String AFTER_RETURNING_ELEMENT = "after-returning";
private static final String AFTER_THROWING_ELEMENT = "after-throwing"; private static final String AFTER_THROWING_ELEMENT = "after-throwing";
private static final String AROUND = "around"; private static final String AROUND = "around";
private static final String RETURNING = "returning"; private static final String RETURNING = "returning";
private static final String RETURNING_PROPERTY = "returningName"; private static final String RETURNING_PROPERTY = "returningName";
private static final String THROWING = "throwing"; private static final String THROWING = "throwing";
private static final String THROWING_PROPERTY = "throwingName"; private static final String THROWING_PROPERTY = "throwingName";
private static final String ARG_NAMES = "arg-names"; private static final String ARG_NAMES = "arg-names";
private static final String ARG_NAMES_PROPERTY = "argumentNames"; private static final String ARG_NAMES_PROPERTY = "argumentNames";
private static final String ASPECT_NAME_PROPERTY = "aspectName"; private static final String ASPECT_NAME_PROPERTY = "aspectName";
private static final String DECLARATION_ORDER_PROPERTY = "declarationOrder"; private static final String DECLARATION_ORDER_PROPERTY = "declarationOrder";
private static final String ORDER_PROPERTY = "order"; private static final String ORDER_PROPERTY = "order";
private static final int METHOD_INDEX = 0; private static final int METHOD_INDEX = 0;
private static final int POINTCUT_INDEX = 1; private static final int POINTCUT_INDEX = 1;
private static final int ASPECT_INSTANCE_FACTORY_INDEX = 2; private static final int ASPECT_INSTANCE_FACTORY_INDEX = 2;
private ParseState parseState = new ParseState(); private ParseState parseState = new ParseState();
@ -232,12 +201,12 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
try { try {
this.parseState.push(new AspectEntry(aspectId, aspectName)); this.parseState.push(new AspectEntry(aspectId, aspectName));
List beanDefinitions = new ArrayList(); List<BeanDefinition> beanDefinitions = new ArrayList<BeanDefinition>();
List beanReferences = new ArrayList(); List<BeanReference> beanReferences = new ArrayList<BeanReference>();
List declareParents = DomUtils.getChildElementsByTagName(aspectElement, DECLARE_PARENTS); List<Element> declareParents = DomUtils.getChildElementsByTagName(aspectElement, DECLARE_PARENTS);
for (int i = METHOD_INDEX; i < declareParents.size(); i++) { for (int i = METHOD_INDEX; i < declareParents.size(); i++) {
Element declareParentsElement = (Element) declareParents.get(i); Element declareParentsElement = declareParents.get(i);
beanDefinitions.add(parseDeclareParents(declareParentsElement, parserContext)); beanDefinitions.add(parseDeclareParents(declareParentsElement, parserContext));
} }
@ -268,9 +237,8 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
aspectElement, aspectId, beanDefinitions, beanReferences, parserContext); aspectElement, aspectId, beanDefinitions, beanReferences, parserContext);
parserContext.pushContainingComponent(aspectComponentDefinition); parserContext.pushContainingComponent(aspectComponentDefinition);
List pointcuts = DomUtils.getChildElementsByTagName(aspectElement, POINTCUT); List<Element> pointcuts = DomUtils.getChildElementsByTagName(aspectElement, POINTCUT);
for (int i = 0; i < pointcuts.size(); i++) { for (Element pointcutElement : pointcuts) {
Element pointcutElement = (Element) pointcuts.get(i);
parsePointcut(pointcutElement, parserContext); parsePointcut(pointcutElement, parserContext);
} }
@ -282,10 +250,11 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
} }
private AspectComponentDefinition createAspectComponentDefinition( private AspectComponentDefinition createAspectComponentDefinition(
Element aspectElement, String aspectId, List beanDefs, List beanRefs, ParserContext parserContext) { Element aspectElement, String aspectId, List<BeanDefinition> beanDefs,
List<BeanReference> beanRefs, ParserContext parserContext) {
BeanDefinition[] beanDefArray = (BeanDefinition[]) beanDefs.toArray(new BeanDefinition[beanDefs.size()]); BeanDefinition[] beanDefArray = beanDefs.toArray(new BeanDefinition[beanDefs.size()]);
BeanReference[] beanRefArray = (BeanReference[]) beanRefs.toArray(new BeanReference[beanRefs.size()]); BeanReference[] beanRefArray = beanRefs.toArray(new BeanReference[beanRefs.size()]);
Object source = parserContext.extractSource(aspectElement); Object source = parserContext.extractSource(aspectElement);
return new AspectComponentDefinition(aspectId, beanDefArray, beanRefArray, source); return new AspectComponentDefinition(aspectId, beanDefArray, beanRefArray, source);
} }
@ -345,7 +314,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
*/ */
private AbstractBeanDefinition parseAdvice( private AbstractBeanDefinition parseAdvice(
String aspectName, int order, Element aspectElement, Element adviceElement, ParserContext parserContext, String aspectName, int order, Element aspectElement, Element adviceElement, ParserContext parserContext,
List beanDefinitions, List beanReferences) { List<BeanDefinition> beanDefinitions, List<BeanReference> beanReferences) {
try { try {
this.parseState.push(new AdviceEntry(adviceElement.getLocalName())); this.parseState.push(new AdviceEntry(adviceElement.getLocalName()));
@ -394,15 +363,14 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
*/ */
private AbstractBeanDefinition createAdviceDefinition( private AbstractBeanDefinition createAdviceDefinition(
Element adviceElement, ParserContext parserContext, String aspectName, int order, Element adviceElement, ParserContext parserContext, String aspectName, int order,
RootBeanDefinition methodDef, RootBeanDefinition aspectFactoryDef, List beanDefinitions, List beanReferences) { RootBeanDefinition methodDef, RootBeanDefinition aspectFactoryDef,
List<BeanDefinition> beanDefinitions, List<BeanReference> beanReferences) {
RootBeanDefinition adviceDefinition = new RootBeanDefinition(getAdviceClass(adviceElement)); RootBeanDefinition adviceDefinition = new RootBeanDefinition(getAdviceClass(adviceElement));
adviceDefinition.setSource(parserContext.extractSource(adviceElement)); adviceDefinition.setSource(parserContext.extractSource(adviceElement));
adviceDefinition.getPropertyValues().addPropertyValue( adviceDefinition.getPropertyValues().addPropertyValue(ASPECT_NAME_PROPERTY, aspectName);
ASPECT_NAME_PROPERTY, aspectName); adviceDefinition.getPropertyValues().addPropertyValue(DECLARATION_ORDER_PROPERTY, order);
adviceDefinition.getPropertyValues().addPropertyValue(
DECLARATION_ORDER_PROPERTY, new Integer(order));
if (adviceElement.hasAttribute(RETURNING)) { if (adviceElement.hasAttribute(RETURNING)) {
adviceDefinition.getPropertyValues().addPropertyValue( adviceDefinition.getPropertyValues().addPropertyValue(
@ -423,7 +391,7 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser {
Object pointcut = parsePointcutProperty(adviceElement, parserContext); Object pointcut = parsePointcutProperty(adviceElement, parserContext);
if (pointcut instanceof BeanDefinition) { if (pointcut instanceof BeanDefinition) {
cav.addIndexedArgumentValue(POINTCUT_INDEX, pointcut); cav.addIndexedArgumentValue(POINTCUT_INDEX, pointcut);
beanDefinitions.add(pointcut); beanDefinitions.add((BeanDefinition) pointcut);
} }
else if (pointcut instanceof String) { else if (pointcut instanceof String) {
RuntimeBeanReference pointcutRef = new RuntimeBeanReference((String) pointcut); RuntimeBeanReference pointcutRef = new RuntimeBeanReference((String) pointcut);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,11 +31,9 @@ import org.springframework.util.Assert;
*/ */
public class ProxyCreatorSupport extends AdvisedSupport { public class ProxyCreatorSupport extends AdvisedSupport {
/** The AopProxyFactory to use */
private AopProxyFactory aopProxyFactory; private AopProxyFactory aopProxyFactory;
/** List of AdvisedSupportListener */ private List<AdvisedSupportListener> listeners = new LinkedList<AdvisedSupportListener>();
private List listeners = new LinkedList();
/** Set to true when the first AOP proxy has been created */ /** Set to true when the first AOP proxy has been created */
private boolean active = false; private boolean active = false;
@ -112,8 +110,8 @@ public class ProxyCreatorSupport extends AdvisedSupport {
*/ */
private void activate() { private void activate() {
this.active = true; this.active = true;
for (int i = 0; i < this.listeners.size(); i++) { for (AdvisedSupportListener listener : this.listeners) {
((AdvisedSupportListener) this.listeners.get(i)).activated(this); listener.activated(this);
} }
} }
@ -126,8 +124,8 @@ public class ProxyCreatorSupport extends AdvisedSupport {
super.adviceChanged(); super.adviceChanged();
synchronized (this) { synchronized (this) {
if (this.active) { if (this.active) {
for (int i = 0; i < this.listeners.size(); i++) { for (AdvisedSupportListener listener : this.listeners) {
((AdvisedSupportListener) this.listeners.get(i)).adviceChanged(this); listener.adviceChanged(this);
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,7 +39,7 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
*/ */
public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Serializable { public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Serializable {
private final List adapters = new ArrayList(3); private final List<AdvisorAdapter> adapters = new ArrayList<AdvisorAdapter>(3);
/** /**
@ -64,9 +64,8 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
// So well-known it doesn't even need an adapter. // So well-known it doesn't even need an adapter.
return new DefaultPointcutAdvisor(advice); return new DefaultPointcutAdvisor(advice);
} }
for (int i = 0; i < this.adapters.size(); i++) { for (AdvisorAdapter adapter : this.adapters) {
// Check that it is supported. // Check that it is supported.
AdvisorAdapter adapter = (AdvisorAdapter) this.adapters.get(i);
if (adapter.supportsAdvice(advice)) { if (adapter.supportsAdvice(advice)) {
return new DefaultPointcutAdvisor(advice); return new DefaultPointcutAdvisor(advice);
} }
@ -75,13 +74,12 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
} }
public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException { public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException {
List interceptors = new ArrayList(3); List<MethodInterceptor> interceptors = new ArrayList<MethodInterceptor>(3);
Advice advice = advisor.getAdvice(); Advice advice = advisor.getAdvice();
if (advice instanceof MethodInterceptor) { if (advice instanceof MethodInterceptor) {
interceptors.add(advice); interceptors.add((MethodInterceptor) advice);
} }
for (int i = 0; i < this.adapters.size(); i++) { for (AdvisorAdapter adapter : this.adapters) {
AdvisorAdapter adapter = (AdvisorAdapter) this.adapters.get(i);
if (adapter.supportsAdvice(advice)) { if (adapter.supportsAdvice(advice)) {
interceptors.add(adapter.getInterceptor(advisor)); interceptors.add(adapter.getInterceptor(advisor));
} }
@ -89,7 +87,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
if (interceptors.isEmpty()) { if (interceptors.isEmpty()) {
throw new UnknownAdviceTypeException(advisor.getAdvice()); throw new UnknownAdviceTypeException(advisor.getAdvice());
} }
return (MethodInterceptor[]) interceptors.toArray(new MethodInterceptor[interceptors.size()]); return interceptors.toArray(new MethodInterceptor[interceptors.size()]);
} }
public void registerAdvisorAdapter(AdvisorAdapter adapter) { public void registerAdvisorAdapter(AdvisorAdapter adapter) {

View File

@ -62,7 +62,7 @@ public class BeanFactoryAdvisorRetrievalHelper {
* @return the list of {@link org.springframework.aop.Advisor} beans * @return the list of {@link org.springframework.aop.Advisor} beans
* @see #isEligibleBean * @see #isEligibleBean
*/ */
public List findAdvisorBeans() { public List<Advisor> findAdvisorBeans() {
// Determine list of advisor bean names, if not cached already. // Determine list of advisor bean names, if not cached already.
String[] advisorNames = null; String[] advisorNames = null;
synchronized (this) { synchronized (this) {
@ -76,7 +76,7 @@ public class BeanFactoryAdvisorRetrievalHelper {
} }
} }
if (advisorNames.length == 0) { if (advisorNames.length == 0) {
return new LinkedList(); return new LinkedList<Advisor>();
} }
List<Advisor> advisors = new LinkedList<Advisor>(); List<Advisor> advisors = new LinkedList<Advisor>();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ import java.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Arrays;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.PatternMatchUtils; import org.springframework.util.PatternMatchUtils;
@ -36,7 +37,7 @@ import org.springframework.util.PatternMatchUtils;
*/ */
public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut implements Serializable { public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut implements Serializable {
private List mappedNames = new LinkedList(); private List<String> mappedNames = new LinkedList<String>();
/** /**
@ -54,11 +55,9 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
* the pointcut matches. * the pointcut matches.
*/ */
public void setMappedNames(String[] mappedNames) { public void setMappedNames(String[] mappedNames) {
this.mappedNames = new LinkedList(); this.mappedNames = new LinkedList<String>();
if (mappedNames != null) { if (mappedNames != null) {
for (int i = 0; i < mappedNames.length; i++) { this.mappedNames.addAll(Arrays.asList(mappedNames));
this.mappedNames.add(mappedNames[i]);
}
} }
} }
@ -72,16 +71,13 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
* @return this pointcut to allow for multiple additions in one line * @return this pointcut to allow for multiple additions in one line
*/ */
public NameMatchMethodPointcut addMethodName(String name) { public NameMatchMethodPointcut addMethodName(String name) {
// TODO in a future release, consider a way of letting proxies
// cause advice changed events.
this.mappedNames.add(name); this.mappedNames.add(name);
return this; return this;
} }
public boolean matches(Method method, Class targetClass) { public boolean matches(Method method, Class targetClass) {
for (int i = 0; i < this.mappedNames.size(); i++) { for (String mappedName : this.mappedNames) {
String mappedName = (String) this.mappedNames.get(i);
if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) { if (mappedName.equals(method.getName()) || isMatch(method.getName(), mappedName)) {
return true; return true;
} }
@ -105,11 +101,8 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (this == other) { return (this == other || (other instanceof NameMatchMethodPointcut &&
return true; ObjectUtils.nullSafeEquals(this.mappedNames, ((NameMatchMethodPointcut) other).mappedNames)));
}
return (other instanceof NameMatchMethodPointcut &&
ObjectUtils.nullSafeEquals(this.mappedNames, ((NameMatchMethodPointcut) other).mappedNames));
} }
@Override @Override

View File

@ -481,7 +481,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
private PropertyTokenHolder getPropertyNameTokens(String propertyName) { private PropertyTokenHolder getPropertyNameTokens(String propertyName) {
PropertyTokenHolder tokens = new PropertyTokenHolder(); PropertyTokenHolder tokens = new PropertyTokenHolder();
String actualName = null; String actualName = null;
List keys = new ArrayList(2); List<String> keys = new ArrayList<String>(2);
int searchIndex = 0; int searchIndex = 0;
while (searchIndex != -1) { while (searchIndex != -1) {
int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex); int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex);

View File

@ -129,10 +129,10 @@ final class PropertyMatches {
* @param maxDistance the maximum distance to accept * @param maxDistance the maximum distance to accept
*/ */
private String[] calculateMatches(PropertyDescriptor[] propertyDescriptors, int maxDistance) { private String[] calculateMatches(PropertyDescriptor[] propertyDescriptors, int maxDistance) {
List candidates = new ArrayList(); List<String> candidates = new ArrayList<String>();
for (int i = 0; i < propertyDescriptors.length; i++) { for (PropertyDescriptor pd : propertyDescriptors) {
if (propertyDescriptors[i].getWriteMethod() != null) { if (pd.getWriteMethod() != null) {
String possibleAlternative = propertyDescriptors[i].getName(); String possibleAlternative = pd.getName();
if (calculateStringDistance(this.propertyName, possibleAlternative) <= maxDistance) { if (calculateStringDistance(this.propertyName, possibleAlternative) <= maxDistance) {
candidates.add(possibleAlternative); candidates.add(possibleAlternative);
} }

View File

@ -71,7 +71,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
private boolean ignoreInvalidKeys = false; private boolean ignoreInvalidKeys = false;
/** Contains names of beans that have overrides */ /** Contains names of beans that have overrides */
private Set beanNames = Collections.synchronizedSet(new HashSet()); private Set<String> beanNames = Collections.synchronizedSet(new HashSet<String>());
/** /**

View File

@ -73,8 +73,8 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com
private void findInnerBeanDefinitionsAndBeanReferences(BeanDefinition beanDefinition) { private void findInnerBeanDefinitionsAndBeanReferences(BeanDefinition beanDefinition) {
List innerBeans = new ArrayList(); List<BeanDefinition> innerBeans = new ArrayList<BeanDefinition>();
List references = new ArrayList(); List<BeanReference> references = new ArrayList<BeanReference>();
PropertyValues propertyValues = beanDefinition.getPropertyValues(); PropertyValues propertyValues = beanDefinition.getPropertyValues();
for (int i = 0; i < propertyValues.getPropertyValues().length; i++) { for (int i = 0; i < propertyValues.getPropertyValues().length; i++) {
PropertyValue propertyValue = propertyValues.getPropertyValues()[i]; PropertyValue propertyValue = propertyValues.getPropertyValues()[i];
@ -83,14 +83,14 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com
innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition()); innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition());
} }
else if (value instanceof BeanDefinition) { else if (value instanceof BeanDefinition) {
innerBeans.add(value); innerBeans.add((BeanDefinition) value);
} }
else if (value instanceof BeanReference) { else if (value instanceof BeanReference) {
references.add(value); references.add((BeanReference) value);
} }
} }
this.innerBeanDefinitions = (BeanDefinition[]) innerBeans.toArray(new BeanDefinition[innerBeans.size()]); this.innerBeanDefinitions = innerBeans.toArray(new BeanDefinition[innerBeans.size()]);
this.beanReferences = (BeanReference[]) references.toArray(new BeanReference[references.size()]); this.beanReferences = references.toArray(new BeanReference[references.size()]);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,7 +36,7 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition {
private final Object source; private final Object source;
private final List nestedComponents = new LinkedList(); private final List<ComponentDefinition> nestedComponents = new LinkedList<ComponentDefinition>();
/** /**
@ -74,8 +74,7 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition {
* @return the array of nested components, or an empty array if none * @return the array of nested components, or an empty array if none
*/ */
public ComponentDefinition[] getNestedComponents() { public ComponentDefinition[] getNestedComponents() {
return (ComponentDefinition[]) return this.nestedComponents.toArray(new ComponentDefinition[this.nestedComponents.size()]);
this.nestedComponents.toArray(new ComponentDefinition[this.nestedComponents.size()]);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.beans.factory.serviceloader; package org.springframework.beans.factory.serviceloader;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.ServiceLoader; import java.util.ServiceLoader;
@ -36,10 +35,9 @@ public class ServiceListFactoryBean extends AbstractServiceLoaderBasedFactoryBea
@Override @Override
protected Object getObjectToExpose(ServiceLoader serviceLoader) { protected Object getObjectToExpose(ServiceLoader serviceLoader) {
List result = new LinkedList(); List<Object> result = new LinkedList<Object>();
Iterator it = serviceLoader.iterator(); for (Object loaderObject : serviceLoader) {
while (it.hasNext()) { result.add(loaderObject);
result.add(it.next());
} }
return result; return result;
} }

View File

@ -295,7 +295,7 @@ class BeanDefinitionValueResolver {
* For each element in the ManagedList, resolve reference if necessary. * For each element in the ManagedList, resolve reference if necessary.
*/ */
private List resolveManagedList(Object argName, List<?> ml) { private List resolveManagedList(Object argName, List<?> ml) {
List resolved = new ArrayList(ml.size()); List<Object> resolved = new ArrayList<Object>(ml.size());
for (int i = 0; i < ml.size(); i++) { for (int i = 0; i < ml.size(); i++) {
resolved.add( resolved.add(
resolveValueIfNecessary( resolveValueIfNecessary(
@ -309,7 +309,7 @@ class BeanDefinitionValueResolver {
* For each element in the ManagedList, resolve reference if necessary. * For each element in the ManagedList, resolve reference if necessary.
*/ */
private Set resolveManagedSet(Object argName, Set<?> ms) { private Set resolveManagedSet(Object argName, Set<?> ms) {
Set resolved = new LinkedHashSet(ms.size()); Set<Object> resolved = new LinkedHashSet<Object>(ms.size());
int i = 0; int i = 0;
for (Object m : ms) { for (Object m : ms) {
resolved.add(resolveValueIfNecessary( resolved.add(resolveValueIfNecessary(
@ -323,7 +323,7 @@ class BeanDefinitionValueResolver {
* For each element in the ManagedMap, resolve reference if necessary. * For each element in the ManagedMap, resolve reference if necessary.
*/ */
private Map resolveManagedMap(Object argName, Map<?, ?> mm) { private Map resolveManagedMap(Object argName, Map<?, ?> mm) {
Map resolved = new LinkedHashMap(mm.size()); Map<Object, Object> resolved = new LinkedHashMap<Object, Object>(mm.size());
for (Map.Entry entry : mm.entrySet()) { for (Map.Entry entry : mm.entrySet()) {
Object resolvedKey = resolveValueIfNecessary(argName, entry.getKey()); Object resolvedKey = resolveValueIfNecessary(argName, entry.getKey());
Object resolvedValue = resolveValueIfNecessary( Object resolvedValue = resolveValueIfNecessary(

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,10 +38,7 @@ public class ReplaceOverride extends MethodOverride {
private final String methodReplacerBeanName; private final String methodReplacerBeanName;
/** private List<String> typeIdentifiers = new LinkedList<String>();
* List of String. Identifying signatures.
*/
private List typeIdentifiers = new LinkedList();
/** /**
@ -90,8 +87,8 @@ public class ReplaceOverride extends MethodOverride {
return false; return false;
} }
for (int i = 0; i < this.typeIdentifiers.size(); i++) { for (int i = 0; i < this.typeIdentifiers.size(); i++) {
String identifier = (String) this.typeIdentifiers.get(i); String identifier = this.typeIdentifiers.get(i);
if (method.getParameterTypes()[i].getName().indexOf(identifier) == -1) { if (!method.getParameterTypes()[i].getName().contains(identifier)) {
// This parameter cannot match. // This parameter cannot match.
return false; return false;
} }

View File

@ -45,11 +45,11 @@ import org.springframework.beans.factory.config.ConstructorArgumentValues;
*/ */
public class RootBeanDefinition extends AbstractBeanDefinition { public class RootBeanDefinition extends AbstractBeanDefinition {
private final Set externallyManagedConfigMembers = Collections.synchronizedSet(new HashSet()); private final Set<Member> externallyManagedConfigMembers = Collections.synchronizedSet(new HashSet<Member>());
private final Set externallyManagedInitMethods = Collections.synchronizedSet(new HashSet()); private final Set<String> externallyManagedInitMethods = Collections.synchronizedSet(new HashSet<String>());
private final Set externallyManagedDestroyMethods = Collections.synchronizedSet(new HashSet()); private final Set<String> externallyManagedDestroyMethods = Collections.synchronizedSet(new HashSet<String>());
/** Package-visible field for caching the resolved constructor or factory method */ /** Package-visible field for caching the resolved constructor or factory method */
volatile Object resolvedConstructorOrFactoryMethod; volatile Object resolvedConstructorOrFactoryMethod;

View File

@ -238,7 +238,7 @@ public class BeanDefinitionParserDelegate {
/** /**
* Stores all used bean names so we can enforce uniqueness on a per file basis. * Stores all used bean names so we can enforce uniqueness on a per file basis.
*/ */
private final Set usedNames = new HashSet(); private final Set<String> usedNames = new HashSet<String>();
/** /**
@ -366,7 +366,7 @@ public class BeanDefinitionParserDelegate {
String id = ele.getAttribute(ID_ATTRIBUTE); String id = ele.getAttribute(ID_ATTRIBUTE);
String nameAttr = ele.getAttribute(NAME_ATTRIBUTE); String nameAttr = ele.getAttribute(NAME_ATTRIBUTE);
List aliases = new ArrayList(); List<String> aliases = new ArrayList<String>();
if (StringUtils.hasLength(nameAttr)) { if (StringUtils.hasLength(nameAttr)) {
String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, BEAN_NAME_DELIMITERS); String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, BEAN_NAME_DELIMITERS);
aliases.addAll(Arrays.asList(nameArr)); aliases.addAll(Arrays.asList(nameArr));

View File

@ -170,12 +170,12 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
if (ResourcePatternUtils.isUrl(location)) { if (ResourcePatternUtils.isUrl(location)) {
try { try {
Set actualResources = new LinkedHashSet(4); Set<Resource> actualResources = new LinkedHashSet<Resource> (4);
int importCount = getReaderContext().getReader().loadBeanDefinitions(location, actualResources); int importCount = getReaderContext().getReader().loadBeanDefinitions(location, actualResources);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Imported " + importCount + " bean definitions from URL location [" + location + "]"); logger.debug("Imported " + importCount + " bean definitions from URL location [" + location + "]");
} }
Resource[] actResArray = (Resource[]) actualResources.toArray(new Resource[actualResources.size()]); Resource[] actResArray = actualResources.toArray(new Resource[actualResources.size()]);
getReaderContext().fireImportProcessed(location, actResArray, extractSource(ele)); getReaderContext().fireImportProcessed(location, actResArray, extractSource(ele));
} }
catch (BeanDefinitionStoreException ex) { catch (BeanDefinitionStoreException ex) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -80,15 +80,15 @@ public class FreeMarkerConfigurationFactory {
private Properties freemarkerSettings; private Properties freemarkerSettings;
private Map freemarkerVariables; private Map<String, Object> freemarkerVariables;
private String defaultEncoding; private String defaultEncoding;
private final List templateLoaders = new ArrayList(); private final List<TemplateLoader> templateLoaders = new ArrayList<TemplateLoader>();
private List preTemplateLoaders; private List<TemplateLoader> preTemplateLoaders;
private List postTemplateLoaders; private List<TemplateLoader> postTemplateLoaders;
private String[] templateLoaderPaths; private String[] templateLoaderPaths;
@ -121,7 +121,7 @@ public class FreeMarkerConfigurationFactory {
* to FreeMarker's <code>Configuration.setAllSharedVariables()</code> method. * to FreeMarker's <code>Configuration.setAllSharedVariables()</code> method.
* @see freemarker.template.Configuration#setAllSharedVariables * @see freemarker.template.Configuration#setAllSharedVariables
*/ */
public void setFreemarkerVariables(Map variables) { public void setFreemarkerVariables(Map<String, Object> variables) {
this.freemarkerVariables = variables; this.freemarkerVariables = variables;
} }
@ -300,8 +300,8 @@ public class FreeMarkerConfigurationFactory {
// Register default template loaders. // Register default template loaders.
if (this.templateLoaderPaths != null) { if (this.templateLoaderPaths != null) {
for (int i = 0; i < this.templateLoaderPaths.length; i++) { for (String path : this.templateLoaderPaths) {
this.templateLoaders.add(getTemplateLoaderForPath(this.templateLoaderPaths[i])); this.templateLoaders.add(getTemplateLoaderForPath(path));
} }
} }
postProcessTemplateLoaders(this.templateLoaders); postProcessTemplateLoaders(this.templateLoaders);
@ -393,16 +393,16 @@ public class FreeMarkerConfigurationFactory {
* @param templateLoaders the final List of TemplateLoader instances * @param templateLoaders the final List of TemplateLoader instances
* @return the aggregate TemplateLoader * @return the aggregate TemplateLoader
*/ */
protected TemplateLoader getAggregateTemplateLoader(List templateLoaders) { protected TemplateLoader getAggregateTemplateLoader(List<TemplateLoader> templateLoaders) {
int loaderCount = templateLoaders.size(); int loaderCount = templateLoaders.size();
switch (loaderCount) { switch (loaderCount) {
case 0: case 0:
logger.info("No FreeMarker TemplateLoaders specified"); logger.info("No FreeMarker TemplateLoaders specified");
return null; return null;
case 1: case 1:
return (TemplateLoader) templateLoaders.get(0); return templateLoaders.get(0);
default: default:
TemplateLoader[] loaders = (TemplateLoader[]) templateLoaders.toArray(new TemplateLoader[loaderCount]); TemplateLoader[] loaders = templateLoaders.toArray(new TemplateLoader[loaderCount]);
return new MultiTemplateLoader(loaders); return new MultiTemplateLoader(loaders);
} }
} }

View File

@ -143,8 +143,8 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
if (codes == null) { if (codes == null) {
codes = new String[0]; codes = new String[0];
} }
for (int i = 0; i < codes.length; i++) { for (String code : codes) {
String msg = getMessageInternal(codes[i], resolvable.getArguments(), locale); String msg = getMessageInternal(code, resolvable.getArguments(), locale);
if (msg != null) { if (msg != null) {
return msg; return msg;
} }
@ -291,13 +291,13 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
if (args == null) { if (args == null) {
return new Object[0]; return new Object[0];
} }
List resolvedArgs = new ArrayList(args.length); List<Object> resolvedArgs = new ArrayList<Object>(args.length);
for (int i = 0; i < args.length; i++) { for (Object arg : args) {
if (args[i] instanceof MessageSourceResolvable) { if (arg instanceof MessageSourceResolvable) {
resolvedArgs.add(getMessage((MessageSourceResolvable) args[i], locale)); resolvedArgs.add(getMessage((MessageSourceResolvable) arg, locale));
} }
else { else {
resolvedArgs.add(args[i]); resolvedArgs.add(arg);
} }
} }
return resolvedArgs.toArray(new Object[resolvedArgs.size()]); return resolvedArgs.toArray(new Object[resolvedArgs.size()]);

View File

@ -16,10 +16,9 @@
package org.springframework.jmx.support; package org.springframework.jmx.support;
import java.util.Iterator; import java.util.Arrays;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import javax.management.MalformedObjectNameException; import javax.management.MalformedObjectNameException;
import javax.management.NotificationFilter; import javax.management.NotificationFilter;
import javax.management.NotificationListener; import javax.management.NotificationListener;
@ -46,7 +45,7 @@ public class NotificationListenerHolder {
private Object handback; private Object handback;
protected Set mappedObjectNames; protected Set<Object> mappedObjectNames;
/** /**
@ -122,15 +121,8 @@ public class NotificationListenerHolder {
* @see #setMappedObjectName * @see #setMappedObjectName
*/ */
public void setMappedObjectNames(Object[] mappedObjectNames) { public void setMappedObjectNames(Object[] mappedObjectNames) {
if (mappedObjectNames != null) { this.mappedObjectNames = (mappedObjectNames != null ?
this.mappedObjectNames = new LinkedHashSet(mappedObjectNames.length); new LinkedHashSet<Object>(Arrays.asList(mappedObjectNames)) : null);
for (int i = 0; i < mappedObjectNames.length; i++) {
this.mappedObjectNames.add(mappedObjectNames[i]);
}
}
else {
this.mappedObjectNames = null;
}
} }
/** /**
@ -145,8 +137,8 @@ public class NotificationListenerHolder {
} }
ObjectName[] resolved = new ObjectName[this.mappedObjectNames.size()]; ObjectName[] resolved = new ObjectName[this.mappedObjectNames.size()];
int i = 0; int i = 0;
for (Iterator it = this.mappedObjectNames.iterator(); it.hasNext();) { for (Object objectName : this.mappedObjectNames) {
resolved[i] = ObjectNameManager.getInstance(it.next()); resolved[i] = ObjectNameManager.getInstance(objectName);
i++; i++;
} }
return resolved; return resolved;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -45,7 +45,7 @@ public abstract class RemoteInvocationUtils {
public static void fillInClientStackTraceIfPossible(Throwable ex) { public static void fillInClientStackTraceIfPossible(Throwable ex) {
if (ex != null) { if (ex != null) {
StackTraceElement[] clientStack = new Throwable().getStackTrace(); StackTraceElement[] clientStack = new Throwable().getStackTrace();
Set visitedExceptions = new HashSet(); Set<Throwable> visitedExceptions = new HashSet<Throwable>();
Throwable exToUpdate = ex; Throwable exToUpdate = ex;
while (exToUpdate != null && !visitedExceptions.contains(exToUpdate)) { while (exToUpdate != null && !visitedExceptions.contains(exToUpdate)) {
StackTraceElement[] serverStack = exToUpdate.getStackTrace(); StackTraceElement[] serverStack = exToUpdate.getStackTrace();

View File

@ -19,7 +19,6 @@ package org.springframework.validation;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.EmptyStackException; import java.util.EmptyStackException;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
@ -38,7 +37,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
private String nestedPath = ""; private String nestedPath = "";
private final Stack nestedPathStack = new Stack(); private final Stack<String> nestedPathStack = new Stack<String>();
public void setNestedPath(String nestedPath) { public void setNestedPath(String nestedPath) {
@ -57,7 +56,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
public void popNestedPath() throws IllegalArgumentException { public void popNestedPath() throws IllegalArgumentException {
try { try {
String formerNestedPath = (String) this.nestedPathStack.pop(); String formerNestedPath = this.nestedPathStack.pop();
doSetNestedPath(formerNestedPath); doSetNestedPath(formerNestedPath);
} }
catch (EmptyStackException ex) { catch (EmptyStackException ex) {
@ -131,8 +130,8 @@ public abstract class AbstractErrors implements Errors, Serializable {
return getAllErrors().size(); return getAllErrors().size();
} }
public List getAllErrors() { public List<ObjectError> getAllErrors() {
List result = new LinkedList(); List<ObjectError> result = new LinkedList<ObjectError>();
result.addAll(getGlobalErrors()); result.addAll(getGlobalErrors());
result.addAll(getFieldErrors()); result.addAll(getFieldErrors());
return Collections.unmodifiableList(result); return Collections.unmodifiableList(result);
@ -172,13 +171,12 @@ public abstract class AbstractErrors implements Errors, Serializable {
return getFieldErrors(field).size(); return getFieldErrors(field).size();
} }
public List getFieldErrors(String field) { public List<FieldError> getFieldErrors(String field) {
List fieldErrors = getFieldErrors(); List<FieldError> fieldErrors = getFieldErrors();
List result = new LinkedList(); List<FieldError> result = new LinkedList<FieldError>();
String fixedField = fixedField(field); String fixedField = fixedField(field);
for (Iterator it = fieldErrors.iterator(); it.hasNext();) { for (FieldError error : fieldErrors) {
Object error = it.next(); if (isMatchingFieldError(fixedField, error)) {
if (isMatchingFieldError(fixedField, (FieldError) error)) {
result.add(error); result.add(error);
} }
} }
@ -198,6 +196,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
} }
return null; return null;
} }
/** /**
* Check whether the given FieldError matches the given field. * Check whether the given FieldError matches the given field.
* @param field the field that we are looking up FieldErrors for * @param field the field that we are looking up FieldErrors for
@ -214,9 +213,8 @@ public abstract class AbstractErrors implements Errors, Serializable {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(getClass().getName()); StringBuilder sb = new StringBuilder(getClass().getName());
sb.append(": ").append(getErrorCount()).append(" errors"); sb.append(": ").append(getErrorCount()).append(" errors");
Iterator it = getAllErrors().iterator(); for (ObjectError error : getAllErrors()) {
while (it.hasNext()) { sb.append('\n').append(error);
sb.append('\n').append(it.next());
} }
return sb.toString(); return sb.toString();
} }

View File

@ -48,7 +48,7 @@ public abstract class Conventions {
* Set of interfaces that are supposed to be ignored * Set of interfaces that are supposed to be ignored
* when searching for the 'primary' interface of a proxy. * when searching for the 'primary' interface of a proxy.
*/ */
private static final Set ignoredInterfaces = new HashSet(); private static final Set<Class> ignoredInterfaces = new HashSet<Class>();
static { static {
ignoredInterfaces.add(Serializable.class); ignoredInterfaces.add(Serializable.class);
@ -212,15 +212,14 @@ public abstract class Conventions {
*/ */
public static String attributeNameToPropertyName(String attributeName) { public static String attributeNameToPropertyName(String attributeName) {
Assert.notNull(attributeName, "'attributeName' must not be null"); Assert.notNull(attributeName, "'attributeName' must not be null");
if (attributeName.indexOf("-") == -1) { if (!attributeName.contains("-")) {
return attributeName; return attributeName;
} }
char[] chars = attributeName.toCharArray(); char[] chars = attributeName.toCharArray();
char[] result = new char[chars.length -1]; // not completely accurate but good guess char[] result = new char[chars.length -1]; // not completely accurate but good guess
int currPos = 0; int currPos = 0;
boolean upperCaseNext = false; boolean upperCaseNext = false;
for (int i = 0; i < chars.length; i++) { for (char c : chars) {
char c = chars[i];
if (c == '-') { if (c == '-') {
upperCaseNext = true; upperCaseNext = true;
} }
@ -260,8 +259,7 @@ public abstract class Conventions {
Class valueClass = value.getClass(); Class valueClass = value.getClass();
if (Proxy.isProxyClass(valueClass)) { if (Proxy.isProxyClass(valueClass)) {
Class[] ifcs = valueClass.getInterfaces(); Class[] ifcs = valueClass.getInterfaces();
for (int i = 0; i < ifcs.length; i++) { for (Class ifc : ifcs) {
Class ifc = ifcs[i];
if (!ignoredInterfaces.contains(ifc)) { if (!ignoredInterfaces.contains(ifc)) {
return ifc; return ifc;
} }

View File

@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
@ -94,17 +93,15 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
public void setValue(Object value) throws IllegalArgumentException { public void setValue(Object value) throws IllegalArgumentException {
if (value instanceof Collection || (value instanceof Object[] && !(value instanceof Resource[]))) { if (value instanceof Collection || (value instanceof Object[] && !(value instanceof Resource[]))) {
Collection input = (value instanceof Collection ? (Collection) value : Arrays.asList((Object[]) value)); Collection input = (value instanceof Collection ? (Collection) value : Arrays.asList((Object[]) value));
List merged = new ArrayList(); List<Resource> merged = new ArrayList<Resource>();
for (Iterator it = input.iterator(); it.hasNext();) { for (Object element : input) {
Object element = it.next();
if (element instanceof String) { if (element instanceof String) {
// A location pattern: resolve it into a Resource array. // A location pattern: resolve it into a Resource array.
// Might point to a single resource or to multiple resources. // Might point to a single resource or to multiple resources.
String pattern = resolvePath((String) element).trim(); String pattern = resolvePath((String) element).trim();
try { try {
Resource[] resources = this.resourcePatternResolver.getResources(pattern); Resource[] resources = this.resourcePatternResolver.getResources(pattern);
for (int i = 0; i < resources.length; i++) { for (Resource resource : resources) {
Resource resource = resources[i];
if (!merged.contains(resource)) { if (!merged.contains(resource)) {
merged.add(resource); merged.add(resource);
} }
@ -117,8 +114,9 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
} }
else if (element instanceof Resource) { else if (element instanceof Resource) {
// A Resource object: add it to the result. // A Resource object: add it to the result.
if (!merged.contains(element)) { Resource resource = (Resource) element;
merged.add(element); if (!merged.contains(resource)) {
merged.add(resource);
} }
} }
else { else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,18 +39,18 @@ import java.util.ListIterator;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.0 * @since 2.0
*/ */
public class AutoPopulatingList implements List, Serializable { public class AutoPopulatingList<E> implements List<E>, Serializable {
/** /**
* The {@link List} that all operations are eventually delegated to. * The {@link List} that all operations are eventually delegated to.
*/ */
private final List backingList; private final List<E> backingList;
/** /**
* The {@link ElementFactory} to use to create new {@link List} elements * The {@link ElementFactory} to use to create new {@link List} elements
* on demand. * on demand.
*/ */
private final ElementFactory elementFactory; private final ElementFactory<E> elementFactory;
/** /**
@ -58,8 +58,8 @@ public class AutoPopulatingList implements List, Serializable {
* {@link ArrayList} and adds new instances of the supplied {@link Class element Class} * {@link ArrayList} and adds new instances of the supplied {@link Class element Class}
* to the backing {@link List} on demand. * to the backing {@link List} on demand.
*/ */
public AutoPopulatingList(Class elementClass) { public AutoPopulatingList(Class<? extends E> elementClass) {
this(new ArrayList(), elementClass); this(new ArrayList<E>(), elementClass);
} }
/** /**
@ -67,23 +67,23 @@ public class AutoPopulatingList implements List, Serializable {
* and adds new instances of the supplied {@link Class element Class} to the backing * and adds new instances of the supplied {@link Class element Class} to the backing
* {@link List} on demand. * {@link List} on demand.
*/ */
public AutoPopulatingList(List backingList, Class elementClass) { public AutoPopulatingList(List<E> backingList, Class<? extends E> elementClass) {
this(backingList, new ReflectiveElementFactory(elementClass)); this(backingList, new ReflectiveElementFactory<E>(elementClass));
} }
/** /**
* Creates a new <code>AutoPopulatingList</code> that is backed by a standard * Creates a new <code>AutoPopulatingList</code> that is backed by a standard
* {@link ArrayList} and creates new elements on demand using the supplied {@link ElementFactory}. * {@link ArrayList} and creates new elements on demand using the supplied {@link ElementFactory}.
*/ */
public AutoPopulatingList(ElementFactory elementFactory) { public AutoPopulatingList(ElementFactory<E> elementFactory) {
this(new ArrayList(), elementFactory); this(new ArrayList<E>(), elementFactory);
} }
/** /**
* Creates a new <code>AutoPopulatingList</code> that is backed by the supplied {@link List} * Creates a new <code>AutoPopulatingList</code> that is backed by the supplied {@link List}
* and creates new elements on demand using the supplied {@link ElementFactory}. * and creates new elements on demand using the supplied {@link ElementFactory}.
*/ */
public AutoPopulatingList(List backingList, ElementFactory elementFactory) { public AutoPopulatingList(List<E> backingList, ElementFactory<E> elementFactory) {
Assert.notNull(backingList, "Backing List must not be null"); Assert.notNull(backingList, "Backing List must not be null");
Assert.notNull(elementFactory, "Element factory must not be null"); Assert.notNull(elementFactory, "Element factory must not be null");
this.backingList = backingList; this.backingList = backingList;
@ -91,19 +91,19 @@ public class AutoPopulatingList implements List, Serializable {
} }
public void add(int index, Object element) { public void add(int index, E element) {
this.backingList.add(index, element); this.backingList.add(index, element);
} }
public boolean add(Object o) { public boolean add(E o) {
return this.backingList.add(o); return this.backingList.add(o);
} }
public boolean addAll(Collection c) { public boolean addAll(Collection<? extends E> c) {
return this.backingList.addAll(c); return this.backingList.addAll(c);
} }
public boolean addAll(int index, Collection c) { public boolean addAll(int index, Collection<? extends E> c) {
return this.backingList.addAll(index, c); return this.backingList.addAll(index, c);
} }
@ -119,19 +119,13 @@ public class AutoPopulatingList implements List, Serializable {
return this.backingList.containsAll(c); return this.backingList.containsAll(c);
} }
@Override
public boolean equals(Object o) {
return this.backingList.equals(o);
}
/** /**
* Get the element at the supplied index, creating it if there is * Get the element at the supplied index, creating it if there is
* no element at that index. * no element at that index.
*/ */
public Object get(int index) { public E get(int index) {
int backingListSize = this.backingList.size(); int backingListSize = this.backingList.size();
E element = null;
Object element = null;
if (index < backingListSize) { if (index < backingListSize) {
element = this.backingList.get(index); element = this.backingList.get(index);
if (element == null) { if (element == null) {
@ -149,11 +143,6 @@ public class AutoPopulatingList implements List, Serializable {
return element; return element;
} }
@Override
public int hashCode() {
return this.backingList.hashCode();
}
public int indexOf(Object o) { public int indexOf(Object o) {
return this.backingList.indexOf(o); return this.backingList.indexOf(o);
} }
@ -162,7 +151,7 @@ public class AutoPopulatingList implements List, Serializable {
return this.backingList.isEmpty(); return this.backingList.isEmpty();
} }
public Iterator iterator() { public Iterator<E> iterator() {
return this.backingList.iterator(); return this.backingList.iterator();
} }
@ -170,15 +159,15 @@ public class AutoPopulatingList implements List, Serializable {
return this.backingList.lastIndexOf(o); return this.backingList.lastIndexOf(o);
} }
public ListIterator listIterator() { public ListIterator<E> listIterator() {
return this.backingList.listIterator(); return this.backingList.listIterator();
} }
public ListIterator listIterator(int index) { public ListIterator<E> listIterator(int index) {
return this.backingList.listIterator(index); return this.backingList.listIterator(index);
} }
public Object remove(int index) { public E remove(int index) {
return this.backingList.remove(index); return this.backingList.remove(index);
} }
@ -186,15 +175,15 @@ public class AutoPopulatingList implements List, Serializable {
return this.backingList.remove(o); return this.backingList.remove(o);
} }
public boolean removeAll(Collection c) { public boolean removeAll(Collection<?> c) {
return this.backingList.removeAll(c); return this.backingList.removeAll(c);
} }
public boolean retainAll(Collection c) { public boolean retainAll(Collection<?> c) {
return this.backingList.retainAll(c); return this.backingList.retainAll(c);
} }
public Object set(int index, Object element) { public E set(int index, E element) {
return this.backingList.set(index, element); return this.backingList.set(index, element);
} }
@ -202,7 +191,7 @@ public class AutoPopulatingList implements List, Serializable {
return this.backingList.size(); return this.backingList.size();
} }
public List subList(int fromIndex, int toIndex) { public List<E> subList(int fromIndex, int toIndex) {
return this.backingList.subList(fromIndex, toIndex); return this.backingList.subList(fromIndex, toIndex);
} }
@ -210,16 +199,27 @@ public class AutoPopulatingList implements List, Serializable {
return this.backingList.toArray(); return this.backingList.toArray();
} }
public Object[] toArray(Object[] a) { public <T> T[] toArray(T[] a) {
return this.backingList.toArray(a); return this.backingList.toArray(a);
} }
@Override
public boolean equals(Object other) {
return this.backingList.equals(other);
}
@Override
public int hashCode() {
return this.backingList.hashCode();
}
/** /**
* Factory interface for creating elements for an index-based access * Factory interface for creating elements for an index-based access
* data structure such as a {@link java.util.List}. * data structure such as a {@link java.util.List}.
*/ */
public interface ElementFactory { public interface ElementFactory<E> {
/** /**
* Create the element for the supplied index. * Create the element for the supplied index.
@ -227,7 +227,7 @@ public class AutoPopulatingList implements List, Serializable {
* @throws ElementInstantiationException if the instantiation process failed * @throws ElementInstantiationException if the instantiation process failed
* (any exception thrown by a target constructor should be propagated as-is) * (any exception thrown by a target constructor should be propagated as-is)
*/ */
Object createElement(int index) throws ElementInstantiationException; E createElement(int index) throws ElementInstantiationException;
} }
@ -247,18 +247,18 @@ public class AutoPopulatingList implements List, Serializable {
* using <code>Class.newInstance()</code> on a given element class. * using <code>Class.newInstance()</code> on a given element class.
* @see java.lang.Class#newInstance() * @see java.lang.Class#newInstance()
*/ */
private static class ReflectiveElementFactory implements ElementFactory, Serializable { private static class ReflectiveElementFactory<E> implements ElementFactory<E>, Serializable {
private final Class elementClass; private final Class<? extends E> elementClass;
public ReflectiveElementFactory(Class elementClass) { public ReflectiveElementFactory(Class<? extends E> elementClass) {
Assert.notNull(elementClass, "Element clas must not be null"); Assert.notNull(elementClass, "Element clas must not be null");
Assert.isTrue(!elementClass.isInterface(), "Element class must not be an interface type"); Assert.isTrue(!elementClass.isInterface(), "Element class must not be an interface type");
Assert.isTrue(!Modifier.isAbstract(elementClass.getModifiers()), "Element class cannot be an abstract class"); Assert.isTrue(!Modifier.isAbstract(elementClass.getModifiers()), "Element class cannot be an abstract class");
this.elementClass = elementClass; this.elementClass = elementClass;
} }
public Object createElement(int index) { public E createElement(int index) {
try { try {
return this.elementClass.newInstance(); return this.elementClass.newInstance();
} }

View File

@ -67,10 +67,9 @@ public abstract class ReflectionUtils {
Class searchType = clazz; Class searchType = clazz;
while (!Object.class.equals(searchType) && searchType != null) { while (!Object.class.equals(searchType) && searchType != null) {
Field[] fields = searchType.getDeclaredFields(); Field[] fields = searchType.getDeclaredFields();
for (int i = 0; i < fields.length; i++) { for (Field field : fields) {
Field field = fields[i]; if ((name == null || name.equals(field.getName())) &&
if ((name == null || name.equals(field.getName())) (type == null || type.equals(field.getType()))) {
&& (type == null || type.equals(field.getType()))) {
return field; return field;
} }
} }
@ -152,8 +151,7 @@ public abstract class ReflectionUtils {
Class searchType = clazz; Class searchType = clazz;
while (!Object.class.equals(searchType) && searchType != null) { while (!Object.class.equals(searchType) && searchType != null) {
Method[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType.getDeclaredMethods()); Method[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType.getDeclaredMethods());
for (int i = 0; i < methods.length; i++) { for (Method method : methods) {
Method method = methods[i];
if (name.equals(method.getName()) && if (name.equals(method.getName()) &&
(paramTypes == null || Arrays.equals(paramTypes, method.getParameterTypes()))) { (paramTypes == null || Arrays.equals(paramTypes, method.getParameterTypes()))) {
return method; return method;
@ -454,16 +452,16 @@ public abstract class ReflectionUtils {
// Keep backing up the inheritance hierarchy. // Keep backing up the inheritance hierarchy.
do { do {
Method[] methods = targetClass.getDeclaredMethods(); Method[] methods = targetClass.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) { for (Method method : methods) {
if (mf != null && !mf.matches(methods[i])) { if (mf != null && !mf.matches(method)) {
continue; continue;
} }
try { try {
mc.doWith(methods[i]); mc.doWith(method);
} }
catch (IllegalAccessException ex) { catch (IllegalAccessException ex) {
throw new IllegalStateException( throw new IllegalStateException(
"Shouldn't be illegal to access method '" + methods[i].getName() + "': " + ex); "Shouldn't be illegal to access method '" + method.getName() + "': " + ex);
} }
} }
targetClass = targetClass.getSuperclass(); targetClass = targetClass.getSuperclass();
@ -476,13 +474,13 @@ public abstract class ReflectionUtils {
* Leaf class methods are included first. * Leaf class methods are included first.
*/ */
public static Method[] getAllDeclaredMethods(Class leafClass) throws IllegalArgumentException { public static Method[] getAllDeclaredMethods(Class leafClass) throws IllegalArgumentException {
final List list = new ArrayList(32); final List<Method> methods = new ArrayList<Method>(32);
doWithMethods(leafClass, new MethodCallback() { doWithMethods(leafClass, new MethodCallback() {
public void doWith(Method method) { public void doWith(Method method) {
list.add(method); methods.add(method);
} }
}); });
return (Method[]) list.toArray(new Method[list.size()]); return methods.toArray(new Method[methods.size()]);
} }
@ -510,17 +508,17 @@ public abstract class ReflectionUtils {
do { do {
// Copy each field declared on this class unless it's static or file. // Copy each field declared on this class unless it's static or file.
Field[] fields = targetClass.getDeclaredFields(); Field[] fields = targetClass.getDeclaredFields();
for (int i = 0; i < fields.length; i++) { for (Field field : fields) {
// Skip static and final fields. // Skip static and final fields.
if (ff != null && !ff.matches(fields[i])) { if (ff != null && !ff.matches(field)) {
continue; continue;
} }
try { try {
fc.doWith(fields[i]); fc.doWith(field);
} }
catch (IllegalAccessException ex) { catch (IllegalAccessException ex) {
throw new IllegalStateException( throw new IllegalStateException(
"Shouldn't be illegal to access field '" + fields[i].getName() + "': " + ex); "Shouldn't be illegal to access field '" + field.getName() + "': " + ex);
} }
} }
targetClass = targetClass.getSuperclass(); targetClass = targetClass.getSuperclass();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-20078the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -48,8 +48,7 @@ public class StopWatch {
private boolean keepTaskList = true; private boolean keepTaskList = true;
/** List of TaskInfo objects */ private final List<TaskInfo> taskList = new LinkedList<TaskInfo>();
private final List taskList = new LinkedList();
/** Start time of the current task */ /** Start time of the current task */
private long startTimeMillis; private long startTimeMillis;
@ -187,7 +186,7 @@ public class StopWatch {
if (!this.keepTaskList) { if (!this.keepTaskList) {
throw new UnsupportedOperationException("Task info is not being kept!"); throw new UnsupportedOperationException("Task info is not being kept!");
} }
return (TaskInfo[]) this.taskList.toArray(new TaskInfo[this.taskList.size()]); return this.taskList.toArray(new TaskInfo[this.taskList.size()]);
} }
@ -209,7 +208,6 @@ public class StopWatch {
sb.append("No task info kept"); sb.append("No task info kept");
} }
else { else {
TaskInfo[] tasks = getTaskInfo();
sb.append("-----------------------------------------\n"); sb.append("-----------------------------------------\n");
sb.append("ms % Task name\n"); sb.append("ms % Task name\n");
sb.append("-----------------------------------------\n"); sb.append("-----------------------------------------\n");
@ -219,10 +217,10 @@ public class StopWatch {
NumberFormat pf = NumberFormat.getPercentInstance(); NumberFormat pf = NumberFormat.getPercentInstance();
pf.setMinimumIntegerDigits(3); pf.setMinimumIntegerDigits(3);
pf.setGroupingUsed(false); pf.setGroupingUsed(false);
for (int i = 0; i < tasks.length; i++) { for (TaskInfo task : getTaskInfo()) {
sb.append(nf.format(tasks[i].getTimeMillis()) + " "); sb.append(nf.format(task.getTimeMillis())).append(" ");
sb.append(pf.format(tasks[i].getTimeSeconds() / getTotalTimeSeconds()) + " "); sb.append(pf.format(task.getTimeSeconds() / getTotalTimeSeconds())).append(" ");
sb.append(tasks[i].getTaskName() + "\n"); sb.append(task.getTaskName()).append("\n");
} }
} }
return sb.toString(); return sb.toString();
@ -236,11 +234,10 @@ public class StopWatch {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(shortSummary()); StringBuilder sb = new StringBuilder(shortSummary());
if (this.keepTaskList) { if (this.keepTaskList) {
TaskInfo[] tasks = getTaskInfo(); for (TaskInfo task : getTaskInfo()) {
for (int i = 0; i < tasks.length; i++) { sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeMillis());
sb.append("; [" + tasks[i].getTaskName() + "] took " + tasks[i].getTimeMillis()); long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
long percent = Math.round((100.0 * tasks[i].getTimeSeconds()) / getTotalTimeSeconds()); sb.append(" = ").append(percent).append("%");
sb.append(" = " + percent + "%");
} }
} }
else { else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,10 +26,10 @@ import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.jdbc.core.SqlInOutParameter;
import org.springframework.jdbc.core.SqlOutParameter; import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter; import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.SqlInOutParameter;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -279,14 +279,10 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
metaDataSchemaName + "/" + metaDataProcedureName); metaDataSchemaName + "/" + metaDataProcedureName);
} }
try { try {
procs = databaseMetaData.getProcedures( procs = databaseMetaData.getProcedures(metaDataCatalogName, metaDataSchemaName, metaDataProcedureName);
metaDataCatalogName, List<String> found = new ArrayList<String>();
metaDataSchemaName,
metaDataProcedureName);
List found = new ArrayList();
while (procs.next()) { while (procs.next()) {
found.add(procs.getString("PROCEDURE_CAT") + found.add(procs.getString("PROCEDURE_CAT") + "." + procs.getString("PROCEDURE_SCHEM") +
"."+procs.getString("PROCEDURE_SCHEM") +
"." + procs.getString("PROCEDURE_NAME")); "." + procs.getString("PROCEDURE_NAME"));
} }
procs.close(); procs.close();
@ -304,10 +300,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
} }
procs = databaseMetaData.getProcedureColumns( procs = databaseMetaData.getProcedureColumns(
metaDataCatalogName, metaDataCatalogName, metaDataSchemaName, metaDataProcedureName, null);
metaDataSchemaName,
metaDataProcedureName,
null);
while (procs.next()) { while (procs.next()) {
String columnName = procs.getString("COLUMN_NAME"); String columnName = procs.getString("COLUMN_NAME");
int columnType = procs.getInt("COLUMN_TYPE"); int columnType = procs.getInt("COLUMN_TYPE");
@ -327,36 +320,30 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
} }
} }
else { else {
CallParameterMetaData meta = new CallParameterMetaData( CallParameterMetaData meta = new CallParameterMetaData(columnName, columnType,
columnName, procs.getInt("DATA_TYPE"), procs.getString("TYPE_NAME"), procs.getBoolean("NULLABLE")
columnType,
procs.getInt("DATA_TYPE"),
procs.getString("TYPE_NAME"),
procs.getBoolean("NULLABLE")
); );
callParameterMetaData.add(meta); callParameterMetaData.add(meta);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Retrieved metadata: " logger.debug("Retrieved metadata: " + meta.getParameterName() + " " +
+ meta.getParameterName() + meta.getParameterType() + " " + meta.getSqlType() +
" " + meta.getParameterType() + " " + meta.getTypeName() + " " + meta.isNullable()
" " + meta.getSqlType() +
" " + meta.getTypeName() +
" " + meta.isNullable()
); );
} }
} }
} }
} }
catch (SQLException se) { catch (SQLException ex) {
logger.warn("Error while retreiving metadata for procedure columns: " + se.getMessage()); logger.warn("Error while retrieving metadata for procedure columns: " + ex);
} }
finally { finally {
try { try {
if (procs != null) if (procs != null) {
procs.close(); procs.close();
} }
catch (SQLException se) { }
logger.warn("Problem closing resultset for procedure column metadata " + se.getMessage()); catch (SQLException ex) {
logger.warn("Problem closing ResultSet for procedure column metadata: " + ex);
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -192,7 +192,7 @@ public class TableMetaDataContext {
if (declaredColumns.size() > 0) { if (declaredColumns.size() > 0) {
return new ArrayList<String>(declaredColumns); return new ArrayList<String>(declaredColumns);
} }
Set keys = new HashSet(generatedKeyNames.length); Set<String> keys = new HashSet<String>(generatedKeyNames.length);
for (String key : generatedKeyNames) { for (String key : generatedKeyNames) {
keys.add(key.toUpperCase()); keys.add(key.toUpperCase());
} }

View File

@ -75,14 +75,14 @@ public class BeanPropertySqlParameterSource extends AbstractSqlParameterSource {
*/ */
public String[] getReadablePropertyNames() { public String[] getReadablePropertyNames() {
if (this.propertyNames == null) { if (this.propertyNames == null) {
List names = new ArrayList(); List<String> names = new ArrayList<String>();
PropertyDescriptor[] props = this.beanWrapper.getPropertyDescriptors(); PropertyDescriptor[] props = this.beanWrapper.getPropertyDescriptors();
for (int i = 0; i < props.length; i++) { for (PropertyDescriptor pd : props) {
if (this.beanWrapper.isReadableProperty(props[i].getName())) { if (this.beanWrapper.isReadableProperty(pd.getName())) {
names.add(props[i].getName()); names.add(pd.getName());
} }
} }
this.propertyNames = (String[]) names.toArray(new String[names.size()]); this.propertyNames = names.toArray(new String[names.size()]);
} }
return this.propertyNames; return this.propertyNames;
} }

View File

@ -44,15 +44,15 @@ import org.springframework.jdbc.BadSqlGrammarException;
*/ */
public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator { public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator {
private static final Set BAD_SQL_GRAMMAR_CODES = new HashSet(8); private static final Set<String> BAD_SQL_GRAMMAR_CODES = new HashSet<String>(8);
private static final Set DATA_INTEGRITY_VIOLATION_CODES = new HashSet(8); private static final Set<String> DATA_INTEGRITY_VIOLATION_CODES = new HashSet<String>(8);
private static final Set DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet(8); private static final Set<String> DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet<String>(8);
private static final Set TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet(8); private static final Set<String> TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet<String>(8);
private static final Set CONCURRENCY_FAILURE_CODES = new HashSet(4); private static final Set<String> CONCURRENCY_FAILURE_CODES = new HashSet<String>(4);
static { static {

View File

@ -394,8 +394,8 @@ public class SingleConnectionFactory
*/ */
protected Session createSession(Connection con, Integer mode) throws JMSException { protected Session createSession(Connection con, Integer mode) throws JMSException {
// Determine JMS API arguments... // Determine JMS API arguments...
boolean transacted = (mode.intValue() == Session.SESSION_TRANSACTED); boolean transacted = (mode == Session.SESSION_TRANSACTED);
int ackMode = (transacted ? Session.AUTO_ACKNOWLEDGE : mode.intValue()); int ackMode = (transacted ? Session.AUTO_ACKNOWLEDGE : mode);
// Now actually call the appropriate JMS factory method... // Now actually call the appropriate JMS factory method...
if (Boolean.FALSE.equals(this.pubSubMode) && con instanceof QueueConnection) { if (Boolean.FALSE.equals(this.pubSubMode) && con instanceof QueueConnection) {
return ((QueueConnection) con).createQueueSession(transacted, ackMode); return ((QueueConnection) con).createQueueSession(transacted, ackMode);
@ -444,7 +444,7 @@ public class SingleConnectionFactory
* @return the wrapped Connection * @return the wrapped Connection
*/ */
protected Connection getSharedConnectionProxy(Connection target) { protected Connection getSharedConnectionProxy(Connection target) {
List classes = new ArrayList(3); List<Class> classes = new ArrayList<Class>(3);
classes.add(Connection.class); classes.add(Connection.class);
if (target instanceof QueueConnection) { if (target instanceof QueueConnection) {
classes.add(QueueConnection.class); classes.add(QueueConnection.class);
@ -454,7 +454,7 @@ public class SingleConnectionFactory
} }
return (Connection) Proxy.newProxyInstance( return (Connection) Proxy.newProxyInstance(
Connection.class.getClassLoader(), Connection.class.getClassLoader(),
(Class[]) classes.toArray(new Class[classes.size()]), classes.toArray(new Class[classes.size()]),
new SharedConnectionInvocationHandler(target)); new SharedConnectionInvocationHandler(target));
} }
@ -477,7 +477,7 @@ public class SingleConnectionFactory
} }
else if (method.getName().equals("hashCode")) { else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy. // Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy)); return System.identityHashCode(proxy);
} }
else if (method.getName().equals("toString")) { else if (method.getName().equals("toString")) {
return "Shared JMS Connection: " + this.target; return "Shared JMS Connection: " + this.target;
@ -527,9 +527,9 @@ public class SingleConnectionFactory
} }
else if (method.getName().equals("createSession") || method.getName().equals("createQueueSession") || else if (method.getName().equals("createSession") || method.getName().equals("createQueueSession") ||
method.getName().equals("createTopicSession")) { method.getName().equals("createTopicSession")) {
boolean transacted = ((Boolean) args[0]).booleanValue(); boolean transacted = (Boolean) args[0];
Integer ackMode = (Integer) args[1]; Integer ackMode = (Integer) args[1];
Integer mode = (transacted ? new Integer(Session.SESSION_TRANSACTED) : ackMode); Integer mode = (transacted ? Session.SESSION_TRANSACTED : ackMode);
Session session = getSession(this.target, mode); Session session = getSession(this.target, mode);
if (session != null) { if (session != null) {
if (!method.getReturnType().isInstance(session)) { if (!method.getReturnType().isInstance(session)) {

View File

@ -192,7 +192,7 @@ public class TransactionAwareConnectionFactoryProxy
* @return the wrapped Connection * @return the wrapped Connection
*/ */
private Connection getTransactionAwareConnectionProxy(Connection target) { private Connection getTransactionAwareConnectionProxy(Connection target) {
List classes = new ArrayList(3); List<Class> classes = new ArrayList<Class>(3);
classes.add(Connection.class); classes.add(Connection.class);
if (target instanceof QueueConnection) { if (target instanceof QueueConnection) {
classes.add(QueueConnection.class); classes.add(QueueConnection.class);
@ -202,7 +202,7 @@ public class TransactionAwareConnectionFactoryProxy
} }
return (Connection) Proxy.newProxyInstance( return (Connection) Proxy.newProxyInstance(
Connection.class.getClassLoader(), Connection.class.getClassLoader(),
(Class[]) classes.toArray(new Class[classes.size()]), classes.toArray(new Class[classes.size()]),
new TransactionAwareConnectionInvocationHandler(target)); new TransactionAwareConnectionInvocationHandler(target));
} }
@ -263,7 +263,7 @@ public class TransactionAwareConnectionFactoryProxy
} }
private Session getCloseSuppressingSessionProxy(Session target) { private Session getCloseSuppressingSessionProxy(Session target) {
List classes = new ArrayList(3); List<Class> classes = new ArrayList<Class>(3);
classes.add(SessionProxy.class); classes.add(SessionProxy.class);
if (target instanceof QueueSession) { if (target instanceof QueueSession) {
classes.add(QueueSession.class); classes.add(QueueSession.class);
@ -273,7 +273,7 @@ public class TransactionAwareConnectionFactoryProxy
} }
return (Session) Proxy.newProxyInstance( return (Session) Proxy.newProxyInstance(
SessionProxy.class.getClassLoader(), SessionProxy.class.getClassLoader(),
(Class[]) classes.toArray(new Class[classes.size()]), classes.toArray(new Class[classes.size()]),
new CloseSuppressingSessionInvocationHandler(target)); new CloseSuppressingSessionInvocationHandler(target));
} }
} }

View File

@ -77,7 +77,7 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
private boolean running = false; private boolean running = false;
private final List pausedTasks = new LinkedList(); private final List<Object> pausedTasks = new LinkedList<Object>();
protected final Object lifecycleMonitor = new Object(); protected final Object lifecycleMonitor = new Object();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -94,13 +94,11 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
} }
private RootBeanDefinition parseAttributeSource(Element attrEle, ParserContext parserContext) { private RootBeanDefinition parseAttributeSource(Element attrEle, ParserContext parserContext) {
List methods = DomUtils.getChildElementsByTagName(attrEle, "method"); List<Element> methods = DomUtils.getChildElementsByTagName(attrEle, "method");
ManagedMap transactionAttributeMap = new ManagedMap(methods.size()); ManagedMap transactionAttributeMap = new ManagedMap(methods.size());
transactionAttributeMap.setSource(parserContext.extractSource(attrEle)); transactionAttributeMap.setSource(parserContext.extractSource(attrEle));
for (int i = 0; i < methods.size(); i++) { for (Element methodEle : methods) {
Element methodEle = (Element) methods.get(i);
String name = methodEle.getAttribute("name"); String name = methodEle.getAttribute("name");
TypedStringValue nameHolder = new TypedStringValue(name); TypedStringValue nameHolder = new TypedStringValue(name);
nameHolder.setSource(parserContext.extractSource(methodEle)); nameHolder.setSource(parserContext.extractSource(methodEle));
@ -125,10 +123,10 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
} }
} }
if (StringUtils.hasText(readOnly)) { if (StringUtils.hasText(readOnly)) {
attribute.setReadOnly(Boolean.valueOf(methodEle.getAttribute(READ_ONLY)).booleanValue()); attribute.setReadOnly(Boolean.valueOf(methodEle.getAttribute(READ_ONLY)));
} }
List rollbackRules = new LinkedList(); List<RollbackRuleAttribute> rollbackRules = new LinkedList<RollbackRuleAttribute>();
if (methodEle.hasAttribute(ROLLBACK_FOR)) { if (methodEle.hasAttribute(ROLLBACK_FOR)) {
String rollbackForValue = methodEle.getAttribute(ROLLBACK_FOR); String rollbackForValue = methodEle.getAttribute(ROLLBACK_FOR);
addRollbackRuleAttributesTo(rollbackRules,rollbackForValue); addRollbackRuleAttributesTo(rollbackRules,rollbackForValue);
@ -148,17 +146,17 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
return attributeSourceDefinition; return attributeSourceDefinition;
} }
private void addRollbackRuleAttributesTo(List rollbackRules, String rollbackForValue) { private void addRollbackRuleAttributesTo(List<RollbackRuleAttribute> rollbackRules, String rollbackForValue) {
String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(rollbackForValue); String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(rollbackForValue);
for (int i = 0; i < exceptionTypeNames.length; i++) { for (String typeName : exceptionTypeNames) {
rollbackRules.add(new RollbackRuleAttribute(StringUtils.trimWhitespace(exceptionTypeNames[i]))); rollbackRules.add(new RollbackRuleAttribute(StringUtils.trimWhitespace(typeName)));
} }
} }
private void addNoRollbackRuleAttributesTo(List rollbackRules, String noRollbackForValue) { private void addNoRollbackRuleAttributesTo(List<RollbackRuleAttribute> rollbackRules, String noRollbackForValue) {
String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(noRollbackForValue); String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(noRollbackForValue);
for (int i = 0; i < exceptionTypeNames.length; i++) { for (String typeName : exceptionTypeNames) {
rollbackRules.add(new NoRollbackRuleAttribute(StringUtils.trimWhitespace(exceptionTypeNames[i]))); rollbackRules.add(new NoRollbackRuleAttribute(StringUtils.trimWhitespace(typeName)));
} }
} }

View File

@ -72,7 +72,7 @@ public abstract class GenericPortletBean extends GenericPortlet {
* Set of required properties (Strings) that must be supplied as * Set of required properties (Strings) that must be supplied as
* config parameters to this portlet. * config parameters to this portlet.
*/ */
private final Set requiredProperties = new HashSet(); private final Set<String> requiredProperties = new HashSet<String>();
/** /**
@ -174,11 +174,11 @@ public abstract class GenericPortletBean extends GenericPortlet {
* we can't accept default values * we can't accept default values
* @throws PortletException if any required properties are missing * @throws PortletException if any required properties are missing
*/ */
private PortletConfigPropertyValues(PortletConfig config, Set requiredProperties) private PortletConfigPropertyValues(PortletConfig config, Set<String> requiredProperties)
throws PortletException { throws PortletException {
Set missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ? Set<String> missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ?
new HashSet(requiredProperties) : null; new HashSet<String>(requiredProperties) : null;
Enumeration en = config.getInitParameterNames(); Enumeration en = config.getInitParameterNames();
while (en.hasMoreElements()) { while (en.hasMoreElements()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.springframework.web.portlet; package org.springframework.web.portlet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -36,7 +37,7 @@ public class HandlerExecutionChain {
private HandlerInterceptor[] interceptors; private HandlerInterceptor[] interceptors;
private List interceptorList; private List<HandlerInterceptor> interceptorList;
/** /**
@ -57,7 +58,7 @@ public class HandlerExecutionChain {
if (handler instanceof HandlerExecutionChain) { if (handler instanceof HandlerExecutionChain) {
HandlerExecutionChain originalChain = (HandlerExecutionChain) handler; HandlerExecutionChain originalChain = (HandlerExecutionChain) handler;
this.handler = originalChain.getHandler(); this.handler = originalChain.getHandler();
this.interceptorList = new ArrayList(); this.interceptorList = new ArrayList<HandlerInterceptor>();
CollectionUtils.mergeArrayIntoCollection(originalChain.getInterceptors(), this.interceptorList); CollectionUtils.mergeArrayIntoCollection(originalChain.getInterceptors(), this.interceptorList);
CollectionUtils.mergeArrayIntoCollection(interceptors, this.interceptorList); CollectionUtils.mergeArrayIntoCollection(interceptors, this.interceptorList);
} }
@ -84,20 +85,16 @@ public class HandlerExecutionChain {
public void addInterceptors(HandlerInterceptor[] interceptors) { public void addInterceptors(HandlerInterceptor[] interceptors) {
if (interceptors != null) { if (interceptors != null) {
initInterceptorList(); initInterceptorList();
for (int i = 0; i < interceptors.length; i++) { this.interceptorList.addAll(Arrays.asList(interceptors));
this.interceptorList.add(interceptors[i]);
}
} }
} }
private void initInterceptorList() { private void initInterceptorList() {
if (this.interceptorList == null) { if (this.interceptorList == null) {
this.interceptorList = new ArrayList(); this.interceptorList = new ArrayList<HandlerInterceptor>();
} }
if (this.interceptors != null) { if (this.interceptors != null) {
for (int i = 0; i < this.interceptors.length; i++) { this.interceptorList.addAll(Arrays.asList(this.interceptors));
this.interceptorList.add(this.interceptors[i]);
}
this.interceptors = null; this.interceptors = null;
} }
} }
@ -108,10 +105,18 @@ public class HandlerExecutionChain {
*/ */
public HandlerInterceptor[] getInterceptors() { public HandlerInterceptor[] getInterceptors() {
if (this.interceptors == null && this.interceptorList != null) { if (this.interceptors == null && this.interceptorList != null) {
this.interceptors = (HandlerInterceptor[]) this.interceptors = this.interceptorList.toArray(new HandlerInterceptor[this.interceptorList.size()]);
this.interceptorList.toArray(new HandlerInterceptor[this.interceptorList.size()]);
} }
return this.interceptors; return this.interceptors;
} }
/**
* Delegates to the handler's <code>toString()</code>.
*/
@Override
public String toString() {
return String.valueOf(this.handler);
}
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ public abstract class AbstractHandlerMapping extends ApplicationObjectSupport
private Object defaultHandler; private Object defaultHandler;
private final List interceptors = new ArrayList(); private final List<Object> interceptors = new ArrayList<Object>();
private boolean applyWebRequestInterceptorsToRenderPhaseOnly = true; private boolean applyWebRequestInterceptorsToRenderPhaseOnly = true;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.web.bind; package org.springframework.web.bind;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
@ -117,7 +116,7 @@ public class EscapedErrors implements Errors {
return this.source.getErrorCount(); return this.source.getErrorCount();
} }
public List getAllErrors() { public List<ObjectError> getAllErrors() {
return escapeObjectErrors(this.source.getAllErrors()); return escapeObjectErrors(this.source.getAllErrors());
} }
@ -129,7 +128,7 @@ public class EscapedErrors implements Errors {
return this.source.getGlobalErrorCount(); return this.source.getGlobalErrorCount();
} }
public List getGlobalErrors() { public List<ObjectError> getGlobalErrors() {
return escapeObjectErrors(this.source.getGlobalErrors()); return escapeObjectErrors(this.source.getGlobalErrors());
} }
@ -145,7 +144,7 @@ public class EscapedErrors implements Errors {
return this.source.getFieldErrorCount(); return this.source.getFieldErrorCount();
} }
public List getFieldErrors() { public List<FieldError> getFieldErrors() {
return this.source.getFieldErrors(); return this.source.getFieldErrors();
} }
@ -161,12 +160,12 @@ public class EscapedErrors implements Errors {
return this.source.getFieldErrorCount(field); return this.source.getFieldErrorCount(field);
} }
public List getFieldErrors(String field) { public List<FieldError> getFieldErrors(String field) {
return escapeObjectErrors(this.source.getFieldErrors(field)); return escapeObjectErrors(this.source.getFieldErrors(field));
} }
public FieldError getFieldError(String field) { public FieldError getFieldError(String field) {
return (FieldError) escapeObjectError(this.source.getFieldError(field)); return escapeObjectError(this.source.getFieldError(field));
} }
public Object getFieldValue(String field) { public Object getFieldValue(String field) {
@ -178,7 +177,8 @@ public class EscapedErrors implements Errors {
return this.source.getFieldType(field); return this.source.getFieldType(field);
} }
private ObjectError escapeObjectError(ObjectError source) { @SuppressWarnings("unchecked")
private <T extends ObjectError> T escapeObjectError(T source) {
if (source == null) { if (source == null) {
return null; return null;
} }
@ -188,20 +188,21 @@ public class EscapedErrors implements Errors {
if (value instanceof String) { if (value instanceof String) {
value = HtmlUtils.htmlEscape((String) value); value = HtmlUtils.htmlEscape((String) value);
} }
return new FieldError( return (T) new FieldError(
fieldError.getObjectName(), fieldError.getField(), value, fieldError.getObjectName(), fieldError.getField(), value,
fieldError.isBindingFailure(), fieldError.getCodes(), fieldError.isBindingFailure(), fieldError.getCodes(),
fieldError.getArguments(), HtmlUtils.htmlEscape(fieldError.getDefaultMessage())); fieldError.getArguments(), HtmlUtils.htmlEscape(fieldError.getDefaultMessage()));
} }
return new ObjectError( else {
return (T) new ObjectError(
source.getObjectName(), source.getCodes(), source.getArguments(), source.getObjectName(), source.getCodes(), source.getArguments(),
HtmlUtils.htmlEscape(source.getDefaultMessage())); HtmlUtils.htmlEscape(source.getDefaultMessage()));
} }
}
private List escapeObjectErrors(List source) { private <T extends ObjectError> List<T> escapeObjectErrors(List<T> source) {
List escaped = new ArrayList(source.size()); List<T> escaped = new ArrayList<T>(source.size());
for (Iterator it = source.iterator(); it.hasNext();) { for (T objectError : source) {
ObjectError objectError = (ObjectError)it.next();
escaped.add(escapeObjectError(objectError)); escaped.add(escapeObjectError(objectError));
} }
return escaped; return escaped;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.springframework.web.servlet; package org.springframework.web.servlet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -35,7 +36,7 @@ public class HandlerExecutionChain {
private HandlerInterceptor[] interceptors; private HandlerInterceptor[] interceptors;
private List interceptorList; private List<HandlerInterceptor> interceptorList;
/** /**
@ -56,7 +57,7 @@ public class HandlerExecutionChain {
if (handler instanceof HandlerExecutionChain) { if (handler instanceof HandlerExecutionChain) {
HandlerExecutionChain originalChain = (HandlerExecutionChain) handler; HandlerExecutionChain originalChain = (HandlerExecutionChain) handler;
this.handler = originalChain.getHandler(); this.handler = originalChain.getHandler();
this.interceptorList = new ArrayList(); this.interceptorList = new ArrayList<HandlerInterceptor>();
CollectionUtils.mergeArrayIntoCollection(originalChain.getInterceptors(), this.interceptorList); CollectionUtils.mergeArrayIntoCollection(originalChain.getInterceptors(), this.interceptorList);
CollectionUtils.mergeArrayIntoCollection(interceptors, this.interceptorList); CollectionUtils.mergeArrayIntoCollection(interceptors, this.interceptorList);
} }
@ -83,20 +84,16 @@ public class HandlerExecutionChain {
public void addInterceptors(HandlerInterceptor[] interceptors) { public void addInterceptors(HandlerInterceptor[] interceptors) {
if (interceptors != null) { if (interceptors != null) {
initInterceptorList(); initInterceptorList();
for (int i = 0; i < interceptors.length; i++) { this.interceptorList.addAll(Arrays.asList(interceptors));
this.interceptorList.add(interceptors[i]);
}
} }
} }
private void initInterceptorList() { private void initInterceptorList() {
if (this.interceptorList == null) { if (this.interceptorList == null) {
this.interceptorList = new ArrayList(); this.interceptorList = new ArrayList<HandlerInterceptor>();
} }
if (this.interceptors != null) { if (this.interceptors != null) {
for (int i = 0; i < this.interceptors.length; i++) { this.interceptorList.addAll(Arrays.asList(this.interceptors));
this.interceptorList.add(this.interceptors[i]);
}
this.interceptors = null; this.interceptors = null;
} }
} }
@ -107,17 +104,18 @@ public class HandlerExecutionChain {
*/ */
public HandlerInterceptor[] getInterceptors() { public HandlerInterceptor[] getInterceptors() {
if (this.interceptors == null && this.interceptorList != null) { if (this.interceptors == null && this.interceptorList != null) {
this.interceptors = (HandlerInterceptor[]) this.interceptors = this.interceptorList.toArray(new HandlerInterceptor[this.interceptorList.size()]);
this.interceptorList.toArray(new HandlerInterceptor[this.interceptorList.size()]);
} }
return this.interceptors; return this.interceptors;
} }
/** /**
* Delegates to the handler's <code>toString()</code>. * Delegates to the handler's <code>toString()</code>.
*/ */
@Override @Override
public String toString() { public String toString() {
return String.valueOf(handler); return String.valueOf(this.handler);
} }
} }

View File

@ -81,7 +81,7 @@ public abstract class HttpServletBean extends HttpServlet {
* Set of required properties (Strings) that must be supplied as * Set of required properties (Strings) that must be supplied as
* config parameters to this servlet. * config parameters to this servlet.
*/ */
private final Set requiredProperties = new HashSet(); private final Set<String> requiredProperties = new HashSet<String>();
/** /**
@ -187,11 +187,11 @@ public abstract class HttpServletBean extends HttpServlet {
* we can't accept default values * we can't accept default values
* @throws ServletException if any required properties are missing * @throws ServletException if any required properties are missing
*/ */
public ServletConfigPropertyValues(ServletConfig config, Set requiredProperties) public ServletConfigPropertyValues(ServletConfig config, Set<String> requiredProperties)
throws ServletException { throws ServletException {
Set missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ? Set<String> missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ?
new HashSet(requiredProperties) : null; new HashSet<String>(requiredProperties) : null;
Enumeration en = config.getInitParameterNames(); Enumeration en = config.getInitParameterNames();
while (en.hasMoreElements()) { while (en.hasMoreElements()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2007 the original author or authors. * Copyright 2002-2008 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,7 +52,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
private Object defaultHandler; private Object defaultHandler;
private final List interceptors = new ArrayList(); private final List<Object> interceptors = new ArrayList<Object>();
private HandlerInterceptor[] adaptedInterceptors; private HandlerInterceptor[] adaptedInterceptors;

View File

@ -55,7 +55,7 @@ public class BeanNameUrlHandlerMapping extends AbstractDetectingUrlHandlerMappin
*/ */
@Override @Override
protected String[] determineUrlsForHandler(String beanName) { protected String[] determineUrlsForHandler(String beanName) {
List urls = new ArrayList(); List<String> urls = new ArrayList<String>();
if (beanName.startsWith("/")) { if (beanName.startsWith("/")) {
urls.add(beanName); urls.add(beanName);
} }

View File

@ -65,7 +65,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
/** Set of supported HTTP methods */ /** Set of supported HTTP methods */
private Set supportedMethods; private Set<String> supportedMethods;
private boolean requireSession = false; private boolean requireSession = false;
@ -97,7 +97,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
*/ */
public WebContentGenerator(boolean restrictDefaultSupportedMethods) { public WebContentGenerator(boolean restrictDefaultSupportedMethods) {
if (restrictDefaultSupportedMethods) { if (restrictDefaultSupportedMethods) {
this.supportedMethods = new HashSet(4); this.supportedMethods = new HashSet<String>(4);
this.supportedMethods.add(METHOD_GET); this.supportedMethods.add(METHOD_GET);
this.supportedMethods.add(METHOD_HEAD); this.supportedMethods.add(METHOD_HEAD);
this.supportedMethods.add(METHOD_POST); this.supportedMethods.add(METHOD_POST);
@ -111,7 +111,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport {
*/ */
public final void setSupportedMethods(String[] methods) { public final void setSupportedMethods(String[] methods) {
if (methods != null) { if (methods != null) {
this.supportedMethods = new HashSet(Arrays.asList(methods)); this.supportedMethods = new HashSet<String>(Arrays.asList(methods));
} }
else { else {
this.supportedMethods = null; this.supportedMethods = null;

View File

@ -19,7 +19,6 @@ package org.springframework.web.servlet.tags.form;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext; import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTag; import javax.servlet.jsp.tagext.BodyTag;
@ -169,7 +168,7 @@ public class ErrorsTag extends AbstractHtmlElementBodyTag implements BodyTag {
*/ */
@Override @Override
protected void exposeAttributes() throws JspException { protected void exposeAttributes() throws JspException {
List errorMessages = new ArrayList(); List<String> errorMessages = new ArrayList<String>();
errorMessages.addAll(Arrays.asList(getBindStatus().getErrorMessages())); errorMessages.addAll(Arrays.asList(getBindStatus().getErrorMessages()));
this.oldMessages = this.pageContext.getAttribute(MESSAGES_ATTRIBUTE, PageContext.PAGE_SCOPE); this.oldMessages = this.pageContext.getAttribute(MESSAGES_ATTRIBUTE, PageContext.PAGE_SCOPE);
this.pageContext.setAttribute(MESSAGES_ATTRIBUTE, errorMessages, PageContext.PAGE_SCOPE); this.pageContext.setAttribute(MESSAGES_ATTRIBUTE, errorMessages, PageContext.PAGE_SCOPE);

View File

@ -74,7 +74,7 @@ public class InternalResourceView extends AbstractUrlBasedView {
private boolean exposeContextBeansAsAttributes = false; private boolean exposeContextBeansAsAttributes = false;
private Set exposedContextBeanNames; private Set<String> exposedContextBeanNames;
private boolean preventDispatchLoop = false; private boolean preventDispatchLoop = false;
@ -158,7 +158,7 @@ public class InternalResourceView extends AbstractUrlBasedView {
* flag on but do not list specific bean names for this property. * flag on but do not list specific bean names for this property.
*/ */
public void setExposedContextBeanNames(String[] exposedContextBeanNames) { public void setExposedContextBeanNames(String[] exposedContextBeanNames) {
this.exposedContextBeanNames = new HashSet(Arrays.asList(exposedContextBeanNames)); this.exposedContextBeanNames = new HashSet<String>(Arrays.asList(exposedContextBeanNames));
} }
/** /**

View File

@ -37,9 +37,9 @@ public class ContextExposingHttpServletRequest extends HttpServletRequestWrapper
private final WebApplicationContext webApplicationContext; private final WebApplicationContext webApplicationContext;
private final Set exposedContextBeanNames; private final Set<String> exposedContextBeanNames;
private Set explicitAttributes; private Set<String> explicitAttributes;
/** /**
@ -60,7 +60,7 @@ public class ContextExposingHttpServletRequest extends HttpServletRequestWrapper
* Set are eligible for exposure as attributes) * Set are eligible for exposure as attributes)
*/ */
public ContextExposingHttpServletRequest( public ContextExposingHttpServletRequest(
HttpServletRequest originalRequest, WebApplicationContext context, Set exposedContextBeanNames) { HttpServletRequest originalRequest, WebApplicationContext context, Set<String> exposedContextBeanNames) {
super(originalRequest); super(originalRequest);
Assert.notNull(context, "WebApplicationContext must not be null"); Assert.notNull(context, "WebApplicationContext must not be null");
@ -93,7 +93,7 @@ public class ContextExposingHttpServletRequest extends HttpServletRequestWrapper
public void setAttribute(String name, Object value) { public void setAttribute(String name, Object value) {
super.setAttribute(name, value); super.setAttribute(name, value);
if (this.explicitAttributes == null) { if (this.explicitAttributes == null) {
this.explicitAttributes = new HashSet(8); this.explicitAttributes = new HashSet<String>(8);
} }
this.explicitAttributes.add(name); this.explicitAttributes.add(name);
} }

View File

@ -83,7 +83,7 @@ public abstract class GenericFilterBean implements
* Set of required properties (Strings) that must be supplied as * Set of required properties (Strings) that must be supplied as
* config parameters to this filter. * config parameters to this filter.
*/ */
private final Set requiredProperties = new HashSet(); private final Set<String> requiredProperties = new HashSet<String>();
/* The FilterConfig of this filter */ /* The FilterConfig of this filter */
private FilterConfig filterConfig; private FilterConfig filterConfig;
@ -275,11 +275,11 @@ public abstract class GenericFilterBean implements
* we can't accept default values * we can't accept default values
* @throws ServletException if any required properties are missing * @throws ServletException if any required properties are missing
*/ */
public FilterConfigPropertyValues(FilterConfig config, Set requiredProperties) public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties)
throws ServletException { throws ServletException {
Set missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ? Set<String> missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ?
new HashSet(requiredProperties) : null; new HashSet<String>(requiredProperties) : null;
Enumeration en = config.getInitParameterNames(); Enumeration en = config.getInitParameterNames();
while (en.hasMoreElements()) { while (en.hasMoreElements()) {