diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java index 82b0a31c3b..7d78a51b1b 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilder.java @@ -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. @@ -24,7 +24,7 @@ import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; * A builder that provides a convenient API for constructing an embedded database. * *
Usage example: - *
+ *
* EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
* EmbeddedDatabase db = builder.setType(H2).addScript("schema.sql").addScript("data.sql").build();
* db.shutdown();
@@ -44,6 +44,7 @@ public class EmbeddedDatabaseBuilder {
private final ResourceLoader resourceLoader;
+
/**
* Create a new embedded database builder.
*/
@@ -62,6 +63,7 @@ public class EmbeddedDatabaseBuilder {
this.resourceLoader = resourceLoader;
}
+
/**
* Set the name of the embedded database.
* Defaults to "testdb" if not called.
diff --git a/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java b/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java
index 7b20382104..9c978dd690 100644
--- a/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java
+++ b/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java
@@ -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.
@@ -32,7 +32,7 @@ import org.springframework.core.OrderComparator;
import org.springframework.util.Assert;
/**
- * Central helper that manages resources and transaction synchronizations per thread.
+ * Central delegate that manages resources and transaction synchronizations per thread.
* To be used by resource management code but not by typical application code.
*
*
Supports one resource per key without overwriting, that is, a resource needs
@@ -284,7 +284,7 @@ public abstract class TransactionSynchronizationManager {
* @see org.springframework.core.Ordered
*/
public static void registerSynchronization(TransactionSynchronization synchronization)
- throws IllegalStateException {
+ throws IllegalStateException {
Assert.notNull(synchronization, "TransactionSynchronization must not be null");
if (!isSynchronizationActive()) {
diff --git a/spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java b/spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java
index aec22e4d5a..a30347a1b0 100644
--- a/spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java
+++ b/spring-web/src/main/java/org/springframework/web/method/HandlerMethod.java
@@ -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,6 +21,7 @@ import java.lang.reflect.Method;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.BridgeMethodResolver;
import org.springframework.core.MethodParameter;
@@ -29,15 +30,13 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
- * Encapsulates information about a bean method consisting of a
- * {@linkplain #getMethod() method} and a {@linkplain #getBean() bean}. Provides
- * convenient access to method parameters, the method return value, method
- * annotations.
+ * Encapsulates information about a handler method consisting of a {@linkplain #getMethod() method}
+ * and a {@linkplain #getBean() bean}. Provides convenient access to method parameters,
+ * method return value, method annotations.
*
- *
The class may be created with a bean instance or with a bean name (e.g. lazy
- * bean, prototype bean). Use {@link #createWithResolvedBean()} to obtain an
- * {@link HandlerMethod} instance with a bean instance initialized through the
- * bean factory.
+ *
The class may be created with a bean instance or with a bean name (e.g. lazy-init bean,
+ * prototype bean). Use {@link #createWithResolvedBean()} to obtain a {@link HandlerMethod}
+ * instance with a bean instance resolved through the associated {@link BeanFactory}.
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev
@@ -50,21 +49,21 @@ public class HandlerMethod {
private final Object bean;
- private final Method method;
-
private final BeanFactory beanFactory;
- private final MethodParameter[] parameters;
+ private final Method method;
private final Method bridgedMethod;
+ private final MethodParameter[] parameters;
+
/**
* Create an instance from a bean instance and a method.
*/
public HandlerMethod(Object bean, Method method) {
- Assert.notNull(bean, "bean is required");
- Assert.notNull(method, "method is required");
+ Assert.notNull(bean, "Bean is required");
+ Assert.notNull(method, "Method is required");
this.bean = bean;
this.beanFactory = null;
this.method = method;
@@ -72,26 +71,17 @@ public class HandlerMethod {
this.parameters = initMethodParameters();
}
- private MethodParameter[] initMethodParameters() {
- int count = this.bridgedMethod.getParameterTypes().length;
- MethodParameter[] result = new MethodParameter[count];
- for (int i = 0; i < count; i++) {
- result[i] = new HandlerMethodParameter(i);
- }
- return result;
- }
-
/**
* Create an instance from a bean instance, method name, and parameter types.
* @throws NoSuchMethodException when the method cannot be found
*/
public HandlerMethod(Object bean, String methodName, Class>... parameterTypes) throws NoSuchMethodException {
- Assert.notNull(bean, "bean is required");
- Assert.notNull(methodName, "method is required");
+ Assert.notNull(bean, "Bean is required");
+ Assert.notNull(methodName, "Method name is required");
this.bean = bean;
this.beanFactory = null;
this.method = bean.getClass().getMethod(methodName, parameterTypes);
- this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);
+ this.bridgedMethod = BridgeMethodResolver.findBridgedMethod(this.method);
this.parameters = initMethodParameters();
}
@@ -101,11 +91,11 @@ public class HandlerMethod {
* re-create the {@code HandlerMethod} with an initialized the bean.
*/
public HandlerMethod(String beanName, BeanFactory beanFactory, Method method) {
- Assert.hasText(beanName, "beanName is required");
- Assert.notNull(beanFactory, "beanFactory is required");
- Assert.notNull(method, "method is required");
+ Assert.hasText(beanName, "Bean name is required");
+ Assert.notNull(beanFactory, "BeanFactory is required");
+ Assert.notNull(method, "Method is required");
Assert.isTrue(beanFactory.containsBean(beanName),
- "Bean factory [" + beanFactory + "] does not contain bean [" + beanName + "]");
+ "BeanFactory [" + beanFactory + "] does not contain bean [" + beanName + "]");
this.bean = beanName;
this.beanFactory = beanFactory;
this.method = method;
@@ -129,8 +119,8 @@ public class HandlerMethod {
* Re-create HandlerMethod with the resolved handler.
*/
private HandlerMethod(HandlerMethod handlerMethod, Object handler) {
- Assert.notNull(handlerMethod, "handlerMethod is required");
- Assert.notNull(handler, "handler is required");
+ Assert.notNull(handlerMethod, "HandlerMethod is required");
+ Assert.notNull(handler, "Handler object is required");
this.bean = handler;
this.beanFactory = handlerMethod.beanFactory;
this.method = handlerMethod.method;
@@ -138,6 +128,16 @@ public class HandlerMethod {
this.parameters = handlerMethod.parameters;
}
+
+ private MethodParameter[] initMethodParameters() {
+ int count = this.bridgedMethod.getParameterTypes().length;
+ MethodParameter[] result = new MethodParameter[count];
+ for (int i = 0; i < count; i++) {
+ result[i] = new HandlerMethodParameter(i);
+ }
+ return result;
+ }
+
/**
* Returns the bean for this handler method.
*/
@@ -157,9 +157,8 @@ public class HandlerMethod {
* Note that if the bean type is a CGLIB-generated class, the original, user-defined class is returned.
*/
public Class> getBeanType() {
- Class> clazz = (this.bean instanceof String)
- ? this.beanFactory.getType((String) this.bean) : this.bean.getClass();
-
+ Class> clazz = (this.bean instanceof String ?
+ this.beanFactory.getType((String) this.bean) : this.bean.getClass());
return ClassUtils.getUserClass(clazz);
}
@@ -223,33 +222,34 @@ public class HandlerMethod {
}
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(Object obj) {
+ if (this == obj) {
return true;
}
- if (o != null && o instanceof HandlerMethod) {
- HandlerMethod other = (HandlerMethod) o;
- return this.bean.equals(other.bean) && this.method.equals(other.method);
+ if (obj != null && obj instanceof HandlerMethod) {
+ HandlerMethod other = (HandlerMethod) obj;
+ return (this.bean.equals(other.bean) && this.method.equals(other.method));
}
return false;
}
@Override
public int hashCode() {
- return 31 * this.bean.hashCode() + this.method.hashCode();
+ return this.bean.hashCode() * 31 + this.method.hashCode();
}
@Override
public String toString() {
- return method.toGenericString();
+ return this.method.toGenericString();
}
+
/**
* A MethodParameter with HandlerMethod-specific behavior.
*/
private class HandlerMethodParameter extends MethodParameter {
- protected HandlerMethodParameter(int index) {
+ public HandlerMethodParameter(int index) {
super(HandlerMethod.this.bridgedMethod, index);
}
@@ -264,6 +264,7 @@ public class HandlerMethod {
}
}
+
/**
* A MethodParameter for a HandlerMethod return type based on an actual return value.
*/
@@ -278,7 +279,7 @@ public class HandlerMethod {
@Override
public Class> getParameterType() {
- return (this.returnValue != null) ? this.returnValue.getClass() : super.getParameterType();
+ return (this.returnValue != null ? this.returnValue.getClass() : super.getParameterType());
}
}
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java
index fc17d9bd5e..73e88b2901 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java
@@ -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.
@@ -74,6 +74,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
/** Whether or not the view should add path variables in the model */
private boolean exposePathVariables = true;
+
/**
* Set the view's name. Helpful for traceability.
*
Framework code must call this when constructing views.
@@ -242,9 +243,10 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
* Returns the value of the flag indicating whether path variables should be added to the model or not.
*/
public boolean isExposePathVariables() {
- return exposePathVariables;
+ return this.exposePathVariables;
}
+
/**
* Prepares the view given the specified model, merging it with static
* attributes and a RequestContext attribute, if necessary.
@@ -258,7 +260,6 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
}
Map mergedModel = createMergedOutputModel(model, request, response);
-
prepareResponse(request, response);
renderMergedOutputModel(mergedModel, request, response);
}
@@ -268,11 +269,11 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
* Dynamic values take precedence over static attributes.
*/
protected Map createMergedOutputModel(Map model, HttpServletRequest request,
-
HttpServletResponse response) {
+
@SuppressWarnings("unchecked")
- Map pathVars = this.exposePathVariables ?
- (Map) request.getAttribute(View.PATH_VARIABLES) : null;
+ Map pathVars = (this.exposePathVariables ?
+ (Map) request.getAttribute(View.PATH_VARIABLES) : null);
// Consolidate static and dynamic model attributes.
int size = this.staticAttributes.size();