Polishing

This commit is contained in:
Juergen Hoeller
2014-08-18 22:24:43 +02:00
parent 3e17331fd9
commit 21f0057990
8 changed files with 41 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ import org.springframework.util.ReflectionUtils;
* also necessary for loading EhCache configuration from a non-default config location.
*
* <p>Note: As of Spring 3.0, Spring's EhCache support requires EhCache 1.3 or higher.
* As of Spring 3.2, we recommend using EhCache 2.1 or higher.
* As of Spring 3.2, we recommend using EhCache 2.5 or higher.
*
* @author Dmitriy Kopylenko
* @author Juergen Hoeller
@@ -106,7 +106,7 @@ public class EhCacheManagerFactoryBean implements FactoryBean<CacheManager>, Ini
}
public void afterPropertiesSet() throws IOException, CacheException {
public void afterPropertiesSet() throws CacheException, IOException {
logger.info("Initializing EhCache CacheManager");
InputStream is = (this.configLocation != null ? this.configLocation.getInputStream() : null);
try {

View File

@@ -146,7 +146,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
*/
public void setJobDetails(JobDetail... jobDetails) {
// Use modifiable ArrayList here, to allow for further adding of
// JobDetail objects during autodetection of JobDetailAwareTriggers.
// JobDetail objects during autodetection of JobDetail-aware Triggers.
this.jobDetails = new ArrayList<JobDetail>(Arrays.asList(jobDetails));
}

View File

@@ -470,7 +470,6 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
configTimeNonTransactionalDataSourceHolder.set(this.nonTransactionalDataSource);
}
// Get Scheduler instance from SchedulerFactory.
try {
this.scheduler = createScheduler(schedulerFactory, this.schedulerName);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,12 +45,11 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing
public void afterPropertiesSet() {
Collection<? extends Cache> caches = loadCaches();
// preserve the initial order of the cache names
// Preserve the initial order of the cache names
this.cacheMap.clear();
this.cacheNames.clear();
for (Cache cache : caches) {
this.cacheMap.put(cache.getName(), decorateCache(cache));
this.cacheNames.add(cache.getName());
addCache(cache);
}
}
@@ -80,8 +79,9 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing
/**
* Load the caches for this cache manager. Occurs at startup.
* The returned collection must not be null.
* Load the initial caches for this cache manager.
* <p>Called by {@link #afterPropertiesSet()} on startup.
* The returned collection may be empty but must not be {@code null}.
*/
protected abstract Collection<? extends Cache> loadCaches();

View File

@@ -172,24 +172,24 @@ class ConfigurationClassParser {
* @return annotation metadata of superclass, {@code null} if none found or previously processed
*/
protected AnnotationMetadata doProcessConfigurationClass(ConfigurationClass configClass, AnnotationMetadata metadata) throws IOException {
// recursively process any member (nested) classes first
// Recursively process any member (nested) classes first
processMemberClasses(metadata);
// process any @PropertySource annotations
// Process any @PropertySource annotations
AnnotationAttributes propertySource = MetadataUtils.attributesFor(metadata,
org.springframework.context.annotation.PropertySource.class);
if (propertySource != null) {
processPropertySource(propertySource);
}
// process any @ComponentScan annotations
// Process any @ComponentScan annotations
AnnotationAttributes componentScan = MetadataUtils.attributesFor(metadata, ComponentScan.class);
if (componentScan != null) {
// the config class is annotated with @ComponentScan -> perform the scan immediately
// The config class is annotated with @ComponentScan -> perform the scan immediately
Set<BeanDefinitionHolder> scannedBeanDefinitions =
this.componentScanParser.parse(componentScan, metadata.getClassName());
// check the set of scanned definitions for any further config classes and parse recursively if necessary
// Check the set of scanned definitions for any further config classes and parse recursively if necessary
for (BeanDefinitionHolder holder : scannedBeanDefinitions) {
if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
this.parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
@@ -197,7 +197,7 @@ class ConfigurationClassParser {
}
}
// process any @Import annotations
// Process any @Import annotations
Set<Object> imports = new LinkedHashSet<Object>();
Set<Object> visited = new LinkedHashSet<Object>();
collectImports(metadata, imports, visited);
@@ -205,7 +205,7 @@ class ConfigurationClassParser {
processImport(configClass, metadata, imports, true);
}
// process any @ImportResource annotations
// Process any @ImportResource annotations
if (metadata.isAnnotated(ImportResource.class.getName())) {
AnnotationAttributes importResource = MetadataUtils.attributesFor(metadata, ImportResource.class);
String[] resources = importResource.getStringArray("value");
@@ -216,13 +216,13 @@ class ConfigurationClassParser {
}
}
// process individual @Bean methods
// Process individual @Bean methods
Set<MethodMetadata> beanMethods = metadata.getAnnotatedMethods(Bean.class.getName());
for (MethodMetadata methodMetadata : beanMethods) {
configClass.addBeanMethod(new BeanMethod(methodMetadata, configClass));
}
// process superclass, if any
// Process superclass, if any
if (metadata.hasSuperClass()) {
String superclass = metadata.getSuperClassName();
if (!superclass.startsWith("java") && !this.knownSuperclasses.containsKey(superclass)) {
@@ -239,7 +239,7 @@ class ConfigurationClassParser {
}
}
// no superclass, processing is complete
// No superclass -> processing is complete
return null;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ public abstract class PropertiesLoaderSupport {
* Set local properties, e.g. via the "props" tag in XML bean definitions,
* allowing for merging multiple properties sets into one.
*/
public void setPropertiesArray(Properties[] propertiesArray) {
public void setPropertiesArray(Properties... propertiesArray) {
this.localProperties = propertiesArray;
}
@@ -88,7 +88,7 @@ public abstract class PropertiesLoaderSupport {
* Hence, make sure that the most specific files are the last
* ones in the given list of locations.
*/
public void setLocations(Resource[] locations) {
public void setLocations(Resource... locations) {
this.locations = locations;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,15 +21,19 @@ import org.springframework.util.ObjectUtils;
/**
* Extension of {@link HttpEntity} that adds a {@link HttpStatus} status code.
* Used in {@code RestTemplate} as well {@code @Controller} methods.
*
* <p>Returned by {@link org.springframework.web.client.RestTemplate#getForEntity}:
* <p>In {@code RestTemplate}, this class is returned by
* {@link org.springframework.web.client.RestTemplate#getForEntity getForEntity()} and
* {@link org.springframework.web.client.RestTemplate#exchange exchange()}:
* <pre class="code">
* ResponseEntity&lt;String&gt; entity = template.getForEntity("http://example.com", String.class);
* String body = entity.getBody();
* MediaType contentType = entity.getHeaders().getContentType();
* HttpStatus statusCode = entity.getStatusCode();
* </pre>
* <p>Can also be used in Spring MVC, as a return value from a @Controller method:
*
* <p>Can also be used in Spring MVC, as the return value from a @Controller method:
* <pre class="code">
* &#64;RequestMapping("/handle")
* public ResponseEntity&lt;String&gt; handle() {

View File

@@ -58,16 +58,15 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
/**
* Provide a URL path to help identify the target request for this FlashMap.
* The path may be absolute (e.g. /application/resource) or relative to the
* current request (e.g. ../resource).
* @param path the URI path
* <p>The path may be absolute (e.g. "/application/resource") or relative to the
* current request (e.g. "../resource").
*/
public void setTargetRequestPath(String path) {
this.targetRequestPath = path;
}
/**
* Return the target URL path or {@code null}.
* Return the target URL path (or {@code null} if none specified).
*/
public String getTargetRequestPath() {
return this.targetRequestPath;
@@ -75,7 +74,7 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
/**
* Provide request parameters identifying the request for this FlashMap.
* @param params a Map with the names and values of expected parameters.
* @param params a Map with the names and values of expected parameters
*/
public FlashMap addTargetRequestParams(MultiValueMap<String, String> params) {
if (params != null) {
@@ -90,8 +89,8 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
/**
* Provide a request parameter identifying the request for this FlashMap.
* @param name the expected parameter name, skipped if empty or {@code null}
* @param value the expected value, skipped if empty or {@code null}
* @param name the expected parameter name (skipped if empty or {@code null})
* @param value the expected value (skipped if empty or {@code null})
*/
public FlashMap addTargetRequestParam(String name, String value) {
if (StringUtils.hasText(name) && StringUtils.hasText(value)) {
@@ -117,18 +116,15 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
}
/**
* Whether this instance has expired depending on the amount of elapsed
* time since the call to {@link #startExpirationPeriod}.
* Return whether this instance has expired depending on the amount of
* elapsed time since the call to {@link #startExpirationPeriod}.
*/
public boolean isExpired() {
if (this.expirationStartTime != 0) {
return (System.currentTimeMillis() - this.expirationStartTime > this.timeToLive * 1000);
}
else {
return false;
}
return (this.expirationStartTime != 0 &&
(System.currentTimeMillis() - this.expirationStartTime > this.timeToLive * 1000));
}
/**
* Compare two FlashMaps and prefer the one that specifies a target URL
* path or has more target URL parameters. Before comparing FlashMap