Polishing
This commit is contained in:
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Base class for asynchronous method execution aspects, such as
|
||||
* {@link org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor}
|
||||
* {@code org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor}
|
||||
* or {@code org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect}.
|
||||
*
|
||||
* <p>Provides support for <i>executor qualification</i> on a method-by-method basis.
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -32,6 +31,8 @@ import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.util.CustomizableThreadCreator;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Juergen Hoeller
|
||||
@@ -47,21 +48,23 @@ public class ExecutorBeanDefinitionParserTests {
|
||||
"executorContext.xml", ExecutorBeanDefinitionParserTests.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void defaultExecutor() throws Exception {
|
||||
Object executor = this.context.getBean("default");
|
||||
ThreadPoolTaskExecutor executor = this.context.getBean("default", ThreadPoolTaskExecutor.class);
|
||||
assertEquals(1, getCorePoolSize(executor));
|
||||
assertEquals(Integer.MAX_VALUE, getMaxPoolSize(executor));
|
||||
assertEquals(Integer.MAX_VALUE, getQueueCapacity(executor));
|
||||
assertEquals(60, getKeepAliveSeconds(executor));
|
||||
assertEquals(false, getAllowCoreThreadTimeOut(executor));
|
||||
|
||||
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "foo";
|
||||
}
|
||||
});
|
||||
((ThreadPoolTaskExecutor)executor).execute(task);
|
||||
executor.execute(task);
|
||||
assertEquals("foo", task.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -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,10 +20,11 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.aop.support.StaticMethodMatcherPointcut;
|
||||
import org.springframework.aop.target.HotSwappableTargetSource;
|
||||
@@ -40,31 +41,38 @@ import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.*;
|
||||
|
||||
|
||||
/**
|
||||
* Test cases for AOP transaction management.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @since 23.04.2003
|
||||
*/
|
||||
public class BeanFactoryTransactionTests extends TestCase {
|
||||
public class BeanFactoryTransactionTests {
|
||||
|
||||
private DefaultListableBeanFactory factory;
|
||||
|
||||
@Override
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.factory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(this.factory).loadBeanDefinitions(
|
||||
new ClassPathResource("transactionalBeanFactory.xml", getClass()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetsAreNotTransactionalWithProxyFactory1() throws NoSuchMethodException {
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory1");
|
||||
assertTrue("testBean is a dynamic proxy", Proxy.isProxyClass(testBean.getClass()));
|
||||
doTestGetsAreNotTransactional(testBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetsAreNotTransactionalWithProxyFactory2DynamicProxy() throws NoSuchMethodException {
|
||||
this.factory.preInstantiateSingletons();
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2DynamicProxy");
|
||||
@@ -72,12 +80,14 @@ public class BeanFactoryTransactionTests extends TestCase {
|
||||
doTestGetsAreNotTransactional(testBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetsAreNotTransactionalWithProxyFactory2Cglib() throws NoSuchMethodException {
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Cglib");
|
||||
assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(testBean));
|
||||
doTestGetsAreNotTransactional(testBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyFactory2Lazy() throws NoSuchMethodException {
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory2Lazy");
|
||||
assertFalse(factory.containsSingleton("target"));
|
||||
@@ -85,6 +95,7 @@ public class BeanFactoryTransactionTests extends TestCase {
|
||||
assertTrue(factory.containsSingleton("target"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCglibTransactionProxyImplementsNoInterfaces() throws NoSuchMethodException {
|
||||
ImplementsNoInterfaces ini = (ImplementsNoInterfaces) factory.getBean("cglibNoInterfaces");
|
||||
assertTrue("testBean is CGLIB advised", AopUtils.isCglibProxy(ini));
|
||||
@@ -99,6 +110,7 @@ public class BeanFactoryTransactionTests extends TestCase {
|
||||
assertEquals(2, ptm.commits);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetsAreNotTransactionalWithProxyFactory3() throws NoSuchMethodException {
|
||||
ITestBean testBean = (ITestBean) factory.getBean("proxyFactory3");
|
||||
assertTrue("testBean is a full proxy", testBean instanceof DerivedTestBean);
|
||||
@@ -158,14 +170,16 @@ public class BeanFactoryTransactionTests extends TestCase {
|
||||
assertTrue(testBean.getAge() == age);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBeansOfTypeWithAbstract() {
|
||||
Map beansOfType = factory.getBeansOfType(ITestBean.class, true, true);
|
||||
Map<String, ITestBean> beansOfType = factory.getBeansOfType(ITestBean.class, true, true);
|
||||
assertNotNull(beansOfType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that we fail gracefully if the user doesn't set any transaction attributes.
|
||||
*/
|
||||
@Test
|
||||
public void testNoTransactionAttributeSource() {
|
||||
try {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
@@ -181,6 +195,7 @@ public class BeanFactoryTransactionTests extends TestCase {
|
||||
/**
|
||||
* Test that we can set the target to a dynamic TargetSource.
|
||||
*/
|
||||
@Test
|
||||
public void testDynamicTargetSource() throws NoSuchMethodException {
|
||||
// Install facade
|
||||
CallCountingTransactionManager txMan = new CallCountingTransactionManager();
|
||||
@@ -211,7 +226,7 @@ public class BeanFactoryTransactionTests extends TestCase {
|
||||
int counter = 0;
|
||||
|
||||
@Override
|
||||
public boolean matches(Method method, Class clazz) {
|
||||
public boolean matches(Method method, Class<?> clazz) {
|
||||
counter++;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,6 +49,7 @@ public class NoSupportAsyncWebRequest extends ServletWebRequest implements Async
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Not supported
|
||||
|
||||
public void startAsync() {
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
@@ -36,7 +35,7 @@ import org.springframework.web.context.request.ServletWebRequest;
|
||||
* <p>The servlet and all filters involved in an async request must have async
|
||||
* support enabled using the Servlet API or by adding an
|
||||
* {@code <async-support>true</async-support>} element to servlet and filter
|
||||
* declarations in web.xml
|
||||
* declarations in {@code web.xml}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
@@ -63,9 +62,9 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
||||
super(request, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>In Servlet 3 async processing, the timeout period begins after the
|
||||
* In Servlet 3 async processing, the timeout period begins after the
|
||||
* container processing thread has exited.
|
||||
*/
|
||||
public void setTimeout(Long timeout) {
|
||||
@@ -82,7 +81,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
||||
}
|
||||
|
||||
public boolean isAsyncStarted() {
|
||||
return ((this.asyncContext != null) && getRequest().isAsyncStarted());
|
||||
return (this.asyncContext != null && getRequest().isAsyncStarted());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,6 +100,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
||||
"or by adding \"<async-supported>true</async-supported>\" to servlet and " +
|
||||
"filter declarations in web.xml.");
|
||||
Assert.state(!isAsyncComplete(), "Async processing has already completed");
|
||||
|
||||
if (isAsyncStarted()) {
|
||||
return;
|
||||
}
|
||||
@@ -116,6 +116,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
|
||||
this.asyncContext.dispatch();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Implementation of AsyncListener methods
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.context.request.async;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -67,18 +68,17 @@ public abstract class WebAsyncUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AsyncWebRequest instance. By default an instance of
|
||||
* {@link StandardServletAsyncWebRequest} is created if running in Servlet
|
||||
* 3.0 (or higher) environment or as a fallback, an instance of
|
||||
* {@link NoSupportAsyncWebRequest} is returned.
|
||||
*
|
||||
* Create an AsyncWebRequest instance. By default, an instance of
|
||||
* {@link StandardServletAsyncWebRequest} gets created when running in
|
||||
* Servlet 3.0 (or higher) environment - as a fallback, an instance
|
||||
* of {@link NoSupportAsyncWebRequest} will be returned.
|
||||
* @param request the current request
|
||||
* @param response the current response
|
||||
* @return an AsyncWebRequest instance, never {@code null}
|
||||
* @return an AsyncWebRequest instance (never {@code null})
|
||||
*/
|
||||
public static AsyncWebRequest createAsyncWebRequest(HttpServletRequest request, HttpServletResponse response) {
|
||||
return ClassUtils.hasMethod(ServletRequest.class, "startAsync") ?
|
||||
createStandardServletAsyncWebRequest(request, response) : new NoSupportAsyncWebRequest(request, response);
|
||||
return (ClassUtils.hasMethod(ServletRequest.class, "startAsync") ?
|
||||
createStandardServletAsyncWebRequest(request, response) : new NoSupportAsyncWebRequest(request, response));
|
||||
}
|
||||
|
||||
private static AsyncWebRequest createStandardServletAsyncWebRequest(HttpServletRequest request, HttpServletResponse response) {
|
||||
@@ -90,8 +90,8 @@ public abstract class WebAsyncUtils {
|
||||
}
|
||||
return (AsyncWebRequest) BeanUtils.instantiateClass(standardAsyncRequestConstructor, request, response);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throw new IllegalStateException("Failed to instantiate StandardServletAsyncWebRequest", t);
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalStateException("Failed to instantiate StandardServletAsyncWebRequest", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -94,6 +94,9 @@ public interface MultipartFile {
|
||||
* <p>If the file has been moved in the filesystem, this operation cannot
|
||||
* be invoked again. Therefore, call this method just once to be able to
|
||||
* work with any storage mechanism.
|
||||
* <p><strong>Note:</strong> when using Servlet 3.0 multipart support you
|
||||
* need to configure the location relative to which files will be copied
|
||||
* as explained in {@link javax.servlet.http.Part#write}.
|
||||
* @param dest the destination file
|
||||
* @throws IOException in case of reading or writing errors
|
||||
* @throws IllegalStateException if the file has already been moved
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,8 +26,10 @@ import javax.servlet.http.HttpServletRequest;
|
||||
*
|
||||
* <p>There are two concrete implementations included in Spring, as of Spring 3.1:
|
||||
* <ul>
|
||||
* <li>{@link org.springframework.web.multipart.commons.CommonsMultipartResolver} for Jakarta Commons FileUpload
|
||||
* <li>{@link org.springframework.web.multipart.support.StandardServletMultipartResolver} for Servlet 3.0 Part API
|
||||
* <li>{@link org.springframework.web.multipart.commons.CommonsMultipartResolver}
|
||||
* for Apache Commons FileUpload
|
||||
* <li>{@link org.springframework.web.multipart.support.StandardServletMultipartResolver}
|
||||
* for the Servlet 3.0+ Part API
|
||||
* </ul>
|
||||
*
|
||||
* <p>There is no default resolver implementation used for Spring
|
||||
@@ -38,14 +40,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||
* application context. Such a resolver gets applied to all requests handled
|
||||
* by that {@link org.springframework.web.servlet.DispatcherServlet}.
|
||||
*
|
||||
* <p>If a {@link org.springframework.web.servlet.DispatcherServlet} detects
|
||||
* a multipart request, it will resolve it via the configured
|
||||
* {@link MultipartResolver} and pass on a
|
||||
* wrapped {@link javax.servlet.http.HttpServletRequest}.
|
||||
* Controllers can then cast their given request to the
|
||||
* {@link MultipartHttpServletRequest}
|
||||
* interface, which permits access to any
|
||||
* {@link MultipartFile MultipartFiles}.
|
||||
* <p>If a {@link org.springframework.web.servlet.DispatcherServlet} detects a
|
||||
* multipart request, it will resolve it via the configured {@link MultipartResolver}
|
||||
* and pass on a wrapped {@link javax.servlet.http.HttpServletRequest}. Controllers
|
||||
* can then cast their given request to the {@link MultipartHttpServletRequest}
|
||||
* interface, which allows for access to any {@link MultipartFile MultipartFiles}.
|
||||
* Note that this cast is only supported in case of an actual multipart request.
|
||||
*
|
||||
* <pre class="code">
|
||||
@@ -58,23 +57,19 @@ import javax.servlet.http.HttpServletRequest;
|
||||
* Instead of direct access, command or form controllers can register a
|
||||
* {@link org.springframework.web.multipart.support.ByteArrayMultipartFileEditor}
|
||||
* or {@link org.springframework.web.multipart.support.StringMultipartFileEditor}
|
||||
* with their data binder, to automatically apply multipart content to command
|
||||
* with their data binder, to automatically apply multipart content to form
|
||||
* bean properties.
|
||||
*
|
||||
* <p>As an alternative to using a
|
||||
* {@link MultipartResolver} with a
|
||||
* <p>As an alternative to using a {@link MultipartResolver} with a
|
||||
* {@link org.springframework.web.servlet.DispatcherServlet},
|
||||
* a {@link org.springframework.web.multipart.support.MultipartFilter} can be
|
||||
* registered in {@code web.xml}. It will delegate to a corresponding
|
||||
* {@link MultipartResolver} bean in the root
|
||||
* application context. This is mainly intended for applications that do not
|
||||
* use Spring's own web MVC framework.
|
||||
* {@link MultipartResolver} bean in the root application context. This is mainly
|
||||
* intended for applications that do not use Spring's own web MVC framework.
|
||||
*
|
||||
* <p>Note: There is hardly ever a need to access the
|
||||
* {@link MultipartResolver} itself
|
||||
* from application code. It will simply do its work behind the scenes,
|
||||
* making
|
||||
* {@link MultipartHttpServletRequest MultipartHttpServletRequests}
|
||||
* <p>Note: There is hardly ever a need to access the {@link MultipartResolver}
|
||||
* itself from application code. It will simply do its work behind the scenes,
|
||||
* making {@link MultipartHttpServletRequest MultipartHttpServletRequests}
|
||||
* available to controllers.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@@ -101,8 +96,8 @@ public interface MultipartResolver {
|
||||
/**
|
||||
* Parse the given HTTP request into multipart files and parameters,
|
||||
* and wrap the request inside a
|
||||
* {@link org.springframework.web.multipart.MultipartHttpServletRequest} object
|
||||
* that provides access to file descriptors and makes contained
|
||||
* {@link org.springframework.web.multipart.MultipartHttpServletRequest}
|
||||
* object that provides access to file descriptors and makes contained
|
||||
* parameters accessible via the standard ServletRequest methods.
|
||||
* @param request the servlet request to wrap (must be of a multipart content type)
|
||||
* @return the wrapped servlet request
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* Base class for multipart resolvers that use Jakarta Commons FileUpload
|
||||
* Base class for multipart resolvers that use Apache Commons FileUpload
|
||||
* 1.2 or above.
|
||||
*
|
||||
* <p>Provides common configuration properties and parsing functionality
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItem;
|
||||
@@ -30,7 +31,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* MultipartFile implementation for Jakarta Commons FileUpload.
|
||||
* MultipartFile implementation for Apache Commons FileUpload.
|
||||
*
|
||||
* @author Trevor D. Cook
|
||||
* @author Juergen Hoeller
|
||||
@@ -56,6 +57,7 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
|
||||
this.size = this.fileItem.getSize();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the underlying {@code org.apache.commons.fileupload.FileItem}
|
||||
* instance. There is hardly any need to access this.
|
||||
@@ -75,18 +77,18 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
|
||||
// Should never happen.
|
||||
return "";
|
||||
}
|
||||
// check for Unix-style path
|
||||
// Check for Unix-style path
|
||||
int pos = filename.lastIndexOf("/");
|
||||
if (pos == -1) {
|
||||
// check for Windows-style path
|
||||
// Check for Windows-style path
|
||||
pos = filename.lastIndexOf("\\");
|
||||
}
|
||||
if (pos != -1) {
|
||||
// any sort of path separator found
|
||||
// Any sort of path separator found...
|
||||
return filename.substring(pos + 1);
|
||||
}
|
||||
else {
|
||||
// plain name
|
||||
// A plain name
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,8 +37,8 @@ import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequ
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* Servlet-based {@link org.springframework.web.multipart.MultipartResolver} implementation
|
||||
* for <a href="http://jakarta.apache.org/commons/fileupload">Jakarta Commons FileUpload</a>
|
||||
* Servlet-based {@link MultipartResolver} implementation for
|
||||
* <a href="http://commons.apache.org/proper/commons-fileupload">Apache Commons FileUpload</a>
|
||||
* 1.2 or above.
|
||||
*
|
||||
* <p>Provides "maxUploadSize", "maxInMemorySize" and "defaultEncoding" settings as
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
|
||||
/**
|
||||
*
|
||||
* MultipartResolver implementation for
|
||||
* <a href="http://jakarta.apache.org/commons/fileupload">Jakarta Commons FileUpload</a>.
|
||||
*
|
||||
* <a href="http://commons.apache.org/proper/commons-fileupload">Apache Commons FileUpload</a>.
|
||||
*/
|
||||
package org.springframework.web.multipart.commons;
|
||||
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -174,7 +174,7 @@ public abstract class WebUtils {
|
||||
* i.e. the value of the "defaultHtmlEscape" context-param in {@code web.xml}
|
||||
* (if any). Falls back to {@code false} in case of no explicit default given.
|
||||
* @param servletContext the servlet context of the web application
|
||||
* @return whether default HTML escaping is enabled (default is false)
|
||||
* @return whether default HTML escaping is enabled (default is {@code false})
|
||||
*/
|
||||
public static boolean isDefaultHtmlEscape(ServletContext servletContext) {
|
||||
if (servletContext == null) {
|
||||
@@ -192,14 +192,15 @@ public abstract class WebUtils {
|
||||
* an actual boolean value specified, allowing to have a context-specific
|
||||
* default in case of no setting at the global level.
|
||||
* @param servletContext the servlet context of the web application
|
||||
* @return whether default HTML escaping is enabled (null = no explicit default)
|
||||
* @return whether default HTML escaping is enabled for the given application
|
||||
* ({@code null} = no explicit default)
|
||||
*/
|
||||
public static Boolean getDefaultHtmlEscape(ServletContext servletContext) {
|
||||
if (servletContext == null) {
|
||||
return null;
|
||||
}
|
||||
String param = servletContext.getInitParameter(HTML_ESCAPE_CONTEXT_PARAM);
|
||||
return (StringUtils.hasText(param)? Boolean.valueOf(param) : null);
|
||||
return (StringUtils.hasText(param) ? Boolean.valueOf(param) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -730,9 +731,9 @@ public abstract class WebUtils {
|
||||
* like this {@code "q1=a;q1=b;q2=a,b,c"}. The resulting map would contain
|
||||
* keys {@code "q1"} and {@code "q2"} with values {@code ["a","b"]} and
|
||||
* {@code ["a","b","c"]} respectively.
|
||||
*
|
||||
* @param matrixVariables the unparsed matrix variables string
|
||||
* @return a map with matrix variable names and values, never {@code null}
|
||||
* @return a map with matrix variable names and values (never {@code null})
|
||||
* @since 3.2
|
||||
*/
|
||||
public static MultiValueMap<String, String> parseMatrixVariables(String matrixVariables) {
|
||||
MultiValueMap<String, String> result = new LinkedMultiValueMap<String, String>();
|
||||
|
||||
Reference in New Issue
Block a user