Skip to content

Commit 2965710

Browse files
committed
Java 5 code style
1 parent 1f9e63a commit 2965710

File tree

71 files changed

+726
-877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+726
-877
lines changed

org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AspectJProxyUtils.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.aop.aspectj;
1818

19-
import java.util.Iterator;
2019
import java.util.List;
2120

2221
import org.springframework.aop.Advisor;
@@ -40,12 +39,11 @@ public abstract class AspectJProxyUtils {
4039
* @param advisors Advisors available
4140
* @return <code>true</code> if any special {@link Advisor Advisors} were added, otherwise <code>false</code>.
4241
*/
43-
public static boolean makeAdvisorChainAspectJCapableIfNecessary(List advisors) {
42+
public static boolean makeAdvisorChainAspectJCapableIfNecessary(List<Advisor> advisors) {
4443
// Don't add advisors to an empty list; may indicate that proxying is just not required
4544
if (!advisors.isEmpty()) {
4645
boolean foundAspectJAdvice = false;
47-
for (Iterator it = advisors.iterator(); it.hasNext() && !foundAspectJAdvice; ) {
48-
Advisor advisor = (Advisor) it.next();
46+
for (Advisor advisor : advisors) {
4947
// Be careful not to get the Advice without a guard, as
5048
// this might eagerly instantiate a non-singleton AspectJ aspect
5149
if (isAspectJAdvice(advisor)) {

org.springframework.aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
1818

1919
import java.util.Collections;
2020
import java.util.HashMap;
21-
import java.util.Iterator;
2221
import java.util.LinkedList;
2322
import java.util.List;
2423
import java.util.Map;
@@ -138,8 +137,7 @@ public List<Advisor> buildAspectJAdvisors() {
138137
return Collections.EMPTY_LIST;
139138
}
140139
List<Advisor> advisors = new LinkedList<Advisor>();
141-
for (Iterator it = aspectNames.iterator(); it.hasNext();) {
142-
String aspectName = (String) it.next();
140+
for (String aspectName : aspectNames) {
143141
List<Advisor> cachedAdvisors = this.advisorsCache.get(aspectName);
144142
if (cachedAdvisors != null) {
145143
advisors.addAll(cachedAdvisors);

org.springframework.aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
package org.springframework.aop.aspectj.autoproxy;
1818

1919
import java.util.Comparator;
20-
import java.util.Iterator;
2120
import java.util.LinkedList;
2221
import java.util.List;
2322

@@ -65,27 +64,27 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
6564
* advisor should run last.
6665
*/
6766
@Override
68-
protected List sortAdvisors(List advisors) {
67+
@SuppressWarnings("unchecked")
68+
protected List<Advisor> sortAdvisors(List<Advisor> advisors) {
6969
// build list for sorting
70-
List partiallyComparableAdvisors = new LinkedList();
71-
for (Iterator it = advisors.iterator(); it.hasNext();) {
72-
Advisor element = (Advisor) it.next();
73-
PartiallyComparableAdvisorHolder advisor =
74-
new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR);
75-
partiallyComparableAdvisors.add(advisor);
70+
List<PartiallyComparableAdvisorHolder> partiallyComparableAdvisors =
71+
new LinkedList<PartiallyComparableAdvisorHolder>();
72+
for (Advisor element : advisors) {
73+
partiallyComparableAdvisors.add(
74+
new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR));
7675
}
7776

7877
// sort it
79-
List sorted = PartialOrder.sort(partiallyComparableAdvisors);
78+
List<PartiallyComparableAdvisorHolder> sorted =
79+
(List<PartiallyComparableAdvisorHolder>) PartialOrder.sort(partiallyComparableAdvisors);
8080
if (sorted == null) {
81-
// TODO: work much harder to give a better error message here.
81+
// TODO: work harder to give a better error message here.
8282
throw new IllegalArgumentException("Advice precedence circularity error");
8383
}
8484

8585
// extract results again
86-
List result = new LinkedList();
87-
for (Iterator it = sorted.iterator(); it.hasNext();) {
88-
PartiallyComparableAdvisorHolder pcAdvisor = (PartiallyComparableAdvisorHolder) it.next();
86+
List<Advisor> result = new LinkedList<Advisor>();
87+
for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) {
8988
result.add(pcAdvisor.getAdvisor());
9089
}
9190

@@ -98,35 +97,35 @@ protected List sortAdvisors(List advisors) {
9897
* and when using AspectJ-style advice.
9998
*/
10099
@Override
101-
protected void extendAdvisors(List candidateAdvisors) {
100+
protected void extendAdvisors(List<Advisor> candidateAdvisors) {
102101
AspectJProxyUtils.makeAdvisorChainAspectJCapableIfNecessary(candidateAdvisors);
103102
}
104103

105104
@Override
106105
protected boolean shouldSkip(Class beanClass, String beanName) {
107106
// TODO: Consider optimization by caching the list of the aspect names
108-
List candidtate = findCandidateAdvisors();
109-
for (Iterator it = candidtate.iterator(); it.hasNext();) {
110-
Advisor advisor = (Advisor) it.next();
107+
List<Advisor> candidateAdvisors = findCandidateAdvisors();
108+
for (Advisor advisor : candidateAdvisors) {
111109
if (advisor instanceof AspectJPointcutAdvisor) {
112-
if(((AbstractAspectJAdvice) advisor.getAdvice()).getAspectName().equals(beanName)) {
110+
if (((AbstractAspectJAdvice) advisor.getAdvice()).getAspectName().equals(beanName)) {
113111
return true;
114112
}
115113
}
116114
}
117115
return super.shouldSkip(beanClass, beanName);
118116
}
119117

118+
120119
/**
121120
* Implements AspectJ PartialComparable interface for defining partial orderings.
122121
*/
123122
private static class PartiallyComparableAdvisorHolder implements PartialComparable {
124123

125124
private final Advisor advisor;
126125

127-
private final Comparator comparator;
126+
private final Comparator<Advisor> comparator;
128127

129-
public PartiallyComparableAdvisorHolder(Advisor advisor, Comparator comparator) {
128+
public PartiallyComparableAdvisorHolder(Advisor advisor, Comparator<Advisor> comparator) {
130129
this.advisor = advisor;
131130
this.comparator = comparator;
132131
}
@@ -151,7 +150,7 @@ public String toString() {
151150
sb.append(ClassUtils.getShortName(advice.getClass()));
152151
sb.append(": ");
153152
if (this.advisor instanceof Ordered) {
154-
sb.append("order " + ((Ordered) this.advisor).getOrder() + ", ");
153+
sb.append("order ").append(((Ordered) this.advisor).getOrder()).append(", ");
155154
}
156155
if (advice instanceof AbstractAspectJAdvice) {
157156
AbstractAspectJAdvice ajAdvice = (AbstractAspectJAdvice) advice;

org.springframework.aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
6262
private ConfigurableBeanFactory beanFactory;
6363

6464
/** Internally used DefaultListableBeanFactory instances, keyed by bean name */
65-
private final Map internalBeanFactories = new HashMap();
65+
private final Map<String, DefaultListableBeanFactory> internalBeanFactories =
66+
new HashMap<String, DefaultListableBeanFactory>();
6667

6768

6869
public final void setBeanFactory(BeanFactory beanFactory) {
@@ -121,15 +122,14 @@ public final TargetSource getTargetSource(Class beanClass, String beanName) {
121122
* @return the internal BeanFactory to be used
122123
*/
123124
protected DefaultListableBeanFactory getInternalBeanFactoryForBean(String beanName) {
124-
DefaultListableBeanFactory internalBeanFactory = null;
125125
synchronized (this.internalBeanFactories) {
126-
internalBeanFactory = (DefaultListableBeanFactory) this.internalBeanFactories.get(beanName);
126+
DefaultListableBeanFactory internalBeanFactory = this.internalBeanFactories.get(beanName);
127127
if (internalBeanFactory == null) {
128128
internalBeanFactory = buildInternalBeanFactory(this.beanFactory);
129129
this.internalBeanFactories.put(beanName, internalBeanFactory);
130130
}
131+
return internalBeanFactory;
131132
}
132-
return internalBeanFactory;
133133
}
134134

135135
/**
@@ -146,9 +146,8 @@ protected DefaultListableBeanFactory buildInternalBeanFactory(ConfigurableBeanFa
146146

147147
// Filter out BeanPostProcessors that are part of the AOP infrastructure,
148148
// since those are only meant to apply to beans defined in the original factory.
149-
for (Iterator it = internalBeanFactory.getBeanPostProcessors().iterator(); it.hasNext();) {
150-
BeanPostProcessor postProcessor = (BeanPostProcessor) it.next();
151-
if (postProcessor instanceof AopInfrastructureBean) {
149+
for (Iterator<BeanPostProcessor> it = internalBeanFactory.getBeanPostProcessors().iterator(); it.hasNext();) {
150+
if (it.next() instanceof AopInfrastructureBean) {
152151
it.remove();
153152
}
154153
}
@@ -162,8 +161,8 @@ protected DefaultListableBeanFactory buildInternalBeanFactory(ConfigurableBeanFa
162161
*/
163162
public void destroy() {
164163
synchronized (this.internalBeanFactories) {
165-
for (Iterator it = this.internalBeanFactories.values().iterator(); it.hasNext();) {
166-
((DefaultListableBeanFactory) it.next()).destroySingletons();
164+
for (DefaultListableBeanFactory bf : this.internalBeanFactories.values()) {
165+
bf.destroySingletons();
167166
}
168167
}
169168
}

org.springframework.aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
1818

1919
import java.io.Serializable;
2020
import java.util.HashSet;
21-
import java.util.Iterator;
2221
import java.util.Set;
2322

2423
import org.aopalliance.aop.Advice;
@@ -43,7 +42,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
4342

4443
private final Advice advice;
4544

46-
private final Set interfaces = new HashSet();
45+
private final Set<Class> interfaces = new HashSet<Class>();
4746

4847
private int order = Integer.MAX_VALUE;
4948

@@ -72,8 +71,8 @@ public DefaultIntroductionAdvisor(Advice advice, IntroductionInfo introductionIn
7271
if (introducedInterfaces.length == 0) {
7372
throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces");
7473
}
75-
for (int i = 0; i < introducedInterfaces.length; i++) {
76-
addInterface(introducedInterfaces[i]);
74+
for (Class ifc : introducedInterfaces) {
75+
addInterface(ifc);
7776
}
7877
}
7978
}
@@ -103,12 +102,11 @@ public void addInterface(Class intf) {
103102
}
104103

105104
public Class[] getInterfaces() {
106-
return (Class[]) this.interfaces.toArray(new Class[this.interfaces.size()]);
105+
return this.interfaces.toArray(new Class[this.interfaces.size()]);
107106
}
108107

109108
public void validateInterfaces() throws IllegalArgumentException {
110-
for (Iterator it = this.interfaces.iterator(); it.hasNext();) {
111-
Class ifc = (Class) it.next();
109+
for (Class ifc : this.interfaces) {
112110
if (this.advice instanceof DynamicIntroductionAdvice &&
113111
!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
114112
throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +

org.springframework.aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@
1919
import java.io.IOException;
2020
import java.io.ObjectInputStream;
2121
import java.io.Serializable;
22+
import java.lang.reflect.Method;
2223
import java.util.HashSet;
2324
import java.util.IdentityHashMap;
24-
import java.util.Iterator;
2525
import java.util.Map;
2626
import java.util.Set;
2727

@@ -46,13 +46,9 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
4646

4747
protected transient Log logger = LogFactory.getLog(getClass());
4848

49-
/** Set of interface Classes */
50-
protected Set publishedInterfaces = new HashSet();
49+
protected Set<Class> publishedInterfaces = new HashSet<Class>();
5150

52-
/**
53-
* Methods that we know we should implement here: key is Method, value is Boolean.
54-
**/
55-
private transient Map rememberedMethods = createRememberedMethodMap();
51+
private transient Map<Method, Boolean> rememberedMethods = new IdentityHashMap<Method, Boolean>(32);
5652

5753

5854
/**
@@ -67,18 +63,17 @@ public void suppressInterface(Class intf) {
6763
}
6864

6965
public Class[] getInterfaces() {
70-
return (Class[]) this.publishedInterfaces.toArray(new Class[this.publishedInterfaces.size()]);
66+
return this.publishedInterfaces.toArray(new Class[this.publishedInterfaces.size()]);
7167
}
7268

7369
/**
7470
* Check whether the specified interfaces is a published introduction interface.
75-
* @param intf the interface to check
71+
* @param ifc the interface to check
7672
* @return whether the interface is part of this introduction
7773
*/
78-
public boolean implementsInterface(Class intf) {
79-
for (Iterator it = this.publishedInterfaces.iterator(); it.hasNext();) {
80-
Class pubIntf = (Class) it.next();
81-
if (intf.isInterface() && intf.isAssignableFrom(pubIntf)) {
74+
public boolean implementsInterface(Class ifc) {
75+
for (Class pubIfc : this.publishedInterfaces) {
76+
if (ifc.isInterface() && ifc.isAssignableFrom(pubIfc)) {
8277
return true;
8378
}
8479
}
@@ -93,24 +88,20 @@ protected void implementInterfacesOnObject(Object delegate) {
9388
this.publishedInterfaces.addAll(ClassUtils.getAllInterfacesAsSet(delegate));
9489
}
9590

96-
private Map createRememberedMethodMap() {
97-
return new IdentityHashMap(32);
98-
}
99-
10091
/**
10192
* Is this method on an introduced interface?
10293
* @param mi the method invocation
10394
* @return whether the invoked method is on an introduced interface
10495
*/
10596
protected final boolean isMethodOnIntroducedInterface(MethodInvocation mi) {
106-
Boolean rememberedResult = (Boolean) this.rememberedMethods.get(mi.getMethod());
97+
Boolean rememberedResult = this.rememberedMethods.get(mi.getMethod());
10798
if (rememberedResult != null) {
108-
return rememberedResult.booleanValue();
99+
return rememberedResult;
109100
}
110101
else {
111102
// Work it out and cache it.
112103
boolean result = implementsInterface(mi.getMethod().getDeclaringClass());
113-
this.rememberedMethods.put(mi.getMethod(), (result ? Boolean.TRUE : Boolean.FALSE));
104+
this.rememberedMethods.put(mi.getMethod(), result);
114105
return result;
115106
}
116107
}
@@ -131,7 +122,7 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
131122

132123
// Initialize transient fields.
133124
this.logger = LogFactory.getLog(getClass());
134-
this.rememberedMethods = createRememberedMethodMap();
125+
this.rememberedMethods = new IdentityHashMap<Method, Boolean>(32);
135126
}
136127

137128
}

org.springframework.beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,16 @@ public static void clearClassLoader(ClassLoader classLoader) {
103103
return;
104104
}
105105
synchronized (classCache) {
106-
for (Iterator it = classCache.keySet().iterator(); it.hasNext();) {
107-
Class beanClass = (Class) it.next();
106+
for (Iterator<Class> it = classCache.keySet().iterator(); it.hasNext();) {
107+
Class beanClass = it.next();
108108
if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) {
109109
it.remove();
110110
}
111111
}
112112
}
113113
synchronized (acceptedClassLoaders) {
114-
for (Iterator it = acceptedClassLoaders.iterator(); it.hasNext();) {
115-
ClassLoader registeredLoader = (ClassLoader) it.next();
114+
for (Iterator<ClassLoader> it = acceptedClassLoaders.iterator(); it.hasNext();) {
115+
ClassLoader registeredLoader = it.next();
116116
if (isUnderneathClassLoader(registeredLoader, classLoader)) {
117117
it.remove();
118118
}

0 commit comments

Comments
 (0)