Skip to content

Commit 160249c

Browse files
committed
generified FactoryBeans and further Java 5 code style updates
1 parent 555fa3b commit 160249c

File tree

48 files changed

+346
-335
lines changed

Some content is hidden

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

48 files changed

+346
-335
lines changed

org.springframework.aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2006 the original author or authors.
2+
* Copyright 2002-2009 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.
@@ -30,7 +30,7 @@
3030
* @author Rob Harrop
3131
* @since 2.0
3232
*/
33-
public class MethodLocatingFactoryBean implements FactoryBean, BeanFactoryAware {
33+
public class MethodLocatingFactoryBean implements FactoryBean<Method>, BeanFactoryAware {
3434

3535
private String targetBeanName;
3636

@@ -78,11 +78,11 @@ public void setBeanFactory(BeanFactory beanFactory) {
7878
}
7979

8080

81-
public Object getObject() throws Exception {
81+
public Method getObject() throws Exception {
8282
return this.method;
8383
}
8484

85-
public Class getObjectType() {
85+
public Class<Method> getObjectType() {
8686
return Method.class;
8787
}
8888

org.springframework.aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 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.
@@ -38,7 +38,7 @@
3838
* @since 2.0
3939
*/
4040
public abstract class AbstractSingletonProxyFactoryBean extends ProxyConfig
41-
implements FactoryBean, BeanClassLoaderAware, InitializingBean {
41+
implements FactoryBean<Object>, BeanClassLoaderAware, InitializingBean {
4242

4343
private Object target;
4444

@@ -196,7 +196,7 @@ public Object getObject() {
196196
return this.proxy;
197197
}
198198

199-
public Class getObjectType() {
199+
public Class<?> getObjectType() {
200200
if (this.proxy != null) {
201201
return this.proxy.getClass();
202202
}

org.springframework.aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
* @see Advised
9090
*/
9191
public class ProxyFactoryBean extends ProxyCreatorSupport
92-
implements FactoryBean, BeanClassLoaderAware, BeanFactoryAware {
92+
implements FactoryBean<Object>, BeanClassLoaderAware, BeanFactoryAware {
9393

9494
/**
9595
* This suffix in a value in an interceptor list indicates to expand globals.
@@ -256,7 +256,7 @@ public Object getObject() throws BeansException {
256256
* a single one), the target bean type, or the TargetSource's target class.
257257
* @see org.springframework.aop.TargetSource#getTargetClass
258258
*/
259-
public Class getObjectType() {
259+
public Class<?> getObjectType() {
260260
synchronized (this) {
261261
if (this.singletonInstance != null) {
262262
return this.singletonInstance.getClass();
@@ -448,7 +448,7 @@ private synchronized void initializeAdvisorChain() throws AopConfigException, Be
448448
else {
449449
// If we get here, we need to add a named interceptor.
450450
// We must check if it's a singleton or prototype.
451-
Object advice = null;
451+
Object advice;
452452
if (this.singleton || this.beanFactory.isSingleton(name)) {
453453
// Add the real Advisor/Advice to the chain.
454454
advice = this.beanFactory.getBean(name);

org.springframework.aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 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.
@@ -49,7 +49,7 @@
4949
* @since 2.0
5050
* @see #setProxyTargetClass
5151
*/
52-
public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean, BeanFactoryAware {
52+
public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean<Object>, BeanFactoryAware {
5353

5454
/** The TargetSource that manages scoping */
5555
private final SimpleBeanTargetSource scopedTargetSource = new SimpleBeanTargetSource();
@@ -117,7 +117,7 @@ public Object getObject() {
117117
return this.proxy;
118118
}
119119

120-
public Class getObjectType() {
120+
public Class<?> getObjectType() {
121121
if (this.proxy != null) {
122122
return this.proxy.getClass();
123123
}

org.springframework.beans/src/main/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java

Lines changed: 5 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-2009 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.
@@ -29,7 +29,7 @@
2929
import org.springframework.util.StringUtils;
3030

3131
/**
32-
* FactoryBean which retrieves a static or non-static field value.
32+
* {@link FactoryBean} which retrieves a static or non-static field value.
3333
*
3434
* <p>Typically used for retrieving public static final constants. Usage example:
3535
*
@@ -52,7 +52,8 @@
5252
* @since 1.1
5353
* @see #setStaticField
5454
*/
55-
public class FieldRetrievingFactoryBean implements FactoryBean, BeanNameAware, BeanClassLoaderAware, InitializingBean {
55+
public class FieldRetrievingFactoryBean
56+
implements FactoryBean<Object>, BeanNameAware, BeanClassLoaderAware, InitializingBean {
5657

5758
private Class targetClass;
5859

@@ -205,7 +206,7 @@ public Object getObject() throws IllegalAccessException {
205206
}
206207
}
207208

208-
public Class getObjectType() {
209+
public Class<?> getObjectType() {
209210
return (this.fieldObject != null ? this.fieldObject.getType() : null);
210211
}
211212

org.springframework.beans/src/main/java/org/springframework/beans/factory/config/MethodInvokingFactoryBean.java

Lines changed: 4 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-2009 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.
@@ -29,7 +29,7 @@
2929
import org.springframework.util.ClassUtils;
3030

3131
/**
32-
* FactoryBean which returns a value which is the result of a static or instance
32+
* {@link FactoryBean} which returns a value which is the result of a static or instance
3333
* method invocation. For most use cases it is better to just use the container's
3434
* built-in factory method support for the same purpose, since that is smarter at
3535
* converting arguments. This factory bean is still useful though when you need to
@@ -88,7 +88,7 @@
8888
* @since 21.11.2003
8989
*/
9090
public class MethodInvokingFactoryBean extends ArgumentConvertingMethodInvoker
91-
implements FactoryBean, BeanClassLoaderAware, BeanFactoryAware, InitializingBean {
91+
implements FactoryBean<Object>, BeanClassLoaderAware, BeanFactoryAware, InitializingBean {
9292

9393
private boolean singleton = true;
9494

@@ -196,7 +196,7 @@ public Object getObject() throws Exception {
196196
* Return the type of object that this FactoryBean creates,
197197
* or <code>null</code> if not known in advance.
198198
*/
199-
public Class getObjectType() {
199+
public Class<?> getObjectType() {
200200
if (!isPrepared()) {
201201
// Not fully initialized yet -> return null to indicate "not known yet".
202202
return null;

org.springframework.beans/src/main/java/org/springframework/beans/factory/config/PropertyPathFactoryBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 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.
@@ -81,7 +81,7 @@
8181
* @see #setTargetBeanName
8282
* @see #setPropertyPath
8383
*/
84-
public class PropertyPathFactoryBean implements FactoryBean, BeanNameAware, BeanFactoryAware {
84+
public class PropertyPathFactoryBean implements FactoryBean<Object>, BeanNameAware, BeanFactoryAware {
8585

8686
private static final Log logger = LogFactory.getLog(PropertyPathFactoryBean.class);
8787

@@ -207,7 +207,7 @@ public Object getObject() throws BeansException {
207207
return target.getPropertyValue(this.propertyPath);
208208
}
209209

210-
public Class getObjectType() {
210+
public Class<?> getObjectType() {
211211
return this.resultType;
212212
}
213213

org.springframework.beans/src/main/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBean.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 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.
@@ -35,9 +35,8 @@
3535
import org.springframework.util.StringUtils;
3636

3737
/**
38-
* A {@link org.springframework.beans.factory.FactoryBean} implementation that
39-
* takes an interface which must have one or more methods with
40-
* the signatures <code>MyType xxx()</code> or <code>MyType xxx(MyIdType id)</code>
38+
* A {@link FactoryBean} implementation that takes an interface which must have one or more
39+
* methods with the signatures <code>MyType xxx()</code> or <code>MyType xxx(MyIdType id)</code>
4140
* (typically, <code>MyService getService()</code> or <code>MyService getService(String id)</code>)
4241
* and creates a dynamic proxy which implements that interface, delegating to an
4342
* underlying {@link org.springframework.beans.factory.BeanFactory}.
@@ -188,7 +187,7 @@
188187
* @see #setServiceMappings
189188
* @see ObjectFactoryCreatingFactoryBean
190189
*/
191-
public class ServiceLocatorFactoryBean implements FactoryBean, BeanFactoryAware, InitializingBean {
190+
public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFactoryAware, InitializingBean {
192191

193192
private Class serviceLocatorInterface;
194193

@@ -328,7 +327,7 @@ public Object getObject() {
328327
return this.proxy;
329328
}
330329

331-
public Class getObjectType() {
330+
public Class<?> getObjectType() {
332331
return this.serviceLocatorInterface;
333332
}
334333

@@ -359,6 +358,7 @@ else if (ReflectionUtils.isToStringMethod(method)) {
359358
}
360359
}
361360

361+
@SuppressWarnings("unchecked")
362362
private Object invokeServiceLocatorMethod(Method method, Object[] args) throws Exception {
363363
Class serviceLocatorMethodReturnType = getServiceLocatorMethodReturnType(method);
364364
try {

org.springframework.context.support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* @see commonj.timers.TimerListener
5454
*/
5555
public class TimerManagerFactoryBean extends JndiLocatorSupport
56-
implements FactoryBean, InitializingBean, DisposableBean, Lifecycle {
56+
implements FactoryBean<TimerManager>, InitializingBean, DisposableBean, Lifecycle {
5757

5858
private TimerManager timerManager;
5959

@@ -169,11 +169,11 @@ public void afterPropertiesSet() throws NamingException {
169169
// Implementation of FactoryBean interface
170170
//---------------------------------------------------------------------
171171

172-
public Object getObject() {
172+
public TimerManager getObject() {
173173
return this.timerManager;
174174
}
175175

176-
public Class getObjectType() {
176+
public Class<? extends TimerManager> getObjectType() {
177177
return (this.timerManager != null ? this.timerManager.getClass() : TimerManager.class);
178178
}
179179

org.springframework.context.support/src/main/java/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2009 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.
@@ -70,7 +70,7 @@
7070
* @see #setConcurrent
7171
*/
7272
public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethodInvoker
73-
implements FactoryBean, BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean {
73+
implements FactoryBean<Object>, BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean {
7474

7575
private String name;
7676

@@ -171,7 +171,7 @@ public void afterPropertiesSet() throws ClassNotFoundException, NoSuchMethodExce
171171
String name = (this.name != null ? this.name : this.beanName);
172172

173173
// Consider the concurrent flag to choose between stateful and stateless job.
174-
Class jobClass = (this.concurrent ? (Class) MethodInvokingJob.class : StatefulMethodInvokingJob.class);
174+
Class jobClass = (this.concurrent ? MethodInvokingJob.class : StatefulMethodInvokingJob.class);
175175

176176
// Build JobDetail instance.
177177
this.jobDetail = new JobDetail(name, this.group, jobClass);
@@ -181,8 +181,8 @@ public void afterPropertiesSet() throws ClassNotFoundException, NoSuchMethodExce
181181

182182
// Register job listener names.
183183
if (this.jobListenerNames != null) {
184-
for (int i = 0; i < this.jobListenerNames.length; i++) {
185-
this.jobDetail.addJobListener(this.jobListenerNames[i]);
184+
for (String jobListenerName : this.jobListenerNames) {
185+
this.jobDetail.addJobListener(jobListenerName);
186186
}
187187
}
188188

@@ -229,7 +229,7 @@ public Object getObject() {
229229
return this.jobDetail;
230230
}
231231

232-
public Class getObjectType() {
232+
public Class<?> getObjectType() {
233233
return JobDetail.class;
234234
}
235235

0 commit comments

Comments
 (0)