Skip to content

Commit fdd1f83

Browse files
committed
Polishing
(cherry picked from commit 3783591)
1 parent ab2c721 commit fdd1f83

File tree

6 files changed

+38
-35
lines changed

6 files changed

+38
-35
lines changed

spring-context/src/main/java/org/springframework/cache/annotation/AbstractCachingConfiguration.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.cache.annotation;
1818

1919
import java.util.Collection;
20-
import javax.annotation.PostConstruct;
2120

2221
import org.springframework.beans.factory.annotation.Autowired;
2322
import org.springframework.cache.CacheManager;
@@ -28,12 +27,11 @@
2827
import org.springframework.context.annotation.ImportAware;
2928
import org.springframework.core.annotation.AnnotationAttributes;
3029
import org.springframework.core.type.AnnotationMetadata;
31-
import org.springframework.util.Assert;
3230
import org.springframework.util.CollectionUtils;
3331

3432
/**
35-
* Abstract base {@code @Configuration} class providing common structure for enabling
36-
* Spring's annotation-driven cache management capability.
33+
* Abstract base {@code @Configuration} class providing common structure
34+
* for enabling Spring's annotation-driven cache management capability.
3735
*
3836
* @author Chris Beams
3937
* @author Stephane Nicoll
@@ -53,13 +51,15 @@ public abstract class AbstractCachingConfiguration<C extends CachingConfigurer>
5351

5452
protected CacheErrorHandler errorHandler;
5553

54+
5655
@Override
5756
public void setImportMetadata(AnnotationMetadata importMetadata) {
5857
this.enableCaching = AnnotationAttributes.fromMap(
5958
importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false));
60-
Assert.notNull(this.enableCaching,
61-
"@EnableCaching is not present on importing class " +
62-
importMetadata.getClassName());
59+
if (this.enableCaching == null) {
60+
throw new IllegalArgumentException(
61+
"@EnableCaching is not present on importing class " + importMetadata.getClassName());
62+
}
6363
}
6464

6565
@Autowired(required = false)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -51,7 +51,7 @@ public class MBeanExportConfiguration implements ImportAware, EnvironmentAware,
5151

5252
private static final String MBEAN_EXPORTER_BEAN_NAME = "mbeanExporter";
5353

54-
private AnnotationAttributes attributes;
54+
private AnnotationAttributes enableMBeanExport;
5555

5656
private Environment environment;
5757

@@ -61,8 +61,8 @@ public class MBeanExportConfiguration implements ImportAware, EnvironmentAware,
6161
@Override
6262
public void setImportMetadata(AnnotationMetadata importMetadata) {
6363
Map<String, Object> map = importMetadata.getAnnotationAttributes(EnableMBeanExport.class.getName());
64-
this.attributes = AnnotationAttributes.fromMap(map);
65-
if (this.attributes == null) {
64+
this.enableMBeanExport = AnnotationAttributes.fromMap(map);
65+
if (this.enableMBeanExport == null) {
6666
throw new IllegalArgumentException(
6767
"@EnableMBeanExport is not present on importing class " + importMetadata.getClassName());
6868
}
@@ -90,7 +90,7 @@ public AnnotationMBeanExporter mbeanExporter() {
9090
}
9191

9292
private void setupDomain(AnnotationMBeanExporter exporter) {
93-
String defaultDomain = this.attributes.getString("defaultDomain");
93+
String defaultDomain = this.enableMBeanExport.getString("defaultDomain");
9494
if (defaultDomain != null && this.environment != null) {
9595
defaultDomain = this.environment.resolvePlaceholders(defaultDomain);
9696
}
@@ -100,7 +100,7 @@ private void setupDomain(AnnotationMBeanExporter exporter) {
100100
}
101101

102102
private void setupServer(AnnotationMBeanExporter exporter) {
103-
String server = this.attributes.getString("server");
103+
String server = this.enableMBeanExport.getString("server");
104104
if (server != null && this.environment != null) {
105105
server = this.environment.resolvePlaceholders(server);
106106
}
@@ -116,7 +116,7 @@ private void setupServer(AnnotationMBeanExporter exporter) {
116116
}
117117

118118
private void setupRegistrationPolicy(AnnotationMBeanExporter exporter) {
119-
RegistrationPolicy registrationPolicy = this.attributes.getEnum("registration");
119+
RegistrationPolicy registrationPolicy = this.enableMBeanExport.getEnum("registration");
120120
exporter.setRegistrationPolicy(registrationPolicy);
121121
}
122122

spring-context/src/main/java/org/springframework/scheduling/annotation/AbstractAsyncConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.springframework.context.annotation.ImportAware;
2626
import org.springframework.core.annotation.AnnotationAttributes;
2727
import org.springframework.core.type.AnnotationMetadata;
28-
import org.springframework.util.Assert;
2928
import org.springframework.util.CollectionUtils;
3029

3130
/**
@@ -51,8 +50,10 @@ public abstract class AbstractAsyncConfiguration implements ImportAware {
5150
public void setImportMetadata(AnnotationMetadata importMetadata) {
5251
this.enableAsync = AnnotationAttributes.fromMap(
5352
importMetadata.getAnnotationAttributes(EnableAsync.class.getName(), false));
54-
Assert.notNull(this.enableAsync,
55-
"@EnableAsync is not present on importing class " + importMetadata.getClassName());
53+
if (this.enableAsync == null) {
54+
throw new IllegalArgumentException(
55+
"@EnableAsync is not present on importing class " + importMetadata.getClassName());
56+
}
5657
}
5758

5859
/**

spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,11 @@
114114
* runtime processing overhead.
115115
* </ul>
116116
*
117-
* <p>Note that even if
118-
* {@link org.springframework.jms.connection.JmsTransactionManager} used to
119-
* only provide fully synchronized Spring transactions based
120-
* on local JMS transactions, "sessionTransacted" offers now the same feature and
121-
* is the recommended option when transactions are not managed externally. In
122-
* other words, set the transaction manager only if you are using JTA , or
123-
* synchronizing transactions.
117+
* <p>Note that the "sessionTransacted" flag is strongly recommended over
118+
* {@link org.springframework.jms.connection.JmsTransactionManager}, provided
119+
* that transactions do not need to be managed externally. As a consequence,
120+
* set the transaction manager only if you are using JTA or if you need to
121+
* synchronize with custom external transaction arrangements.
124122
*
125123
* @author Juergen Hoeller
126124
* @author Stephane Nicoll

spring-tx/src/main/java/org/springframework/transaction/annotation/AbstractTransactionManagementConfiguration.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.transaction.PlatformTransactionManager;
3030
import org.springframework.transaction.config.TransactionManagementConfigUtils;
3131
import org.springframework.transaction.event.TransactionalEventListenerFactory;
32-
import org.springframework.util.Assert;
3332
import org.springframework.util.CollectionUtils;
3433

3534
/**
@@ -52,18 +51,14 @@ public abstract class AbstractTransactionManagementConfiguration implements Impo
5251
protected PlatformTransactionManager txManager;
5352

5453

55-
@Bean(name = TransactionManagementConfigUtils.TRANSACTIONAL_EVENT_LISTENER_FACTORY_BEAN_NAME)
56-
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
57-
public TransactionalEventListenerFactory transactionalEventListenerFactory() {
58-
return new TransactionalEventListenerFactory();
59-
}
60-
6154
@Override
6255
public void setImportMetadata(AnnotationMetadata importMetadata) {
6356
this.enableTx = AnnotationAttributes.fromMap(
6457
importMetadata.getAnnotationAttributes(EnableTransactionManagement.class.getName(), false));
65-
Assert.notNull(this.enableTx,
66-
"@EnableTransactionManagement is not present on importing class " + importMetadata.getClassName());
58+
if (this.enableTx == null) {
59+
throw new IllegalArgumentException(
60+
"@EnableTransactionManagement is not present on importing class " + importMetadata.getClassName());
61+
}
6762
}
6863

6964
@Autowired(required = false)
@@ -78,4 +73,11 @@ void setConfigurers(Collection<TransactionManagementConfigurer> configurers) {
7873
this.txManager = configurer.annotationDrivenTransactionManager();
7974
}
8075

76+
77+
@Bean(name = TransactionManagementConfigUtils.TRANSACTIONAL_EVENT_LISTENER_FACTORY_BEAN_NAME)
78+
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
79+
public TransactionalEventListenerFactory transactionalEventListenerFactory() {
80+
return new TransactionalEventListenerFactory();
81+
}
82+
8183
}

spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -42,6 +42,7 @@ public class DelegatingWebMvcConfiguration extends WebMvcConfigurationSupport {
4242

4343
private final WebMvcConfigurerComposite configurers = new WebMvcConfigurerComposite();
4444

45+
4546
@Autowired(required = false)
4647
public void setConfigurers(List<WebMvcConfigurer> configurers) {
4748
if (configurers == null || configurers.isEmpty()) {
@@ -50,6 +51,7 @@ public void setConfigurers(List<WebMvcConfigurer> configurers) {
5051
this.configurers.addWebMvcConfigurers(configurers);
5152
}
5253

54+
5355
@Override
5456
protected void addInterceptors(InterceptorRegistry registry) {
5557
this.configurers.addInterceptors(registry);

0 commit comments

Comments
 (0)