Skip to content

Commit e324c2a

Browse files
committed
Polishing
1 parent 39a2366 commit e324c2a

File tree

5 files changed

+39
-55
lines changed

5 files changed

+39
-55
lines changed

spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,16 @@ protected void processConfigurationClass(ConfigurationClass configClass) throws
231231
* @return the superclass, or {@code null} if none found or previously processed
232232
*/
233233
protected final SourceClass doProcessConfigurationClass(ConfigurationClass configClass, SourceClass sourceClass) throws IOException {
234-
// recursively process any member (nested) classes first
234+
// Recursively process any member (nested) classes first
235235
processMemberClasses(configClass, sourceClass);
236236

237-
// process any @PropertySource annotations
237+
// Process any @PropertySource annotations
238238
for (AnnotationAttributes propertySource : AnnotationConfigUtils.attributesForRepeatable(
239239
sourceClass.getMetadata(), PropertySources.class, org.springframework.context.annotation.PropertySource.class)) {
240240
processPropertySource(propertySource);
241241
}
242242

243-
// process any @ComponentScan annotations
243+
// Process any @ComponentScan annotations
244244
AnnotationAttributes componentScan = AnnotationConfigUtils.attributesFor(sourceClass.getMetadata(), ComponentScan.class);
245245
if (componentScan != null) {
246246
// the config class is annotated with @ComponentScan -> perform the scan immediately
@@ -257,10 +257,10 @@ protected final SourceClass doProcessConfigurationClass(ConfigurationClass confi
257257
}
258258
}
259259

260-
// process any @Import annotations
260+
// Process any @Import annotations
261261
processImports(configClass, sourceClass, getImports(sourceClass), true);
262262

263-
// process any @ImportResource annotations
263+
// Process any @ImportResource annotations
264264
if (sourceClass.getMetadata().isAnnotated(ImportResource.class.getName())) {
265265
AnnotationAttributes importResource = AnnotationConfigUtils.attributesFor(sourceClass.getMetadata(), ImportResource.class);
266266
String[] resources = importResource.getStringArray("value");
@@ -271,18 +271,18 @@ protected final SourceClass doProcessConfigurationClass(ConfigurationClass confi
271271
}
272272
}
273273

274-
// process individual @Bean methods
274+
// Process individual @Bean methods
275275
Set<MethodMetadata> beanMethods = sourceClass.getMetadata().getAnnotatedMethods(Bean.class.getName());
276276
for (MethodMetadata methodMetadata : beanMethods) {
277277
configClass.addBeanMethod(new BeanMethod(methodMetadata, configClass));
278278
}
279279

280-
// process superclass, if any
280+
// Process superclass, if any
281281
if (sourceClass.getMetadata().hasSuperClass()) {
282282
String superclass = sourceClass.getMetadata().getSuperClassName();
283283
if (!superclass.startsWith("java") && !this.knownSuperclasses.containsKey(superclass)) {
284284
this.knownSuperclasses.put(superclass, configClass);
285-
// superclass found, return its annotation metadata and recurse
285+
// Superclass found, return its annotation metadata and recurse
286286
try {
287287
return sourceClass.getSuperClass();
288288
}
@@ -292,7 +292,7 @@ protected final SourceClass doProcessConfigurationClass(ConfigurationClass confi
292292
}
293293
}
294294

295-
// no superclass, processing is complete
295+
// No superclass, processing is complete
296296
return null;
297297
}
298298

spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -66,7 +66,7 @@ public void setProperties(Properties properties) {
6666
* Set local properties, e.g. via the "props" tag in XML bean definitions,
6767
* allowing for merging multiple properties sets into one.
6868
*/
69-
public void setPropertiesArray(Properties[] propertiesArray) {
69+
public void setPropertiesArray(Properties... propertiesArray) {
7070
this.localProperties = propertiesArray;
7171
}
7272

@@ -88,7 +88,7 @@ public void setLocation(Resource location) {
8888
* Hence, make sure that the most specific files are the last
8989
* ones in the given list of locations.
9090
*/
91-
public void setLocations(Resource[] locations) {
91+
public void setLocations(Resource... locations) {
9292
this.locations = locations;
9393
}
9494

spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,23 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
5858

5959
/**
6060
* Provide a URL path to help identify the target request for this FlashMap.
61-
* The path may be absolute (e.g. /application/resource) or relative to the
62-
* current request (e.g. ../resource).
63-
* @param path the URI path
61+
* <p>The path may be absolute (e.g. "/application/resource") or relative to the
62+
* current request (e.g. "../resource").
6463
*/
6564
public void setTargetRequestPath(String path) {
6665
this.targetRequestPath = path;
6766
}
6867

6968
/**
70-
* Return the target URL path or {@code null}.
69+
* Return the target URL path (or {@code null} if none specified).
7170
*/
7271
public String getTargetRequestPath() {
7372
return this.targetRequestPath;
7473
}
7574

7675
/**
7776
* Provide request parameters identifying the request for this FlashMap.
78-
* @param params a Map with the names and values of expected parameters.
77+
* @param params a Map with the names and values of expected parameters
7978
*/
8079
public FlashMap addTargetRequestParams(MultiValueMap<String, String> params) {
8180
if (params != null) {
@@ -90,8 +89,8 @@ public FlashMap addTargetRequestParams(MultiValueMap<String, String> params) {
9089

9190
/**
9291
* Provide a request parameter identifying the request for this FlashMap.
93-
* @param name the expected parameter name, skipped if empty or {@code null}
94-
* @param value the expected value, skipped if empty or {@code null}
92+
* @param name the expected parameter name (skipped if empty or {@code null})
93+
* @param value the expected value (skipped if empty or {@code null})
9594
*/
9695
public FlashMap addTargetRequestParam(String name, String value) {
9796
if (StringUtils.hasText(name) && StringUtils.hasText(value)) {
@@ -117,18 +116,15 @@ public void startExpirationPeriod(int timeToLive) {
117116
}
118117

119118
/**
120-
* Whether this instance has expired depending on the amount of elapsed
121-
* time since the call to {@link #startExpirationPeriod}.
119+
* Return whether this instance has expired depending on the amount of
120+
* elapsed time since the call to {@link #startExpirationPeriod}.
122121
*/
123122
public boolean isExpired() {
124-
if (this.expirationStartTime != 0) {
125-
return (System.currentTimeMillis() - this.expirationStartTime > this.timeToLive * 1000);
126-
}
127-
else {
128-
return false;
129-
}
123+
return (this.expirationStartTime != 0 &&
124+
(System.currentTimeMillis() - this.expirationStartTime > this.timeToLive * 1000));
130125
}
131126

127+
132128
/**
133129
* Compare two FlashMaps and prefer the one that specifies a target URL
134130
* path or has more target URL parameters. Before comparing FlashMap
Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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,10 +16,7 @@
1616

1717
package org.springframework.web.socket.handler;
1818

19-
import org.apache.commons.logging.Log;
20-
import org.apache.commons.logging.LogFactory;
2119
import org.springframework.beans.BeanUtils;
22-
import org.springframework.beans.BeansException;
2320
import org.springframework.beans.factory.BeanFactory;
2421
import org.springframework.beans.factory.BeanFactoryAware;
2522
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
@@ -35,8 +32,6 @@
3532
*/
3633
public class BeanCreatingHandlerProvider<T> implements BeanFactoryAware {
3734

38-
private static final Log logger = LogFactory.getLog(BeanCreatingHandlerProvider.class);
39-
4035
private final Class<? extends T> handlerType;
4136

4237
private AutowireCapableBeanFactory beanFactory;
@@ -49,41 +44,35 @@ public BeanCreatingHandlerProvider(Class<? extends T> handlerType) {
4944

5045

5146
@Override
52-
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
47+
public void setBeanFactory(BeanFactory beanFactory) {
5348
if (beanFactory instanceof AutowireCapableBeanFactory) {
5449
this.beanFactory = (AutowireCapableBeanFactory) beanFactory;
5550
}
5651
}
5752

53+
public void destroy(T handler) {
54+
if (this.beanFactory != null) {
55+
this.beanFactory.destroyBean(handler);
56+
}
57+
}
58+
59+
5860
public Class<? extends T> getHandlerType() {
5961
return this.handlerType;
6062
}
6163

6264
public T getHandler() {
63-
if (logger.isTraceEnabled()) {
64-
logger.trace("Creating instance for handler type " + this.handlerType);
65-
}
66-
if (this.beanFactory == null) {
67-
logger.warn("No BeanFactory available, attempting to use default constructor");
68-
return BeanUtils.instantiate(this.handlerType);
69-
}
70-
else {
65+
if (this.beanFactory != null) {
7166
return this.beanFactory.createBean(this.handlerType);
7267
}
73-
}
74-
75-
public void destroy(T handler) {
76-
if (this.beanFactory != null) {
77-
if (logger.isTraceEnabled()) {
78-
logger.trace("Destroying handler instance " + handler);
79-
}
80-
this.beanFactory.destroyBean(handler);
68+
else {
69+
return BeanUtils.instantiate(this.handlerType);
8170
}
8271
}
8372

8473
@Override
8574
public String toString() {
86-
return "BeanCreatingHandlerProvider [handlerClass=" + this.handlerType + "]";
75+
return "BeanCreatingHandlerProvider[handlerType=" + this.handlerType + "]";
8776
}
8877

8978
}

spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -28,7 +28,6 @@
2828
import javax.websocket.server.HandshakeRequest;
2929
import javax.websocket.server.ServerEndpointConfig;
3030

31-
import org.springframework.beans.BeansException;
3231
import org.springframework.beans.factory.BeanFactory;
3332
import org.springframework.beans.factory.BeanFactoryAware;
3433
import org.springframework.util.Assert;
@@ -50,7 +49,6 @@
5049
*
5150
* @author Rossen Stoyanchev
5251
* @since 4.0
53-
*
5452
* @see ServerEndpointExporter
5553
*/
5654
public class ServerEndpointRegistration extends ServerEndpointConfig.Configurator
@@ -169,12 +167,13 @@ public Configurator getConfigurator() {
169167
}
170168

171169
@Override
172-
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
170+
public void setBeanFactory(BeanFactory beanFactory) {
173171
if (this.endpointProvider != null) {
174172
this.endpointProvider.setBeanFactory(beanFactory);
175173
}
176174
}
177175

176+
178177
// Implementations of ServerEndpointConfig.Configurator
179178

180179
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)