Browse Source

Polishing

pull/1016/head
Juergen Hoeller 10 years ago
parent
commit
9af12d290e
  1. 4
      spring-context/src/main/java/org/springframework/scheduling/annotation/Async.java
  2. 8
      spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java
  3. 2
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationAwareOrderComparator.java
  4. 10
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
  5. 9
      spring-test/src/main/java/org/springframework/test/annotation/Commit.java
  6. 80
      spring-test/src/main/java/org/springframework/test/annotation/DirtiesContext.java
  7. 8
      spring-test/src/main/java/org/springframework/test/annotation/IfProfileValue.java
  8. 11
      spring-test/src/main/java/org/springframework/test/annotation/Repeat.java
  9. 11
      spring-test/src/main/java/org/springframework/test/annotation/Rollback.java
  10. 11
      spring-test/src/main/java/org/springframework/test/annotation/Timed.java
  11. 68
      spring-test/src/main/java/org/springframework/test/context/jdbc/MergedSqlConfig.java
  12. 14
      spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java
  13. 9
      spring-test/src/main/java/org/springframework/test/context/jdbc/SqlConfig.java
  14. 9
      spring-test/src/main/java/org/springframework/test/context/jdbc/SqlGroup.java
  15. 9
      spring-test/src/main/java/org/springframework/test/context/transaction/AfterTransaction.java
  16. 9
      spring-test/src/main/java/org/springframework/test/context/transaction/BeforeTransaction.java
  17. 6
      spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java
  18. 5
      spring-test/src/main/java/org/springframework/test/util/MetaAnnotationUtils.java
  19. 2
      spring-tx/src/main/java/org/springframework/transaction/event/TransactionalEventListenerFactory.java
  20. 40
      spring-web/src/main/java/org/springframework/http/HttpRangeResource.java
  21. 12
      spring-web/src/main/java/org/springframework/web/bind/annotation/DeleteMapping.java
  22. 12
      spring-web/src/main/java/org/springframework/web/bind/annotation/GetMapping.java
  23. 1
      spring-web/src/main/java/org/springframework/web/bind/annotation/ModelAttribute.java
  24. 12
      spring-web/src/main/java/org/springframework/web/bind/annotation/PatchMapping.java
  25. 12
      spring-web/src/main/java/org/springframework/web/bind/annotation/PostMapping.java
  26. 12
      spring-web/src/main/java/org/springframework/web/bind/annotation/PutMapping.java
  27. 14
      spring-web/src/main/java/org/springframework/web/context/annotation/ApplicationScope.java
  28. 14
      spring-web/src/main/java/org/springframework/web/context/annotation/RequestScope.java
  29. 14
      spring-web/src/main/java/org/springframework/web/context/annotation/SessionScope.java
  30. 6
      spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java
  31. 20
      spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java
  32. 7
      spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite.java
  33. 8
      spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -56,7 +56,7 @@ public @interface Async {
* bean definition. * bean definition.
* <p>When specified on a class level {@code @Async} annotation, indicates that the * <p>When specified on a class level {@code @Async} annotation, indicates that the
* given executor should be used for all methods within the class. Method level use * given executor should be used for all methods within the class. Method level use
* of {@link Async#value} always overrides any value set at the class level. * of {@code Async#value} always overrides any value set at the class level.
* @since 3.1.2 * @since 3.1.2
*/ */
String value() default ""; String value() default "";

8
spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -445,8 +445,7 @@ public class GroovyScriptFactoryTests {
assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger)); assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
} }
@Test @Test // SPR-6268
// Test for SPR-6268
public void testRefreshableFromTagProxyTargetClass() throws Exception { public void testRefreshableFromTagProxyTargetClass() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml", ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml",
getClass()); getClass());
@ -464,8 +463,7 @@ public class GroovyScriptFactoryTests {
assertNotNull(AnnotationUtils.findAnnotation(messenger.getClass(), Component.class)); assertNotNull(AnnotationUtils.findAnnotation(messenger.getClass(), Component.class));
} }
@Test @Test // SPR-6268
// Test for SPR-6268
public void testProxyTargetClassNotAllowedIfNotGroovy() throws Exception { public void testProxyTargetClassNotAllowedIfNotGroovy() throws Exception {
try { try {
new ClassPathXmlApplicationContext("jruby-with-xsd-proxy-target-class.xml", getClass()); new ClassPathXmlApplicationContext("jruby-with-xsd-proxy-target-class.xml", getClass());

2
spring-core/src/main/java/org/springframework/core/annotation/AnnotationAwareOrderComparator.java

@ -22,8 +22,8 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.springframework.core.OrderComparator;
import org.springframework.core.DecoratingProxy; import org.springframework.core.DecoratingProxy;
import org.springframework.core.OrderComparator;
/** /**
* {@code AnnotationAwareOrderComparator} is an extension of * {@code AnnotationAwareOrderComparator} is an extension of

10
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

@ -71,11 +71,11 @@ import org.springframework.util.StringUtils;
* <em>meta-present</em> on the other annotation. * <em>meta-present</em> on the other annotation.
* *
* <h3>Meta-annotation Support</h3> * <h3>Meta-annotation Support</h3>
* <p>Most {@code find*()} methods and some {@code get*()} methods in this * <p>Most {@code find*()} methods and some {@code get*()} methods in this class
* class provide support for finding annotations used as meta-annotations. * provide support for finding annotations used as meta-annotations. Consult the
* Consult the Javadoc for each method in this class for details. For support * javadoc for each method in this class for details. For fine-grained support for
* for meta-annotations with <em>attribute overrides</em> in * meta-annotations with <em>attribute overrides</em> in <em>composed annotations</em>,
* <em>composed annotations</em>, use {@link AnnotatedElementUtils} instead. * consider using {@link AnnotatedElementUtils}'s more specific methods instead.
* *
* <h3>Attribute Aliases</h3> * <h3>Attribute Aliases</h3>
* <p>All public methods in this class that return annotations, arrays of * <p>All public methods in this class that return annotations, arrays of

9
spring-test/src/main/java/org/springframework/test/annotation/Commit.java

@ -17,12 +17,11 @@
package org.springframework.test.annotation; package org.springframework.test.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* {@code @Commit} is a test annotation that is used to indicate that a * {@code @Commit} is a test annotation that is used to indicate that a
* <em>test-managed transaction</em> should be <em>committed</em> after * <em>test-managed transaction</em> should be <em>committed</em> after
@ -49,9 +48,9 @@ import static java.lang.annotation.RetentionPolicy.*;
* @see Rollback * @see Rollback
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener * @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
*/ */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Retention(RUNTIME)
@Target({ TYPE, METHOD })
@Rollback(false) @Rollback(false)
public @interface Commit { public @interface Commit {
} }

80
spring-test/src/main/java/org/springframework/test/annotation/DirtiesContext.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -76,19 +76,48 @@ import java.lang.annotation.Target;
* @see org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener * @see org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener
* @see org.springframework.test.context.support.DirtiesContextTestExecutionListener * @see org.springframework.test.context.support.DirtiesContextTestExecutionListener
*/ */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Inherited @Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface DirtiesContext { public @interface DirtiesContext {
/**
* The <i>mode</i> to use when a test method is annotated with
* {@code @DirtiesContext}.
* <p>Defaults to {@link MethodMode#AFTER_METHOD AFTER_METHOD}.
* <p>Setting the method mode on an annotated test class has no meaning.
* For class-level control, use {@link #classMode} instead.
* @since 4.2
*/
MethodMode methodMode() default MethodMode.AFTER_METHOD;
/**
* The <i>mode</i> to use when a test class is annotated with
* {@code @DirtiesContext}.
* <p>Defaults to {@link ClassMode#AFTER_CLASS AFTER_CLASS}.
* <p>Setting the class mode on an annotated test method has no meaning.
* For method-level control, use {@link #methodMode} instead.
* @since 3.0
*/
ClassMode classMode() default ClassMode.AFTER_CLASS;
/**
* The context cache clearing <em>mode</em> to use when a context is
* configured as part of a hierarchy via
* {@link org.springframework.test.context.ContextHierarchy @ContextHierarchy}.
* <p>Defaults to {@link HierarchyMode#EXHAUSTIVE EXHAUSTIVE}.
* @since 3.2.2
*/
HierarchyMode hierarchyMode() default HierarchyMode.EXHAUSTIVE;
/** /**
* Defines <i>modes</i> which determine how {@code @DirtiesContext} is * Defines <i>modes</i> which determine how {@code @DirtiesContext} is
* interpreted when used to annotate a test method. * interpreted when used to annotate a test method.
*
* @since 4.2 * @since 4.2
*/ */
static enum MethodMode { enum MethodMode {
/** /**
* The associated {@code ApplicationContext} will be marked as * The associated {@code ApplicationContext} will be marked as
@ -103,13 +132,13 @@ public @interface DirtiesContext {
AFTER_METHOD; AFTER_METHOD;
} }
/** /**
* Defines <i>modes</i> which determine how {@code @DirtiesContext} is * Defines <i>modes</i> which determine how {@code @DirtiesContext} is
* interpreted when used to annotate a test class. * interpreted when used to annotate a test class.
*
* @since 3.0 * @since 3.0
*/ */
static enum ClassMode { enum ClassMode {
/** /**
* The associated {@code ApplicationContext} will be marked as * The associated {@code ApplicationContext} will be marked as
@ -140,15 +169,15 @@ public @interface DirtiesContext {
AFTER_CLASS; AFTER_CLASS;
} }
/** /**
* Defines <i>modes</i> which determine how the context cache is cleared * Defines <i>modes</i> which determine how the context cache is cleared
* when {@code @DirtiesContext} is used in a test whose context is * when {@code @DirtiesContext} is used in a test whose context is
* configured as part of a hierarchy via * configured as part of a hierarchy via
* {@link org.springframework.test.context.ContextHierarchy @ContextHierarchy}. * {@link org.springframework.test.context.ContextHierarchy @ContextHierarchy}.
*
* @since 3.2.2 * @since 3.2.2
*/ */
static enum HierarchyMode { enum HierarchyMode {
/** /**
* The context cache will be cleared using an <em>exhaustive</em> algorithm * The context cache will be cleared using an <em>exhaustive</em> algorithm
@ -174,37 +203,4 @@ public @interface DirtiesContext {
CURRENT_LEVEL; CURRENT_LEVEL;
} }
/**
* The <i>mode</i> to use when a test method is annotated with
* {@code @DirtiesContext}.
* <p>Defaults to {@link MethodMode#AFTER_METHOD AFTER_METHOD}.
* <p>Setting the method mode on an annotated test class has no meaning.
* For class-level control, use {@link #classMode} instead.
*
* @since 4.2
*/
MethodMode methodMode() default MethodMode.AFTER_METHOD;
/**
* The <i>mode</i> to use when a test class is annotated with
* {@code @DirtiesContext}.
* <p>Defaults to {@link ClassMode#AFTER_CLASS AFTER_CLASS}.
* <p>Setting the class mode on an annotated test method has no meaning.
* For method-level control, use {@link #methodMode} instead.
*
* @since 3.0
*/
ClassMode classMode() default ClassMode.AFTER_CLASS;
/**
* The context cache clearing <em>mode</em> to use when a context is
* configured as part of a hierarchy via
* {@link org.springframework.test.context.ContextHierarchy @ContextHierarchy}.
* <p>Defaults to {@link HierarchyMode#EXHAUSTIVE EXHAUSTIVE}.
*
* @since 3.2.2
*/
HierarchyMode hierarchyMode() default HierarchyMode.EXHAUSTIVE;
} }

8
spring-test/src/main/java/org/springframework/test/annotation/IfProfileValue.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -95,10 +95,10 @@ import java.lang.annotation.Target;
* @see org.springframework.context.annotation.Profile * @see org.springframework.context.annotation.Profile
* @see org.springframework.test.context.ActiveProfiles * @see org.springframework.test.context.ActiveProfiles
*/ */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Inherited @Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface IfProfileValue { public @interface IfProfileValue {
/** /**
@ -109,7 +109,6 @@ public @interface IfProfileValue {
/** /**
* A single, permissible {@code value} of the <em>profile value</em> * A single, permissible {@code value} of the <em>profile value</em>
* for the given {@link #name}. * for the given {@link #name}.
*
* <p>Note: Assigning values to both {@link #value} and {@link #values} * <p>Note: Assigning values to both {@link #value} and {@link #values}
* will lead to a configuration conflict. * will lead to a configuration conflict.
*/ */
@ -118,7 +117,6 @@ public @interface IfProfileValue {
/** /**
* A list of all permissible {@code values} of the <em>profile value</em> * A list of all permissible {@code values} of the <em>profile value</em>
* for the given {@link #name}. * for the given {@link #name}.
*
* <p>Note: Assigning values to both {@link #value} and {@link #values} * <p>Note: Assigning values to both {@link #value} and {@link #values}
* will lead to a configuration conflict. * will lead to a configuration conflict.
*/ */

11
spring-test/src/main/java/org/springframework/test/annotation/Repeat.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,12 +17,11 @@
package org.springframework.test.annotation; package org.springframework.test.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* Test annotation to indicate that a test method should be invoked repeatedly. * Test annotation to indicate that a test method should be invoked repeatedly.
* *
@ -41,9 +40,9 @@ import static java.lang.annotation.RetentionPolicy.*;
* @see org.springframework.test.context.junit4.rules.SpringMethodRule * @see org.springframework.test.context.junit4.rules.SpringMethodRule
* @see org.springframework.test.context.junit4.statements.SpringRepeat * @see org.springframework.test.context.junit4.statements.SpringRepeat
*/ */
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Retention(RUNTIME)
@Target({ METHOD, ANNOTATION_TYPE })
public @interface Repeat { public @interface Repeat {
/** /**

11
spring-test/src/main/java/org/springframework/test/annotation/Rollback.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,12 +17,11 @@
package org.springframework.test.annotation; package org.springframework.test.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* {@code @Rollback} is a test annotation that is used to indicate whether * {@code @Rollback} is a test annotation that is used to indicate whether
* a <em>test-managed transaction</em> should be <em>rolled back</em> after * a <em>test-managed transaction</em> should be <em>rolled back</em> after
@ -54,9 +53,9 @@ import static java.lang.annotation.RetentionPolicy.*;
* @see Commit * @see Commit
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener * @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
*/ */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Retention(RUNTIME)
@Target({ TYPE, METHOD })
public @interface Rollback { public @interface Rollback {
/** /**

11
spring-test/src/main/java/org/springframework/test/annotation/Timed.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,12 +17,11 @@
package org.springframework.test.annotation; package org.springframework.test.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* Test-specific annotation to indicate that a test method has to finish * Test-specific annotation to indicate that a test method has to finish
* execution in a {@linkplain #millis() specified time period}. * execution in a {@linkplain #millis() specified time period}.
@ -45,9 +44,9 @@ import static java.lang.annotation.RetentionPolicy.*;
* @see org.springframework.test.context.junit4.rules.SpringMethodRule * @see org.springframework.test.context.junit4.rules.SpringMethodRule
* @see org.springframework.test.context.junit4.statements.SpringFailOnTimeout * @see org.springframework.test.context.junit4.statements.SpringFailOnTimeout
*/ */
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Retention(RUNTIME)
@Target({ METHOD, ANNOTATION_TYPE })
public @interface Timed { public @interface Timed {
/** /**

68
spring-test/src/main/java/org/springframework/test/context/jdbc/MergedSqlConfig.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,8 +27,8 @@ import org.springframework.util.Assert;
/** /**
* {@code MergedSqlConfig} encapsulates the <em>merged</em> {@link SqlConfig @SqlConfig} * {@code MergedSqlConfig} encapsulates the <em>merged</em> {@link SqlConfig @SqlConfig}
* attributes declared locally via {@link Sql#config} and globally as a * attributes declared locally via {@link Sql#config} and globally as a class-level annotation.
* class-level annotation. *
* <p>Explicit local configuration attributes override global configuration attributes. * <p>Explicit local configuration attributes override global configuration attributes.
* *
* @author Sam Brannen * @author Sam Brannen
@ -56,23 +56,6 @@ class MergedSqlConfig {
private final ErrorMode errorMode; private final ErrorMode errorMode;
private static <E extends Enum<?>> E getEnum(AnnotationAttributes attributes, String attributeName,
E inheritedOrDefaultValue, E defaultValue) {
E value = attributes.getEnum(attributeName);
if (value == inheritedOrDefaultValue) {
value = defaultValue;
}
return value;
}
private static String getString(AnnotationAttributes attributes, String attributeName, String defaultValue) {
String value = attributes.getString(attributeName);
if ("".equals(value)) {
value = defaultValue;
}
return value;
}
/** /**
* Construct a {@code MergedSqlConfig} instance by merging the configuration * Construct a {@code MergedSqlConfig} instance by merging the configuration
* from the supplied local (potentially method-level) {@code @SqlConfig} annotation * from the supplied local (potentially method-level) {@code @SqlConfig} annotation
@ -86,8 +69,8 @@ class MergedSqlConfig {
Assert.notNull(testClass, "testClass must not be null"); Assert.notNull(testClass, "testClass must not be null");
// Get global attributes, if any. // Get global attributes, if any.
AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(testClass, AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(
SqlConfig.class.getName(), false, false); testClass, SqlConfig.class.getName(), false, false);
// Override global attributes with local attributes. // Override global attributes with local attributes.
if (attributes != null) { if (attributes != null) {
@ -95,7 +78,7 @@ class MergedSqlConfig {
Object value = AnnotationUtils.getValue(localSqlConfig, key); Object value = AnnotationUtils.getValue(localSqlConfig, key);
if (value != null) { if (value != null) {
// Is the value explicit (i.e., not a 'default')? // Is the value explicit (i.e., not a 'default')?
if (!value.equals("") && (value != TransactionMode.DEFAULT) && (value != ErrorMode.DEFAULT)) { if (!value.equals("") && value != TransactionMode.DEFAULT && value != ErrorMode.DEFAULT) {
attributes.put(key, value); attributes.put(key, value);
} }
} }
@ -187,17 +170,36 @@ class MergedSqlConfig {
*/ */
@Override @Override
public String toString() { public String toString() {
return new ToStringCreator(this)// return new ToStringCreator(this)
.append("dataSource", dataSource)// .append("dataSource", this.dataSource)
.append("transactionManager", transactionManager)// .append("transactionManager", this.transactionManager)
.append("transactionMode", transactionMode)// .append("transactionMode", this.transactionMode)
.append("encoding", encoding)// .append("encoding", this.encoding)
.append("separator", separator)// .append("separator", this.separator)
.append("commentPrefix", commentPrefix)// .append("commentPrefix", this.commentPrefix)
.append("blockCommentStartDelimiter", blockCommentStartDelimiter)// .append("blockCommentStartDelimiter", this.blockCommentStartDelimiter)
.append("blockCommentEndDelimiter", blockCommentEndDelimiter)// .append("blockCommentEndDelimiter", this.blockCommentEndDelimiter)
.append("errorMode", errorMode)// .append("errorMode", this.errorMode)
.toString(); .toString();
} }
private static <E extends Enum<?>> E getEnum(AnnotationAttributes attributes, String attributeName,
E inheritedOrDefaultValue, E defaultValue) {
E value = attributes.getEnum(attributeName);
if (value == inheritedOrDefaultValue) {
value = defaultValue;
}
return value;
}
private static String getString(AnnotationAttributes attributes, String attributeName, String defaultValue) {
String value = attributes.getString(attributeName);
if ("".equals(value)) {
value = defaultValue;
}
return value;
}
} }

14
spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java

@ -17,16 +17,15 @@
package org.springframework.test.context.jdbc; package org.springframework.test.context.jdbc;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited; import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable; import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* {@code @Sql} is used to annotate a test class or test method to configure * {@code @Sql} is used to annotate a test class or test method to configure
* SQL {@link #scripts} and {@link #statements} to be executed against a given * SQL {@link #scripts} and {@link #statements} to be executed against a given
@ -65,10 +64,10 @@ import static java.lang.annotation.RetentionPolicy.*;
* @see org.springframework.jdbc.datasource.init.ResourceDatabasePopulator * @see org.springframework.jdbc.datasource.init.ResourceDatabasePopulator
* @see org.springframework.jdbc.datasource.init.ScriptUtils * @see org.springframework.jdbc.datasource.init.ScriptUtils
*/ */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Inherited @Inherited
@Retention(RUNTIME)
@Target({TYPE, METHOD})
@Repeatable(SqlGroup.class) @Repeatable(SqlGroup.class)
public @interface Sql { public @interface Sql {
@ -88,7 +87,6 @@ public @interface Sql {
* {@link #value}, but it may be used instead of {@link #value}. Similarly, * {@link #value}, but it may be used instead of {@link #value}. Similarly,
* this attribute may be used in conjunction with or instead of * this attribute may be used in conjunction with or instead of
* {@link #statements}. * {@link #statements}.
*
* <h3>Path Resource Semantics</h3> * <h3>Path Resource Semantics</h3>
* <p>Each path will be interpreted as a Spring * <p>Each path will be interpreted as a Spring
* {@link org.springframework.core.io.Resource Resource}. A plain path * {@link org.springframework.core.io.Resource Resource}. A plain path
@ -101,7 +99,6 @@ public @interface Sql {
* {@link org.springframework.util.ResourceUtils#CLASSPATH_URL_PREFIX classpath:}, * {@link org.springframework.util.ResourceUtils#CLASSPATH_URL_PREFIX classpath:},
* {@link org.springframework.util.ResourceUtils#FILE_URL_PREFIX file:}, * {@link org.springframework.util.ResourceUtils#FILE_URL_PREFIX file:},
* {@code http:}, etc.) will be loaded using the specified resource protocol. * {@code http:}, etc.) will be loaded using the specified resource protocol.
*
* <h3>Default Script Detection</h3> * <h3>Default Script Detection</h3>
* <p>If no SQL scripts or {@link #statements} are specified, an attempt will * <p>If no SQL scripts or {@link #statements} are specified, an attempt will
* be made to detect a <em>default</em> script depending on where this * be made to detect a <em>default</em> script depending on where this
@ -116,7 +113,6 @@ public @interface Sql {
* {@code com.example.MyTest}, the corresponding default script is * {@code com.example.MyTest}, the corresponding default script is
* {@code "classpath:com/example/MyTest.testMethod.sql"}.</li> * {@code "classpath:com/example/MyTest.testMethod.sql"}.</li>
* </ul> * </ul>
*
* @see #value * @see #value
* @see #statements * @see #statements
*/ */
@ -127,13 +123,11 @@ public @interface Sql {
* <em>Inlined SQL statements</em> to execute. * <em>Inlined SQL statements</em> to execute.
* <p>This attribute may be used in conjunction with or instead of * <p>This attribute may be used in conjunction with or instead of
* {@link #scripts}. * {@link #scripts}.
*
* <h3>Ordering</h3> * <h3>Ordering</h3>
* <p>Statements declared via this attribute will be executed after * <p>Statements declared via this attribute will be executed after
* statements loaded from resource {@link #scripts}. If you wish to have * statements loaded from resource {@link #scripts}. If you wish to have
* inlined statements executed before scripts, simply declare multiple * inlined statements executed before scripts, simply declare multiple
* instances of {@code @Sql} on the same class or method. * instances of {@code @Sql} on the same class or method.
*
* @since 4.2 * @since 4.2
* @see #scripts * @see #scripts
*/ */

9
spring-test/src/main/java/org/springframework/test/context/jdbc/SqlConfig.java

@ -17,13 +17,12 @@
package org.springframework.test.context.jdbc; package org.springframework.test.context.jdbc;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited; import java.lang.annotation.Inherited;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* {@code @SqlConfig} defines metadata that is used to determine how to parse * {@code @SqlConfig} defines metadata that is used to determine how to parse
* and execute SQL scripts configured via the {@link Sql @Sql} annotation. * and execute SQL scripts configured via the {@link Sql @Sql} annotation.
@ -59,10 +58,10 @@ import static java.lang.annotation.RetentionPolicy.*;
* @since 4.1 * @since 4.1
* @see Sql * @see Sql
*/ */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Inherited @Inherited
@Retention(RUNTIME)
@Target(TYPE)
public @interface SqlConfig { public @interface SqlConfig {
/** /**

9
spring-test/src/main/java/org/springframework/test/context/jdbc/SqlGroup.java

@ -17,13 +17,12 @@
package org.springframework.test.context.jdbc; package org.springframework.test.context.jdbc;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited; import java.lang.annotation.Inherited;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* Container annotation that aggregates several {@link Sql @Sql} annotations. * Container annotation that aggregates several {@link Sql @Sql} annotations.
* *
@ -39,10 +38,10 @@ import static java.lang.annotation.RetentionPolicy.*;
* @since 4.1 * @since 4.1
* @see Sql * @see Sql
*/ */
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Inherited @Inherited
@Retention(RUNTIME)
@Target({TYPE, METHOD})
public @interface SqlGroup { public @interface SqlGroup {
Sql[] value(); Sql[] value();

9
spring-test/src/main/java/org/springframework/test/context/transaction/AfterTransaction.java

@ -17,12 +17,11 @@
package org.springframework.test.context.transaction; package org.springframework.test.context.transaction;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* <p>Test annotation to indicate that the annotated {@code void} method * <p>Test annotation to indicate that the annotated {@code void} method
* should be executed <em>after</em> a transaction is ended for a test method * should be executed <em>after</em> a transaction is ended for a test method
@ -39,8 +38,8 @@ import static java.lang.annotation.RetentionPolicy.*;
* @see org.springframework.transaction.annotation.Transactional * @see org.springframework.transaction.annotation.Transactional
* @see BeforeTransaction * @see BeforeTransaction
*/ */
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Retention(RUNTIME)
@Target({ METHOD, ANNOTATION_TYPE })
public @interface AfterTransaction { public @interface AfterTransaction {
} }

9
spring-test/src/main/java/org/springframework/test/context/transaction/BeforeTransaction.java

@ -17,12 +17,11 @@
package org.springframework.test.context.transaction; package org.springframework.test.context.transaction;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/** /**
* <p>Test annotation to indicate that the annotated {@code void} method * <p>Test annotation to indicate that the annotated {@code void} method
* should be executed <em>before</em> a transaction is started for a test method * should be executed <em>before</em> a transaction is started for a test method
@ -39,8 +38,8 @@ import static java.lang.annotation.RetentionPolicy.*;
* @see org.springframework.transaction.annotation.Transactional * @see org.springframework.transaction.annotation.Transactional
* @see AfterTransaction * @see AfterTransaction
*/ */
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Retention(RUNTIME)
@Target({ METHOD, ANNOTATION_TYPE })
public @interface BeforeTransaction { public @interface BeforeTransaction {
} }

6
spring-test/src/main/java/org/springframework/test/context/web/WebAppConfiguration.java

@ -47,19 +47,17 @@ import java.lang.annotation.Target;
* @see org.springframework.test.context.ContextConfiguration * @see org.springframework.test.context.ContextConfiguration
* @see ServletTestExecutionListener * @see ServletTestExecutionListener
*/ */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Inherited @Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface WebAppConfiguration { public @interface WebAppConfiguration {
/** /**
* The resource path to the root directory of the web application. * The resource path to the root directory of the web application.
*
* <p>A path that does not include a Spring resource prefix (e.g., {@code classpath:}, * <p>A path that does not include a Spring resource prefix (e.g., {@code classpath:},
* {@code file:}, etc.) will be interpreted as a file system resource, and a * {@code file:}, etc.) will be interpreted as a file system resource, and a
* path should not end with a slash. * path should not end with a slash.
*
* <p>Defaults to {@code "src/main/webapp"} as a file system resource. Note * <p>Defaults to {@code "src/main/webapp"} as a file system resource. Note
* that this is the standard directory for the root of a web application in * that this is the standard directory for the root of a web application in
* a project that follows the standard Maven project layout for a WAR. * a project that follows the standard Maven project layout for a WAR.

5
spring-test/src/main/java/org/springframework/test/util/MetaAnnotationUtils.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -274,13 +274,13 @@ public abstract class MetaAnnotationUtils {
private final AnnotationAttributes annotationAttributes; private final AnnotationAttributes annotationAttributes;
public AnnotationDescriptor(Class<?> rootDeclaringClass, T annotation) { public AnnotationDescriptor(Class<?> rootDeclaringClass, T annotation) {
this(rootDeclaringClass, rootDeclaringClass, null, annotation); this(rootDeclaringClass, rootDeclaringClass, null, annotation);
} }
public AnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass, public AnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass,
Annotation composedAnnotation, T annotation) { Annotation composedAnnotation, T annotation) {
Assert.notNull(rootDeclaringClass, "rootDeclaringClass must not be null"); Assert.notNull(rootDeclaringClass, "rootDeclaringClass must not be null");
Assert.notNull(annotation, "annotation must not be null"); Assert.notNull(annotation, "annotation must not be null");
this.rootDeclaringClass = rootDeclaringClass; this.rootDeclaringClass = rootDeclaringClass;
@ -362,6 +362,7 @@ public abstract class MetaAnnotationUtils {
public UntypedAnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass, public UntypedAnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass,
Annotation composedAnnotation, Annotation annotation) { Annotation composedAnnotation, Annotation annotation) {
super(rootDeclaringClass, declaringClass, composedAnnotation, annotation); super(rootDeclaringClass, declaringClass, composedAnnotation, annotation);
} }

2
spring-tx/src/main/java/org/springframework/transaction/event/TransactionalEventListenerFactory.java

@ -41,7 +41,7 @@ public class TransactionalEventListenerFactory implements EventListenerFactory,
@Override @Override
public int getOrder() { public int getOrder() {
return order; return this.order;
} }

40
spring-web/src/main/java/org/springframework/http/HttpRangeResource.java

@ -27,15 +27,15 @@ import org.springframework.core.io.Resource;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* Holder that combines a {@link Resource} descriptor with * Holder that combines a {@link Resource} descriptor with {@link HttpRange}
* {@link HttpRange} information to be used for reading * information to be used for reading selected parts of the resource.
* selected parts of the resource.
* *
* <p>Used as an argument for partial conversion operations in * <p>Used as an argument for partial conversion operations in
* {@link org.springframework.http.converter.ResourceHttpMessageConverter}. * {@link org.springframework.http.converter.ResourceHttpMessageConverter}.
* *
* @author Brian Clozel * @author Brian Clozel
* @since 4.3.0 * @since 4.3
* @see HttpRange
*/ */
public class HttpRangeResource implements Resource { public class HttpRangeResource implements Resource {
@ -43,77 +43,81 @@ public class HttpRangeResource implements Resource {
private final Resource resource; private final Resource resource;
public HttpRangeResource(List<HttpRange> httpRanges, Resource resource) { public HttpRangeResource(List<HttpRange> httpRanges, Resource resource) {
Assert.notEmpty(httpRanges, "list of HTTP Ranges should not be empty"); Assert.notEmpty(httpRanges, "List of HTTP Ranges should not be empty");
this.httpRanges = httpRanges; this.httpRanges = httpRanges;
this.resource = resource; this.resource = resource;
} }
/** /**
* Return the list of HTTP (byte) ranges describing the requested * Return the list of HTTP (byte) ranges describing the requested
* parts of the Resource, as provided by the HTTP Range request. * parts of the Resource, as provided by the HTTP Range request.
*/ */
public final List<HttpRange> getHttpRanges() { public final List<HttpRange> getHttpRanges() {
return httpRanges; return this.httpRanges;
} }
@Override @Override
public boolean exists() { public boolean exists() {
return resource.exists(); return this.resource.exists();
} }
@Override @Override
public boolean isReadable() { public boolean isReadable() {
return resource.isReadable(); return this.resource.isReadable();
} }
@Override @Override
public boolean isOpen() { public boolean isOpen() {
return resource.isOpen(); return this.resource.isOpen();
} }
@Override @Override
public URL getURL() throws IOException { public URL getURL() throws IOException {
return resource.getURL(); return this.resource.getURL();
} }
@Override @Override
public URI getURI() throws IOException { public URI getURI() throws IOException {
return resource.getURI(); return this.resource.getURI();
} }
@Override @Override
public File getFile() throws IOException { public File getFile() throws IOException {
return resource.getFile(); return this.resource.getFile();
} }
@Override @Override
public long contentLength() throws IOException { public long contentLength() throws IOException {
return resource.contentLength(); return this.resource.contentLength();
} }
@Override @Override
public long lastModified() throws IOException { public long lastModified() throws IOException {
return resource.lastModified(); return this.resource.lastModified();
} }
@Override @Override
public Resource createRelative(String relativePath) throws IOException { public Resource createRelative(String relativePath) throws IOException {
return resource.createRelative(relativePath); return this.resource.createRelative(relativePath);
} }
@Override @Override
public String getFilename() { public String getFilename() {
return resource.getFilename(); return this.resource.getFilename();
} }
@Override @Override
public String getDescription() { public String getDescription() {
return resource.getDescription(); return this.resource.getDescription();
} }
@Override @Override
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {
return resource.getInputStream(); return this.resource.getInputStream();
} }
} }

12
spring-web/src/main/java/org/springframework/web/bind/annotation/DeleteMapping.java

@ -17,15 +17,13 @@
package org.springframework.web.bind.annotation; package org.springframework.web.bind.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.web.bind.annotation.RequestMethod.DELETE;
/** /**
* Annotation for mapping HTTP {@code DELETE} requests onto specific handler * Annotation for mapping HTTP {@code DELETE} requests onto specific handler
* methods. * methods.
@ -41,10 +39,10 @@ import static org.springframework.web.bind.annotation.RequestMethod.DELETE;
* @see PatchMapping * @see PatchMapping
* @see RequestMapping * @see RequestMapping
*/ */
@Target(METHOD) @Target(ElementType.METHOD)
@Retention(RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@RequestMapping(method = DELETE) @RequestMapping(method = RequestMethod.DELETE)
public @interface DeleteMapping { public @interface DeleteMapping {
/** /**

12
spring-web/src/main/java/org/springframework/web/bind/annotation/GetMapping.java

@ -17,15 +17,13 @@
package org.springframework.web.bind.annotation; package org.springframework.web.bind.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
/** /**
* Annotation for mapping HTTP {@code GET} requests onto specific handler * Annotation for mapping HTTP {@code GET} requests onto specific handler
* methods. * methods.
@ -45,10 +43,10 @@ import static org.springframework.web.bind.annotation.RequestMethod.GET;
* @see PatchMapping * @see PatchMapping
* @see RequestMapping * @see RequestMapping
*/ */
@Target(METHOD) @Target(ElementType.METHOD)
@Retention(RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@RequestMapping(method = GET) @RequestMapping(method = RequestMethod.GET)
public @interface GetMapping { public @interface GetMapping {
/** /**

1
spring-web/src/main/java/org/springframework/web/bind/annotation/ModelAttribute.java

@ -83,6 +83,7 @@ public @interface ModelAttribute {
* binding for that attribute. * binding for that attribute.
* <p>By default this is set to "true" in which case data binding applies. * <p>By default this is set to "true" in which case data binding applies.
* Set this to "false" to disable data binding. * Set this to "false" to disable data binding.
* @since 4.3
*/ */
boolean binding() default true; boolean binding() default true;

12
spring-web/src/main/java/org/springframework/web/bind/annotation/PatchMapping.java

@ -17,15 +17,13 @@
package org.springframework.web.bind.annotation; package org.springframework.web.bind.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.web.bind.annotation.RequestMethod.PATCH;
/** /**
* Annotation for mapping HTTP {@code PATCH} requests onto specific handler * Annotation for mapping HTTP {@code PATCH} requests onto specific handler
* methods. * methods.
@ -41,10 +39,10 @@ import static org.springframework.web.bind.annotation.RequestMethod.PATCH;
* @see DeleteMapping * @see DeleteMapping
* @see RequestMapping * @see RequestMapping
*/ */
@Target(METHOD) @Target(ElementType.METHOD)
@Retention(RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@RequestMapping(method = PATCH) @RequestMapping(method = RequestMethod.PATCH)
public @interface PatchMapping { public @interface PatchMapping {
/** /**

12
spring-web/src/main/java/org/springframework/web/bind/annotation/PostMapping.java

@ -17,15 +17,13 @@
package org.springframework.web.bind.annotation; package org.springframework.web.bind.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
/** /**
* Annotation for mapping HTTP {@code POST} requests onto specific handler * Annotation for mapping HTTP {@code POST} requests onto specific handler
* methods. * methods.
@ -41,10 +39,10 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST;
* @see PatchMapping * @see PatchMapping
* @see RequestMapping * @see RequestMapping
*/ */
@Target(METHOD) @Target(ElementType.METHOD)
@Retention(RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@RequestMapping(method = POST) @RequestMapping(method = RequestMethod.POST)
public @interface PostMapping { public @interface PostMapping {
/** /**

12
spring-web/src/main/java/org/springframework/web/bind/annotation/PutMapping.java

@ -17,15 +17,13 @@
package org.springframework.web.bind.annotation; package org.springframework.web.bind.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.web.bind.annotation.RequestMethod.PUT;
/** /**
* Annotation for mapping HTTP {@code PUT} requests onto specific handler * Annotation for mapping HTTP {@code PUT} requests onto specific handler
* methods. * methods.
@ -41,10 +39,10 @@ import static org.springframework.web.bind.annotation.RequestMethod.PUT;
* @see PatchMapping * @see PatchMapping
* @see RequestMapping * @see RequestMapping
*/ */
@Target(METHOD) @Target(ElementType.METHOD)
@Retention(RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@RequestMapping(method = PUT) @RequestMapping(method = RequestMethod.PUT)
public @interface PutMapping { public @interface PutMapping {
/** /**

14
spring-web/src/main/java/org/springframework/web/context/annotation/ApplicationScope.java

@ -17,17 +17,15 @@
package org.springframework.web.context.annotation; package org.springframework.web.context.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.web.context.WebApplicationContext;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.web.context.WebApplicationContext.SCOPE_APPLICATION;
/** /**
* {@code @ApplicationScope} is a specialization of {@link Scope @Scope} for a * {@code @ApplicationScope} is a specialization of {@link Scope @Scope} for a
@ -50,10 +48,10 @@ import static org.springframework.web.context.WebApplicationContext.SCOPE_APPLIC
* @see org.springframework.stereotype.Component * @see org.springframework.stereotype.Component
* @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Bean
*/ */
@Scope(SCOPE_APPLICATION) @Target({ElementType.TYPE, ElementType.METHOD})
@Target({ TYPE, METHOD }) @Retention(RetentionPolicy.RUNTIME)
@Retention(RUNTIME)
@Documented @Documented
@Scope(WebApplicationContext.SCOPE_APPLICATION)
public @interface ApplicationScope { public @interface ApplicationScope {
/** /**

14
spring-web/src/main/java/org/springframework/web/context/annotation/RequestScope.java

@ -17,17 +17,15 @@
package org.springframework.web.context.annotation; package org.springframework.web.context.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.web.context.WebApplicationContext;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.web.context.WebApplicationContext.SCOPE_REQUEST;
/** /**
* {@code @RequestScope} is a specialization of {@link Scope @Scope} for a * {@code @RequestScope} is a specialization of {@link Scope @Scope} for a
@ -50,10 +48,10 @@ import static org.springframework.web.context.WebApplicationContext.SCOPE_REQUES
* @see org.springframework.stereotype.Component * @see org.springframework.stereotype.Component
* @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Bean
*/ */
@Scope(SCOPE_REQUEST) @Target({ElementType.TYPE, ElementType.METHOD})
@Target({ TYPE, METHOD }) @Retention(RetentionPolicy.RUNTIME)
@Retention(RUNTIME)
@Documented @Documented
@Scope(WebApplicationContext.SCOPE_REQUEST)
public @interface RequestScope { public @interface RequestScope {
/** /**

14
spring-web/src/main/java/org/springframework/web/context/annotation/SessionScope.java

@ -17,17 +17,15 @@
package org.springframework.web.context.annotation; package org.springframework.web.context.annotation;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
import org.springframework.web.context.WebApplicationContext;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.springframework.web.context.WebApplicationContext.SCOPE_SESSION;
/** /**
* {@code @SessionScope} is a specialization of {@link Scope @Scope} for a * {@code @SessionScope} is a specialization of {@link Scope @Scope} for a
@ -50,10 +48,10 @@ import static org.springframework.web.context.WebApplicationContext.SCOPE_SESSIO
* @see org.springframework.stereotype.Component * @see org.springframework.stereotype.Component
* @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Bean
*/ */
@Scope(SCOPE_SESSION) @Target({ElementType.TYPE, ElementType.METHOD})
@Target({ TYPE, METHOD }) @Retention(RetentionPolicy.RUNTIME)
@Retention(RUNTIME)
@Documented @Documented
@Scope(WebApplicationContext.SCOPE_SESSION)
public @interface SessionScope { public @interface SessionScope {
/** /**

6
spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -103,8 +103,8 @@ public class ControllerAdviceBean implements Ordered {
this.order = initOrderFromBean(bean); this.order = initOrderFromBean(bean);
} }
ControllerAdvice annotation = AnnotatedElementUtils.findMergedAnnotation( ControllerAdvice annotation =
beanType, ControllerAdvice.class); AnnotatedElementUtils.findMergedAnnotation(beanType, ControllerAdvice.class);
if (annotation != null) { if (annotation != null) {
this.basePackages = initBasePackages(annotation); this.basePackages = initBasePackages(annotation);

20
spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java

@ -132,10 +132,10 @@ public final class ModelFactory {
while (!this.modelMethods.isEmpty()) { while (!this.modelMethods.isEmpty()) {
InvocableHandlerMethod modelMethod = getNextModelMethod(container).getHandlerMethod(); InvocableHandlerMethod modelMethod = getNextModelMethod(container).getHandlerMethod();
ModelAttribute annotation = modelMethod.getMethodAnnotation(ModelAttribute.class); ModelAttribute ann = modelMethod.getMethodAnnotation(ModelAttribute.class);
if (container.containsAttribute(annotation.name())) { if (container.containsAttribute(ann.name())) {
if (!annotation.binding()) { if (!ann.binding()) {
container.setBindingDisabled(annotation.name()); container.setBindingDisabled(ann.name());
} }
continue; continue;
} }
@ -144,7 +144,7 @@ public final class ModelFactory {
if (!modelMethod.isVoid()){ if (!modelMethod.isVoid()){
String returnValueName = getNameForReturnValue(returnValue, modelMethod.getReturnType()); String returnValueName = getNameForReturnValue(returnValue, modelMethod.getReturnType());
if (!annotation.binding()) { if (!ann.binding()) {
container.setBindingDisabled(returnValueName); container.setBindingDisabled(returnValueName);
} }
if (!container.containsAttribute(returnValueName)) { if (!container.containsAttribute(returnValueName)) {
@ -199,8 +199,8 @@ public final class ModelFactory {
* @return the derived name; never {@code null} or an empty string * @return the derived name; never {@code null} or an empty string
*/ */
public static String getNameForParameter(MethodParameter parameter) { public static String getNameForParameter(MethodParameter parameter) {
ModelAttribute annot = parameter.getParameterAnnotation(ModelAttribute.class); ModelAttribute ann = parameter.getParameterAnnotation(ModelAttribute.class);
String name = (annot != null) ? annot.value() : null; String name = (ann != null ? ann.value() : null);
return StringUtils.hasText(name) ? name : Conventions.getVariableNameForParameter(parameter); return StringUtils.hasText(name) ? name : Conventions.getVariableNameForParameter(parameter);
} }
@ -216,9 +216,9 @@ public final class ModelFactory {
* @return the model name, never {@code null} nor empty * @return the model name, never {@code null} nor empty
*/ */
public static String getNameForReturnValue(Object returnValue, MethodParameter returnType) { public static String getNameForReturnValue(Object returnValue, MethodParameter returnType) {
ModelAttribute annotation = returnType.getMethodAnnotation(ModelAttribute.class); ModelAttribute ann = returnType.getMethodAnnotation(ModelAttribute.class);
if (annotation != null && StringUtils.hasText(annotation.value())) { if (ann != null && StringUtils.hasText(ann.value())) {
return annotation.value(); return ann.value();
} }
else { else {
Method method = returnType.getMethod(); Method method = returnType.getMethod();

7
spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.util.Assert;
import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.NativeWebRequest;
/** /**
@ -76,7 +75,9 @@ public class HandlerMethodReturnValueHandlerComposite implements AsyncHandlerMet
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception { ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
HandlerMethodReturnValueHandler handler = selectHandler(returnValue, returnType); HandlerMethodReturnValueHandler handler = selectHandler(returnValue, returnType);
Assert.notNull(handler, "Unknown return value type [" + returnType.getParameterType().getName() + "]"); if (handler == null) {
throw new IllegalArgumentException("Unknown return value type: " + returnType.getParameterType().getName());
}
handler.handleReturnValue(returnValue, returnType, mavContainer, webRequest); handler.handleReturnValue(returnValue, returnType, mavContainer, webRequest);
} }

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -77,9 +77,9 @@ public class SpringConfigurator extends Configurator {
return endpoint; return endpoint;
} }
Component annot = AnnotationUtils.findAnnotation(endpointClass, Component.class); Component ann = AnnotationUtils.findAnnotation(endpointClass, Component.class);
if ((annot != null) && wac.containsBean(annot.value())) { if (ann != null && wac.containsBean(ann.value())) {
T endpoint = wac.getBean(annot.value(), endpointClass); T endpoint = wac.getBean(ann.value(), endpointClass);
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
logger.trace("Using @ServerEndpoint singleton " + endpoint); logger.trace("Using @ServerEndpoint singleton " + endpoint);
} }

Loading…
Cancel
Save