Polishing
This commit is contained in:
@@ -155,7 +155,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
|||||||
/**
|
/**
|
||||||
* Handles a fatal error thrown while asynchronously invoking the specified
|
* Handles a fatal error thrown while asynchronously invoking the specified
|
||||||
* {@link Method}.
|
* {@link Method}.
|
||||||
* <p>If the return type of the method is a {@link java.util.concurrent.Future} object, the original
|
* <p>If the return type of the method is a {@link Future} object, the original
|
||||||
* exception can be propagated by just throwing it at the higher level. However,
|
* exception can be propagated by just throwing it at the higher level. However,
|
||||||
* for all other cases, the exception will not be transmitted back to the client.
|
* for all other cases, the exception will not be transmitted back to the client.
|
||||||
* In that later case, the current {@link AsyncUncaughtExceptionHandler} will be
|
* In that later case, the current {@link AsyncUncaughtExceptionHandler} will be
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2015 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.
|
||||||
@@ -48,21 +48,23 @@ public class ExecutorBeanDefinitionParserTests {
|
|||||||
"executorContext.xml", ExecutorBeanDefinitionParserTests.class);
|
"executorContext.xml", ExecutorBeanDefinitionParserTests.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void defaultExecutor() throws Exception {
|
public void defaultExecutor() throws Exception {
|
||||||
Object executor = this.context.getBean("default");
|
ThreadPoolTaskExecutor executor = this.context.getBean("default", ThreadPoolTaskExecutor.class);
|
||||||
assertEquals(1, getCorePoolSize(executor));
|
assertEquals(1, getCorePoolSize(executor));
|
||||||
assertEquals(Integer.MAX_VALUE, getMaxPoolSize(executor));
|
assertEquals(Integer.MAX_VALUE, getMaxPoolSize(executor));
|
||||||
assertEquals(Integer.MAX_VALUE, getQueueCapacity(executor));
|
assertEquals(Integer.MAX_VALUE, getQueueCapacity(executor));
|
||||||
assertEquals(60, getKeepAliveSeconds(executor));
|
assertEquals(60, getKeepAliveSeconds(executor));
|
||||||
assertEquals(false, getAllowCoreThreadTimeOut(executor));
|
assertEquals(false, getAllowCoreThreadTimeOut(executor));
|
||||||
|
|
||||||
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
|
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String call() throws Exception {
|
public String call() throws Exception {
|
||||||
return "foo";
|
return "foo";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((ThreadPoolTaskExecutor)executor).execute(task);
|
executor.execute(task);
|
||||||
assertEquals("foo", task.get());
|
assertEquals("foo", task.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 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.
|
||||||
@@ -41,6 +41,8 @@ import org.springframework.util.ReflectionUtils;
|
|||||||
*/
|
*/
|
||||||
class CachedMessageProducer implements MessageProducer, QueueSender, TopicPublisher {
|
class CachedMessageProducer implements MessageProducer, QueueSender, TopicPublisher {
|
||||||
|
|
||||||
|
// Various JMS 2.0 MessageProducer methods, if available
|
||||||
|
|
||||||
private static final Method setDeliveryDelayMethod =
|
private static final Method setDeliveryDelayMethod =
|
||||||
ClassUtils.getMethodIfAvailable(MessageProducer.class, "setDeliveryDelay", long.class);
|
ClassUtils.getMethodIfAvailable(MessageProducer.class, "setDeliveryDelay", long.class);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 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.
|
||||||
@@ -78,9 +78,11 @@ import org.springframework.util.ReflectionUtils;
|
|||||||
*/
|
*/
|
||||||
public class CachingConnectionFactory extends SingleConnectionFactory {
|
public class CachingConnectionFactory extends SingleConnectionFactory {
|
||||||
|
|
||||||
|
/** The JMS 2.0 Session.createSharedConsumer method, if available */
|
||||||
private static final Method createSharedConsumerMethod = ClassUtils.getMethodIfAvailable(
|
private static final Method createSharedConsumerMethod = ClassUtils.getMethodIfAvailable(
|
||||||
Session.class, "createSharedConsumer", Topic.class, String.class, String.class);
|
Session.class, "createSharedConsumer", Topic.class, String.class, String.class);
|
||||||
|
|
||||||
|
/** The JMS 2.0 Session.createSharedDurableConsumer method, if available */
|
||||||
private static final Method createSharedDurableConsumerMethod = ClassUtils.getMethodIfAvailable(
|
private static final Method createSharedDurableConsumerMethod = ClassUtils.getMethodIfAvailable(
|
||||||
Session.class, "createSharedDurableConsumer", Topic.class, String.class, String.class);
|
Session.class, "createSharedDurableConsumer", Topic.class, String.class, String.class);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2015 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.
|
||||||
@@ -101,6 +101,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
|
|||||||
public static final long RECEIVE_TIMEOUT_INDEFINITE_WAIT = 0;
|
public static final long RECEIVE_TIMEOUT_INDEFINITE_WAIT = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/** The JMS 2.0 MessageProducer.setDeliveryDelay method, if available */
|
||||||
private static final Method setDeliveryDelayMethod =
|
private static final Method setDeliveryDelayMethod =
|
||||||
ClassUtils.getMethodIfAvailable(MessageProducer.class, "setDeliveryDelay", long.class);
|
ClassUtils.getMethodIfAvailable(MessageProducer.class, "setDeliveryDelay", long.class);
|
||||||
|
|
||||||
|
|||||||
@@ -134,9 +134,11 @@ import org.springframework.util.ReflectionUtils;
|
|||||||
public abstract class AbstractMessageListenerContainer extends AbstractJmsListeningContainer
|
public abstract class AbstractMessageListenerContainer extends AbstractJmsListeningContainer
|
||||||
implements MessageListenerContainer {
|
implements MessageListenerContainer {
|
||||||
|
|
||||||
|
/** The JMS 2.0 Session.createSharedConsumer method, if available */
|
||||||
private static final Method createSharedConsumerMethod = ClassUtils.getMethodIfAvailable(
|
private static final Method createSharedConsumerMethod = ClassUtils.getMethodIfAvailable(
|
||||||
Session.class, "createSharedConsumer", Topic.class, String.class, String.class);
|
Session.class, "createSharedConsumer", Topic.class, String.class, String.class);
|
||||||
|
|
||||||
|
/** The JMS 2.0 Session.createSharedDurableConsumer method, if available */
|
||||||
private static final Method createSharedDurableConsumerMethod = ClassUtils.getMethodIfAvailable(
|
private static final Method createSharedDurableConsumerMethod = ClassUtils.getMethodIfAvailable(
|
||||||
Session.class, "createSharedDurableConsumer", Topic.class, String.class, String.class);
|
Session.class, "createSharedDurableConsumer", Topic.class, String.class, String.class);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2015 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.
|
||||||
@@ -33,6 +33,7 @@ public class NoSupportAsyncWebRequest extends ServletWebRequest implements Async
|
|||||||
super(request, response);
|
super(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCompletionHandler(Runnable runnable) {
|
public void addCompletionHandler(Runnable runnable) {
|
||||||
// ignored
|
// ignored
|
||||||
@@ -53,6 +54,7 @@ public class NoSupportAsyncWebRequest extends ServletWebRequest implements Async
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Not supported
|
// Not supported
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2015 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.
|
||||||
@@ -35,7 +35,7 @@ import org.springframework.web.context.request.ServletWebRequest;
|
|||||||
* <p>The servlet and all filters involved in an async request must have async
|
* <p>The servlet and all filters involved in an async request must have async
|
||||||
* support enabled using the Servlet API or by adding an
|
* support enabled using the Servlet API or by adding an
|
||||||
* {@code <async-support>true</async-support>} element to servlet and filter
|
* {@code <async-support>true</async-support>} element to servlet and filter
|
||||||
* declarations in web.xml
|
* declarations in {@code web.xml}.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
@@ -62,9 +62,9 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
|||||||
super(request, response);
|
super(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* In Servlet 3 async processing, the timeout period begins after the
|
||||||
* <p>In Servlet 3 async processing, the timeout period begins after the
|
|
||||||
* container processing thread has exited.
|
* container processing thread has exited.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -85,7 +85,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAsyncStarted() {
|
public boolean isAsyncStarted() {
|
||||||
return ((this.asyncContext != null) && getRequest().isAsyncStarted());
|
return (this.asyncContext != null && getRequest().isAsyncStarted());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,6 +106,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
|||||||
"or by adding \"<async-supported>true</async-supported>\" to servlet and " +
|
"or by adding \"<async-supported>true</async-supported>\" to servlet and " +
|
||||||
"filter declarations in web.xml.");
|
"filter declarations in web.xml.");
|
||||||
Assert.state(!isAsyncComplete(), "Async processing has already completed");
|
Assert.state(!isAsyncComplete(), "Async processing has already completed");
|
||||||
|
|
||||||
if (isAsyncStarted()) {
|
if (isAsyncStarted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -122,6 +123,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
|||||||
this.asyncContext.dispatch();
|
this.asyncContext.dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Implementation of AsyncListener methods
|
// Implementation of AsyncListener methods
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
|
|||||||
this.size = this.fileItem.getSize();
|
this.size = this.fileItem.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the underlying {@code org.apache.commons.fileupload.FileItem}
|
* Return the underlying {@code org.apache.commons.fileupload.FileItem}
|
||||||
* instance. There is hardly any need to access this.
|
* instance. There is hardly any need to access this.
|
||||||
@@ -65,7 +66,6 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
|
|||||||
return this.fileItem;
|
return this.fileItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.fileItem.getFieldName();
|
return this.fileItem.getFieldName();
|
||||||
@@ -78,18 +78,18 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
|
|||||||
// Should never happen.
|
// Should never happen.
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
// check for Unix-style path
|
// Check for Unix-style path
|
||||||
int pos = filename.lastIndexOf("/");
|
int pos = filename.lastIndexOf("/");
|
||||||
if (pos == -1) {
|
if (pos == -1) {
|
||||||
// check for Windows-style path
|
// Check for Windows-style path
|
||||||
pos = filename.lastIndexOf("\\");
|
pos = filename.lastIndexOf("\\");
|
||||||
}
|
}
|
||||||
if (pos != -1) {
|
if (pos != -1) {
|
||||||
// any sort of path separator found
|
// Any sort of path separator found...
|
||||||
return filename.substring(pos + 1);
|
return filename.substring(pos + 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// plain name
|
// A plain name
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user