diff --git a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java
index c75392c30b..8e51136e2e 100644
--- a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java
+++ b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java
@@ -43,7 +43,7 @@ import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
* meaningful validation. All exposed Commons Pool properties use the
* corresponding Commons Pool defaults.
*
- *
Compatible with Apache Commons Pool 2.4
+ *
Compatible with Apache Commons Pool 2.4, as of Spring 4.2.
*
* @author Rod Johnson
* @author Rob Harrop
@@ -90,6 +90,7 @@ public class CommonsPool2TargetSource extends AbstractPoolingTargetSource implem
setMaxSize(GenericObjectPoolConfig.DEFAULT_MAX_TOTAL);
}
+
/**
* Set the maximum number of idle objects in the pool.
* Default is 8.
@@ -185,9 +186,10 @@ public class CommonsPool2TargetSource extends AbstractPoolingTargetSource implem
* Specify if the call should block when the pool is exhausted.
*/
public boolean isBlockWhenExhausted() {
- return blockWhenExhausted;
+ return this.blockWhenExhausted;
}
+
/**
* Creates and holds an ObjectPool instance.
* @see #createObjectPool()
@@ -220,7 +222,7 @@ public class CommonsPool2TargetSource extends AbstractPoolingTargetSource implem
/**
- * Borrow an object from the {@code ObjectPool}.
+ * Borrows an object from the {@code ObjectPool}.
*/
@Override
public Object getTarget() throws Exception {
diff --git a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AnnotationTransactionAspect.aj b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AnnotationTransactionAspect.aj
index 77db8ea48b..f98093d411 100644
--- a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AnnotationTransactionAspect.aj
+++ b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/AnnotationTransactionAspect.aj
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -20,7 +20,8 @@ import org.springframework.transaction.annotation.AnnotationTransactionAttribute
import org.springframework.transaction.annotation.Transactional;
/**
- * Concrete AspectJ transaction aspect using Spring's @Transactional annotation.
+ * Concrete AspectJ transaction aspect using Spring's
+ * {@link org.springframework.transaction.annotation.Transactional} annotation.
*
*
When using this aspect, you must annotate the implementation class
* (and/or methods within that class), not the interface (if any) that
@@ -66,8 +67,6 @@ public aspect AnnotationTransactionAspect extends AbstractTransactionAspect {
* will have Spring transaction management applied.
*/
protected pointcut transactionalMethodExecution(Object txObject) :
- (executionOfAnyPublicMethodInAtTransactionalType()
- || executionOfTransactionalMethod() )
- && this(txObject);
+ (executionOfAnyPublicMethodInAtTransactionalType() || executionOfTransactionalMethod() ) && this(txObject);
}
diff --git a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/JtaAnnotationTransactionAspect.aj b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/JtaAnnotationTransactionAspect.aj
index 86a8557cba..6b02e1de3a 100644
--- a/spring-aspects/src/main/java/org/springframework/transaction/aspectj/JtaAnnotationTransactionAspect.aj
+++ b/spring-aspects/src/main/java/org/springframework/transaction/aspectj/JtaAnnotationTransactionAspect.aj
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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.
@@ -23,7 +23,8 @@ import org.aspectj.lang.annotation.RequiredTypes;
import org.springframework.transaction.annotation.AnnotationTransactionAttributeSource;
/**
- * Concrete AspectJ transaction aspect using {@code javax.transaction.Transactional} annotation.
+ * Concrete AspectJ transaction aspect using the JTA 1.2
+ * {@link javax.transaction.Transactional} annotation.
*
*
When using this aspect, you must annotate the implementation class
* (and/or methods within that class), not the interface (if any) that
@@ -41,7 +42,7 @@ import org.springframework.transaction.annotation.AnnotationTransactionAttribute
*
* @author Stephane Nicoll
* @since 4.2
- * @see Transactional
+ * @see javax.transaction.Transactional
* @see AnnotationTransactionAspect
*/
@RequiredTypes({"javax.transaction.Transactional"})
@@ -69,8 +70,6 @@ public aspect JtaAnnotationTransactionAspect extends AbstractTransactionAspect {
* will have Spring transaction management applied.
*/
protected pointcut transactionalMethodExecution(Object txObject) :
- (executionOfAnyPublicMethodInAtTransactionalType()
- || executionOfTransactionalMethod() )
- && this(txObject);
+ (executionOfAnyPublicMethodInAtTransactionalType() || executionOfTransactionalMethod() ) && this(txObject);
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java b/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java
index ba9e309ace..9ea5bfd372 100644
--- a/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java
+++ b/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java
@@ -101,6 +101,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
*/
private Map nestedPropertyAccessors;
+
/**
* Create new empty accessor. Wrapped instance needs to be set afterwards.
* Registers default editors.
@@ -168,6 +169,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
setConversionService(parent.getConversionService());
}
+
/**
* Specify a limit for array and collection auto-growing.
*
Default is unlimited on a plain accessor.
@@ -758,7 +760,6 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
for (int i = length; i < Array.getLength(newArray); i++) {
Array.set(newArray, i, newValue(componentType, null, name));
}
- // TODO this is not efficient because conversion may create a copy ... set directly because we know it is assignable.
setPropertyValue(name, newArray);
return getPropertyValue(name);
}
@@ -802,7 +803,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
* @param propertyPath property property path, which may be nested
* @return a property accessor for the target bean
*/
- @SuppressWarnings("unchecked") // avoid nested generic
+ @SuppressWarnings("unchecked") // avoid nested generic
protected AbstractNestablePropertyAccessor getPropertyAccessorForPropertyPath(String propertyPath) {
int pos = PropertyAccessorUtils.getFirstNestedPropertySeparatorIndex(propertyPath);
// Handle nested properties recursively.
@@ -1024,9 +1025,9 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
public abstract Object getValue() throws Exception;
public abstract void setValue(Object object, Object value) throws Exception;
-
}
+
protected static class PropertyTokenHolder {
public String canonicalName;
@@ -1055,4 +1056,5 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
return !((Optional>) optionalObject).isPresent();
}
}
+
}
diff --git a/spring-context/src/main/java/org/springframework/context/PayloadApplicationEvent.java b/spring-context/src/main/java/org/springframework/context/PayloadApplicationEvent.java
index 4ecb26582f..6011df5067 100644
--- a/spring-context/src/main/java/org/springframework/context/PayloadApplicationEvent.java
+++ b/spring-context/src/main/java/org/springframework/context/PayloadApplicationEvent.java
@@ -46,10 +46,10 @@ public class PayloadApplicationEvent extends ApplicationEvent implements Reso
this.payload = payload;
}
+
@Override
public ResolvableType getResolvableType() {
- return ResolvableType.forClassWithGenerics(getClass(),
- ResolvableType.forInstance(getPayload()));
+ return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forInstance(getPayload()));
}
/**
diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
index f1a80bda42..0a23ea0314 100644
--- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
+++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
@@ -334,11 +334,26 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
publishEvent(event, null);
}
+ /**
+ * Publish the given event to all listeners.
+ *
Note: Listeners get initialized after the MessageSource, to be able
+ * to access it within listener implementations. Thus, MessageSource
+ * implementations cannot publish events.
+ * @param event the event to publish (may be an {@link ApplicationEvent}
+ * or a payload object to be turned into a {@link PayloadApplicationEvent})
+ */
@Override
public void publishEvent(Object event) {
publishEvent(event, null);
}
+ /**
+ * Publish the given event to all listeners.
+ * @param event the event to publish (may be an {@link ApplicationEvent}
+ * or a payload object to be turned into a {@link PayloadApplicationEvent})
+ * @param eventType the resolved event type, if known
+ * @since 4.2
+ */
protected void publishEvent(Object event, ResolvableType eventType) {
Assert.notNull(event, "Event must not be null");
if (logger.isTraceEnabled()) {
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptStatementFailedException.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptStatementFailedException.java
index 6636eb81a9..e944f26c73 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptStatementFailedException.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptStatementFailedException.java
@@ -41,6 +41,7 @@ public class ScriptStatementFailedException extends ScriptException {
super(buildErrorMessage(stmt, stmtNumber, encodedResource), cause);
}
+
/**
* Build an error message for an SQL script execution failure,
* based on the supplied arguments.
@@ -53,8 +54,7 @@ public class ScriptStatementFailedException extends ScriptException {
* @since 4.2
*/
public static String buildErrorMessage(String stmt, int stmtNumber, EncodedResource encodedResource) {
- return String.format("Failed to execute SQL script statement #%s of %s: %s",
- stmtNumber, encodedResource, stmt);
+ return String.format("Failed to execute SQL script statement #%s of %s: %s", stmtNumber, encodedResource, stmt);
}
}
diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/adapter/JmsResponse.java b/spring-jms/src/main/java/org/springframework/jms/listener/adapter/JmsResponse.java
index 15a48de37c..0ba0e326d7 100644
--- a/spring-jms/src/main/java/org/springframework/jms/listener/adapter/JmsResponse.java
+++ b/spring-jms/src/main/java/org/springframework/jms/listener/adapter/JmsResponse.java
@@ -24,12 +24,12 @@ import org.springframework.jms.support.destination.DestinationResolver;
import org.springframework.util.Assert;
/**
- * Return type of any JMS listener method used to indicate the actual response destination
- * alongside the response itself. Typically used when said destination needs to be
- * computed at runtime.
- *
- * The example below sends a response with the content of the {@code result} argument to
- * the {@code queueOut Queue}:
+ * Return type of any JMS listener method used to indicate the actual response
+ * destination alongside the response itself. Typically used when said destination
+ * needs to be computed at runtime.
+ *
+ *
The example below sends a response with the content of the {@code result}
+ * argument to the {@code queueOut Queue}:
*
*
*
* If the destination does not need to be computed at runtime,
- * {@link org.springframework.messaging.handler.annotation.SendTo @SendTo} is the
- * recommended declarative approach.
+ * {@link org.springframework.messaging.handler.annotation.SendTo @SendTo}
+ * is the recommended declarative approach.
*
* @author Stephane Nicoll
* @since 4.2
@@ -58,6 +58,7 @@ public class JmsResponse {
private final Object destination;
+
/**
* Create a new instance
* @param response the content of the result
@@ -69,29 +70,6 @@ public class JmsResponse {
this.destination = destination;
}
- /**
- * Create a {@link JmsResponse} targeting the queue with the specified name.
- */
- public static JmsResponse forQueue(T result, String queueName) {
- Assert.notNull(queueName, "Queue name must not be null");
- return new JmsResponse(result, new DestinationNameHolder(queueName, false));
- }
-
- /**
- * Create a {@link JmsResponse} targeting the topic with the specified name.
- */
- public static JmsResponse forTopic(T result, String topicName) {
- Assert.notNull(topicName, "Topic name must not be null");
- return new JmsResponse(result, new DestinationNameHolder(topicName, true));
- }
-
- /**
- * Create a {@link JmsResponse} targeting the specified {@link Destination}.
- */
- public static JmsResponse forDestination(T result, Destination destination) {
- Assert.notNull(destination, "Destination must not be null");
- return new JmsResponse(result, destination);
- }
/**
* Return the content of the response.
@@ -124,7 +102,32 @@ public class JmsResponse {
@Override
public String toString() {
- return "JmsResponse{" + "response=" + this.response + ", destination=" + this.destination + '}';
+ return "JmsResponse [" + "response=" + this.response + ", destination=" + this.destination + ']';
+ }
+
+
+ /**
+ * Create a {@link JmsResponse} targeting the queue with the specified name.
+ */
+ public static JmsResponse forQueue(T result, String queueName) {
+ Assert.notNull(queueName, "Queue name must not be null");
+ return new JmsResponse(result, new DestinationNameHolder(queueName, false));
+ }
+
+ /**
+ * Create a {@link JmsResponse} targeting the topic with the specified name.
+ */
+ public static JmsResponse forTopic(T result, String topicName) {
+ Assert.notNull(topicName, "Topic name must not be null");
+ return new JmsResponse(result, new DestinationNameHolder(topicName, true));
+ }
+
+ /**
+ * Create a {@link JmsResponse} targeting the specified {@link Destination}.
+ */
+ public static JmsResponse forDestination(T result, Destination destination) {
+ Assert.notNull(destination, "Destination must not be null");
+ return new JmsResponse(result, destination);
}
@@ -132,7 +135,8 @@ public class JmsResponse {
* Internal class combining a destination name
* and its target destination type (queue or topic).
*/
- protected static class DestinationNameHolder {
+ private static class DestinationNameHolder {
+
private final String destinationName;
private final boolean pubSubDomain;
diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java
index 78c6ade2a3..83955d9631 100644
--- a/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java
+++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/MarshallingMessageConverter.java
@@ -18,7 +18,6 @@ package org.springframework.messaging.converter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
@@ -32,9 +31,7 @@ import org.springframework.beans.TypeMismatchException;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.oxm.Marshaller;
-import org.springframework.oxm.MarshallingFailureException;
import org.springframework.oxm.Unmarshaller;
-import org.springframework.oxm.UnmarshallingFailureException;
import org.springframework.util.Assert;
import org.springframework.util.MimeType;
@@ -61,8 +58,7 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
* {@link #setUnmarshaller(Unmarshaller)} to be invoked separately.
*/
public MarshallingMessageConverter() {
- this(new MimeType("application", "xml"), new MimeType("text", "xml"),
- new MimeType("application", "*+xml"));
+ this(new MimeType("application", "xml"), new MimeType("text", "xml"), new MimeType("application", "*+xml"));
}
/**
@@ -76,10 +72,8 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
/**
* Constructor with {@link Marshaller}. If the given {@link Marshaller} also
* implements {@link Unmarshaller}, it is also used for unmarshalling.
- *
*
Note that all {@code Marshaller} implementations in Spring also implement
* {@code Unmarshaller} so that you can safely use this constructor.
- *
* @param marshaller object used as marshaller and unmarshaller
*/
public MarshallingMessageConverter(Marshaller marshaller) {
@@ -144,17 +138,13 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
Assert.notNull(this.unmarshaller, "Property 'unmarshaller' is required");
try {
Source source = getSource(message.getPayload());
-
Object result = this.unmarshaller.unmarshal(source);
if (!targetClass.isInstance(result)) {
throw new TypeMismatchException(result, targetClass);
}
return result;
}
- catch (UnmarshallingFailureException ex) {
- throw new MessageConversionException(message, "Could not unmarshal XML: " + ex.getMessage(), ex);
- }
- catch (IOException ex) {
+ catch (Exception ex) {
throw new MessageConversionException(message, "Could not unmarshal XML: " + ex.getMessage(), ex);
}
}
@@ -175,26 +165,20 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
if (byte[].class == getSerializedPayloadClass()) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Result result = new StreamResult(out);
-
this.marshaller.marshal(payload, result);
-
payload = out.toByteArray();
}
else {
Writer writer = new StringWriter();
Result result = new StreamResult(writer);
-
this.marshaller.marshal(payload, result);
-
payload = writer.toString();
}
}
- catch (MarshallingFailureException ex) {
- throw new MessageConversionException("Could not marshal XML: " + ex.getMessage(), ex);
- }
- catch (IOException ex) {
+ catch (Exception ex) {
throw new MessageConversionException("Could not marshal XML: " + ex.getMessage(), ex);
}
return payload;
}
+
}
diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/MessagingAdviceBean.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/MessagingAdviceBean.java
index 5042c64003..bbe80496cb 100644
--- a/spring-messaging/src/main/java/org/springframework/messaging/handler/MessagingAdviceBean.java
+++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/MessagingAdviceBean.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.messaging.handler;
import org.springframework.core.Ordered;
diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractAsyncReturnValueHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractAsyncReturnValueHandler.java
index 993599c0a5..6153339706 100644
--- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractAsyncReturnValueHandler.java
+++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractAsyncReturnValueHandler.java
@@ -21,7 +21,7 @@ import org.springframework.messaging.Message;
/**
* Convenient base class for {@link AsyncHandlerMethodReturnValueHandler}
- * implementations that support only asynchronous (Future-like) return values a
+ * implementations that support only asynchronous (Future-like) return values
* and merely serve as adapters of such types to Spring's
* {@link org.springframework.util.concurrent.ListenableFuture ListenableFuture}.
*
@@ -38,7 +38,7 @@ public abstract class AbstractAsyncReturnValueHandler implements AsyncHandlerMet
@Override
public void handleReturnValue(Object returnValue, MethodParameter returnType, Message> message) {
// Should never be called since we return "true" from isAsyncReturnValue
- throw new IllegalStateException("Unexpected invocation.");
+ throw new IllegalStateException("Unexpected invocation");
}
}
diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AsyncHandlerMethodReturnValueHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AsyncHandlerMethodReturnValueHandler.java
index 4848954744..9dda4d014d 100644
--- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AsyncHandlerMethodReturnValueHandler.java
+++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AsyncHandlerMethodReturnValueHandler.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.messaging.handler.invocation;
import org.springframework.core.MethodParameter;
@@ -38,11 +39,9 @@ public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodRetur
* with success and error callbacks. If this method returns {@code true},
* then {@link #toListenableFuture} is invoked next. If it returns
* {@code false}, then {@link #handleReturnValue} is called.
- *
*
Note: this method will only be invoked after
* {@link #supportsReturnType(org.springframework.core.MethodParameter)}
* is called and it returns {@code true}.
- *
* @param returnValue the value returned from the handler method
* @param returnType the type of the return value.
* @return true if the return value type represents an async value.
@@ -55,11 +54,9 @@ public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodRetur
* {@link org.springframework.util.concurrent.SettableListenableFuture
* SettableListenableFuture}. Return value handling will then continue when
* the ListenableFuture is completed with either success or error.
- *
*
Note: this method will only be invoked after
* {@link #supportsReturnType(org.springframework.core.MethodParameter)}
* is called and it returns {@code true}.
- *
* @param returnValue the value returned from the handler method
* @param returnType the type of the return value.
* @return the resulting ListenableFuture or {@code null} in which case no
@@ -67,4 +64,4 @@ public interface AsyncHandlerMethodReturnValueHandler extends HandlerMethodRetur
*/
ListenableFuture> toListenableFuture(Object returnValue, MethodParameter returnType);
-}
\ No newline at end of file
+}
diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/CompletableFutureReturnValueHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/CompletableFutureReturnValueHandler.java
index e08c9fb08e..83b6afd704 100644
--- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/CompletableFutureReturnValueHandler.java
+++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/CompletableFutureReturnValueHandler.java
@@ -43,4 +43,4 @@ public class CompletableFutureReturnValueHandler extends AbstractAsyncReturnValu
return new CompletableToListenableFutureAdapter