Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.scripting.bsh;
|
package org.springframework.scripting.bsh;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ import static org.mockito.BDDMockito.*;
|
|||||||
public class BshScriptFactoryTests {
|
public class BshScriptFactoryTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void staticScript() throws Exception {
|
public void staticScript() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
||||||
|
|
||||||
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.class)).contains("calculator"));
|
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Calculator.class)).contains("calculator"));
|
||||||
@@ -75,7 +76,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void staticScriptWithNullReturnValue() throws Exception {
|
public void staticScriptWithNullReturnValue() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
||||||
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerWithConfig"));
|
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerWithConfig"));
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void staticScriptWithTwoInterfacesSpecified() throws Exception {
|
public void staticScriptWithTwoInterfacesSpecified() {
|
||||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
||||||
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerWithConfigExtra"));
|
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerWithConfigExtra"));
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void staticWithScriptReturningInstance() throws Exception {
|
public void staticWithScriptReturningInstance() {
|
||||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
||||||
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerInstance"));
|
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerInstance"));
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void staticScriptImplementingInterface() throws Exception {
|
public void staticScriptImplementingInterface() {
|
||||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
||||||
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerImpl"));
|
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerImpl"));
|
||||||
|
|
||||||
@@ -128,7 +129,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void staticPrototypeScript() throws Exception {
|
public void staticPrototypeScript() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
|
||||||
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||||
@@ -147,7 +148,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nonStaticScript() throws Exception {
|
public void nonStaticScript() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshRefreshableContext.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshRefreshableContext.xml", getClass());
|
||||||
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
Messenger messenger = (Messenger) ctx.getBean("messenger");
|
||||||
|
|
||||||
@@ -165,7 +166,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nonStaticPrototypeScript() throws Exception {
|
public void nonStaticPrototypeScript() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshRefreshableContext.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bshRefreshableContext.xml", getClass());
|
||||||
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||||
@@ -189,7 +190,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void scriptCompilationException() throws Exception {
|
public void scriptCompilationException() {
|
||||||
try {
|
try {
|
||||||
new ClassPathXmlApplicationContext("org/springframework/scripting/bsh/bshBrokenContext.xml");
|
new ClassPathXmlApplicationContext("org/springframework/scripting/bsh/bshBrokenContext.xml");
|
||||||
fail("Must throw exception for broken script file");
|
fail("Must throw exception for broken script file");
|
||||||
@@ -200,7 +201,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void scriptThatCompilesButIsJustPlainBad() throws Exception {
|
public void scriptThatCompilesButIsJustPlainBad() throws IOException {
|
||||||
ScriptSource script = mock(ScriptSource.class);
|
ScriptSource script = mock(ScriptSource.class);
|
||||||
final String badScript = "String getMessage() { throw new IllegalArgumentException(); }";
|
final String badScript = "String getMessage() { throw new IllegalArgumentException(); }";
|
||||||
given(script.getScriptAsString()).willReturn(badScript);
|
given(script.getScriptAsString()).willReturn(badScript);
|
||||||
@@ -217,7 +218,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ctorWithNullScriptSourceLocator() throws Exception {
|
public void ctorWithNullScriptSourceLocator() {
|
||||||
try {
|
try {
|
||||||
new BshScriptFactory(null, Messenger.class);
|
new BshScriptFactory(null, Messenger.class);
|
||||||
fail("Must have thrown exception by this point.");
|
fail("Must have thrown exception by this point.");
|
||||||
@@ -227,9 +228,9 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ctorWithEmptyScriptSourceLocator() throws Exception {
|
public void ctorWithEmptyScriptSourceLocator() {
|
||||||
try {
|
try {
|
||||||
new BshScriptFactory("", new Class<?>[] {Messenger.class});
|
new BshScriptFactory("", Messenger.class);
|
||||||
fail("Must have thrown exception by this point.");
|
fail("Must have thrown exception by this point.");
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException expected) {
|
catch (IllegalArgumentException expected) {
|
||||||
@@ -237,9 +238,9 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ctorWithWhitespacedScriptSourceLocator() throws Exception {
|
public void ctorWithWhitespacedScriptSourceLocator() {
|
||||||
try {
|
try {
|
||||||
new BshScriptFactory("\n ", new Class<?>[] {Messenger.class});
|
new BshScriptFactory("\n ", Messenger.class);
|
||||||
fail("Must have thrown exception by this point.");
|
fail("Must have thrown exception by this point.");
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException expected) {
|
catch (IllegalArgumentException expected) {
|
||||||
@@ -247,7 +248,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resourceScriptFromTag() throws Exception {
|
public void resourceScriptFromTag() {
|
||||||
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
||||||
TestBean testBean = (TestBean) ctx.getBean("testBean");
|
TestBean testBean = (TestBean) ctx.getBean("testBean");
|
||||||
|
|
||||||
@@ -286,7 +287,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void prototypeScriptFromTag() throws Exception {
|
public void prototypeScriptFromTag() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
||||||
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||||
@@ -302,7 +303,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void inlineScriptFromTag() throws Exception {
|
public void inlineScriptFromTag() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
||||||
Calculator calculator = (Calculator) ctx.getBean("calculator");
|
Calculator calculator = (Calculator) ctx.getBean("calculator");
|
||||||
assertNotNull(calculator);
|
assertNotNull(calculator);
|
||||||
@@ -310,7 +311,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refreshableFromTag() throws Exception {
|
public void refreshableFromTag() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
||||||
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
|
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
|
||||||
assertEquals("Hello World!", messenger.getMessage());
|
assertEquals("Hello World!", messenger.getMessage());
|
||||||
@@ -318,7 +319,7 @@ public class BshScriptFactoryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void applicationEventListener() throws Exception {
|
public void applicationEventListener() {
|
||||||
ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
ApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
|
||||||
Messenger eventListener = (Messenger) ctx.getBean("eventListener");
|
Messenger eventListener = (Messenger) ctx.getBean("eventListener");
|
||||||
ctx.publishEvent(new MyEvent(ctx));
|
ctx.publishEvent(new MyEvent(ctx));
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||||
|
|
||||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd">
|
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd">
|
||||||
|
|
||||||
<lang:bsh id="messenger" script-source="classpath:org/springframework/scripting/bsh/Messenger.bsh"
|
<lang:bsh id="messenger" script-source="classpath:org/springframework/scripting/bsh/Messenger.bsh"
|
||||||
@@ -29,7 +28,7 @@
|
|||||||
</lang:bsh>
|
</lang:bsh>
|
||||||
|
|
||||||
<lang:bsh id="messengerByType" script-source="classpath:org/springframework/scripting/bsh/MessengerImpl.bsh"
|
<lang:bsh id="messengerByType" script-source="classpath:org/springframework/scripting/bsh/MessengerImpl.bsh"
|
||||||
autowire="byType" dependency-check="objects" init-method="init" destroy-method="destroy">
|
autowire="byType" init-method="init" destroy-method="destroy">
|
||||||
</lang:bsh>
|
</lang:bsh>
|
||||||
|
|
||||||
<lang:bsh id="messengerByName" script-source="classpath:org/springframework/scripting/bsh/MessengerImpl.bsh"
|
<lang:bsh id="messengerByName" script-source="classpath:org/springframework/scripting/bsh/MessengerImpl.bsh"
|
||||||
@@ -52,12 +51,12 @@
|
|||||||
<lang:property name="message" value="Hello World!"/>
|
<lang:property name="message" value="Hello World!"/>
|
||||||
</lang:bsh>
|
</lang:bsh>
|
||||||
|
|
||||||
<lang:bsh id="eventListener" script-interfaces="org.springframework.context.ApplicationListener,org.springframework.scripting.Messenger" >
|
<lang:bsh id="eventListener" script-interfaces="org.springframework.context.ApplicationListener,org.springframework.scripting.Messenger" >
|
||||||
<lang:inline-script><![CDATA[
|
<lang:inline-script><![CDATA[
|
||||||
int count;
|
int count;
|
||||||
void onApplicationEvent (org.springframework.context.ApplicationEvent event) { count++; System.out.println(event); }
|
void onApplicationEvent (org.springframework.context.ApplicationEvent event) { count++; System.out.println(event); }
|
||||||
String getMessage() { return "count=" + count; }
|
String getMessage() { return "count=" + count; }
|
||||||
]]></lang:inline-script>
|
]]></lang:inline-script>
|
||||||
</lang:bsh>
|
</lang:bsh>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
@@ -26,12 +26,12 @@ import org.springframework.core.convert.converter.ConverterRegistry;
|
|||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialization of {@link GenericConversionService} configured by default with
|
* A specialization of {@link GenericConversionService} configured by default
|
||||||
* converters appropriate for most environments.
|
* with converters appropriate for most environments.
|
||||||
*
|
*
|
||||||
* <p>Designed for direct instantiation but also exposes the static
|
* <p>Designed for direct instantiation but also exposes the static
|
||||||
* {@link #addDefaultConverters(ConverterRegistry)} utility method for ad hoc use against any
|
* {@link #addDefaultConverters(ConverterRegistry)} utility method for ad-hoc
|
||||||
* {@code ConverterRegistry} instance.
|
* use against any {@code ConverterRegistry} instance.
|
||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
@@ -55,6 +55,15 @@ public class DefaultConversionService extends GenericConversionService {
|
|||||||
private static volatile DefaultConversionService sharedInstance;
|
private static volatile DefaultConversionService sharedInstance;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new {@code DefaultConversionService} with the set of
|
||||||
|
* {@linkplain DefaultConversionService#addDefaultConverters(ConverterRegistry) default converters}.
|
||||||
|
*/
|
||||||
|
public DefaultConversionService() {
|
||||||
|
addDefaultConverters(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a shared default {@code ConversionService} instance,
|
* Return a shared default {@code ConversionService} instance,
|
||||||
* lazily building it once needed.
|
* lazily building it once needed.
|
||||||
@@ -77,22 +86,10 @@ public class DefaultConversionService extends GenericConversionService {
|
|||||||
return sharedInstance;
|
return sharedInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new {@code DefaultConversionService} with the set of
|
|
||||||
* {@linkplain DefaultConversionService#addDefaultConverters(ConverterRegistry) default converters}.
|
|
||||||
*/
|
|
||||||
public DefaultConversionService() {
|
|
||||||
addDefaultConverters(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// static utility methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add converters appropriate for most environments.
|
* Add converters appropriate for most environments.
|
||||||
* @param converterRegistry the registry of converters to add to (must also be castable to ConversionService,
|
* @param converterRegistry the registry of converters to add to
|
||||||
* e.g. being a {@link ConfigurableConversionService})
|
* (must also be castable to ConversionService, e.g. being a {@link ConfigurableConversionService})
|
||||||
* @throws ClassCastException if the given ConverterRegistry could not be cast to a ConversionService
|
* @throws ClassCastException if the given ConverterRegistry could not be cast to a ConversionService
|
||||||
*/
|
*/
|
||||||
public static void addDefaultConverters(ConverterRegistry converterRegistry) {
|
public static void addDefaultConverters(ConverterRegistry converterRegistry) {
|
||||||
@@ -113,9 +110,9 @@ public class DefaultConversionService extends GenericConversionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add collection converters.
|
* Add common collection converters.
|
||||||
* @param converterRegistry the registry of converters to add to (must also be castable to ConversionService,
|
* @param converterRegistry the registry of converters to add to
|
||||||
* e.g. being a {@link ConfigurableConversionService})
|
* (must also be castable to ConversionService, e.g. being a {@link ConfigurableConversionService})
|
||||||
* @throws ClassCastException if the given ConverterRegistry could not be cast to a ConversionService
|
* @throws ClassCastException if the given ConverterRegistry could not be cast to a ConversionService
|
||||||
* @since 4.2.3
|
* @since 4.2.3
|
||||||
*/
|
*/
|
||||||
@@ -146,9 +143,6 @@ public class DefaultConversionService extends GenericConversionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// internal helpers
|
|
||||||
|
|
||||||
private static void addScalarConverters(ConverterRegistry converterRegistry) {
|
private static void addScalarConverters(ConverterRegistry converterRegistry) {
|
||||||
converterRegistry.addConverterFactory(new NumberToNumberConverterFactory());
|
converterRegistry.addConverterFactory(new NumberToNumberConverterFactory());
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
@@ -222,6 +222,7 @@ public abstract class MockMvcRequestBuilders {
|
|||||||
return new MockMultipartHttpServletRequestBuilder(uri);
|
return new MockMultipartHttpServletRequestBuilder(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a {@link RequestBuilder} for an async dispatch from the
|
* Create a {@link RequestBuilder} for an async dispatch from the
|
||||||
* {@link MvcResult} of the request that started async processing.
|
* {@link MvcResult} of the request that started async processing.
|
||||||
|
|||||||
@@ -104,9 +104,10 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
|||||||
this.supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
|
this.supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
|
||||||
this.supportedMediaTypes.add(MediaType.MULTIPART_FORM_DATA);
|
this.supportedMediaTypes.add(MediaType.MULTIPART_FORM_DATA);
|
||||||
|
|
||||||
this.partConverters.add(new ByteArrayHttpMessageConverter());
|
|
||||||
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
|
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
|
||||||
stringHttpMessageConverter.setWriteAcceptCharset(false);
|
stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316
|
||||||
|
|
||||||
|
this.partConverters.add(new ByteArrayHttpMessageConverter());
|
||||||
this.partConverters.add(stringHttpMessageConverter);
|
this.partConverters.add(stringHttpMessageConverter);
|
||||||
this.partConverters.add(new ResourceHttpMessageConverter());
|
this.partConverters.add(new ResourceHttpMessageConverter());
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2017 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.
|
||||||
@@ -37,17 +37,22 @@ import org.springframework.util.ClassUtils;
|
|||||||
public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConverter {
|
public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConverter {
|
||||||
|
|
||||||
private static final boolean jaxb2Present =
|
private static final boolean jaxb2Present =
|
||||||
ClassUtils.isPresent("javax.xml.bind.Binder", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
|
ClassUtils.isPresent("javax.xml.bind.Binder",
|
||||||
|
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jackson2Present =
|
private static final boolean jackson2Present =
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", AllEncompassingFormHttpMessageConverter.class.getClassLoader()) &&
|
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper",
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
|
AllEncompassingFormHttpMessageConverter.class.getClassLoader()) &&
|
||||||
|
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator",
|
||||||
|
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jackson2XmlPresent =
|
private static final boolean jackson2XmlPresent =
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
|
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper",
|
||||||
|
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean gsonPresent =
|
private static final boolean gsonPresent =
|
||||||
ClassUtils.isPresent("com.google.gson.Gson", AllEncompassingFormHttpMessageConverter.class.getClassLoader());
|
ClassUtils.isPresent("com.google.gson.Gson",
|
||||||
|
AllEncompassingFormHttpMessageConverter.class.getClassLoader());
|
||||||
|
|
||||||
|
|
||||||
public AllEncompassingFormHttpMessageConverter() {
|
public AllEncompassingFormHttpMessageConverter() {
|
||||||
|
|||||||
@@ -122,20 +122,26 @@ import org.springframework.web.util.UriTemplateHandler;
|
|||||||
public class RestTemplate extends InterceptingHttpAccessor implements RestOperations {
|
public class RestTemplate extends InterceptingHttpAccessor implements RestOperations {
|
||||||
|
|
||||||
private static boolean romePresent =
|
private static boolean romePresent =
|
||||||
ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", RestTemplate.class.getClassLoader());
|
ClassUtils.isPresent("com.rometools.rome.feed.WireFeed",
|
||||||
|
RestTemplate.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jaxb2Present =
|
private static final boolean jaxb2Present =
|
||||||
ClassUtils.isPresent("javax.xml.bind.Binder", RestTemplate.class.getClassLoader());
|
ClassUtils.isPresent("javax.xml.bind.Binder",
|
||||||
|
RestTemplate.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jackson2Present =
|
private static final boolean jackson2Present =
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", RestTemplate.class.getClassLoader()) &&
|
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper",
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", RestTemplate.class.getClassLoader());
|
RestTemplate.class.getClassLoader()) &&
|
||||||
|
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator",
|
||||||
|
RestTemplate.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jackson2XmlPresent =
|
private static final boolean jackson2XmlPresent =
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", RestTemplate.class.getClassLoader());
|
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper",
|
||||||
|
RestTemplate.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean gsonPresent =
|
private static final boolean gsonPresent =
|
||||||
ClassUtils.isPresent("com.google.gson.Gson", RestTemplate.class.getClassLoader());
|
ClassUtils.isPresent("com.google.gson.Gson",
|
||||||
|
RestTemplate.class.getClassLoader());
|
||||||
|
|
||||||
|
|
||||||
private final List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
|
private final List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
|
||||||
@@ -215,7 +221,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the message body converters.
|
* Return the list of message body converters.
|
||||||
|
* <p>The returned {@link List} is active and may get appended to.
|
||||||
*/
|
*/
|
||||||
public List<HttpMessageConverter<?>> getMessageConverters() {
|
public List<HttpMessageConverter<?>> getMessageConverters() {
|
||||||
return this.messageConverters;
|
return this.messageConverters;
|
||||||
|
|||||||
@@ -156,23 +156,30 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
|||||||
public static final String CONTENT_NEGOTIATION_MANAGER_BEAN_NAME = "mvcContentNegotiationManager";
|
public static final String CONTENT_NEGOTIATION_MANAGER_BEAN_NAME = "mvcContentNegotiationManager";
|
||||||
|
|
||||||
private static final boolean javaxValidationPresent =
|
private static final boolean javaxValidationPresent =
|
||||||
ClassUtils.isPresent("javax.validation.Validator", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
ClassUtils.isPresent("javax.validation.Validator",
|
||||||
|
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||||
|
|
||||||
private static boolean romePresent =
|
private static boolean romePresent =
|
||||||
ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
ClassUtils.isPresent("com.rometools.rome.feed.WireFeed",
|
||||||
|
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jaxb2Present =
|
private static final boolean jaxb2Present =
|
||||||
ClassUtils.isPresent("javax.xml.bind.Binder", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
ClassUtils.isPresent("javax.xml.bind.Binder",
|
||||||
|
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jackson2Present =
|
private static final boolean jackson2Present =
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", AnnotationDrivenBeanDefinitionParser.class.getClassLoader()) &&
|
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper",
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
AnnotationDrivenBeanDefinitionParser.class.getClassLoader()) &&
|
||||||
|
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator",
|
||||||
|
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jackson2XmlPresent =
|
private static final boolean jackson2XmlPresent =
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper",
|
||||||
|
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean gsonPresent =
|
private static final boolean gsonPresent =
|
||||||
ClassUtils.isPresent("com.google.gson.Gson", AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
ClassUtils.isPresent("com.google.gson.Gson",
|
||||||
|
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -174,20 +174,26 @@ import org.springframework.web.util.UrlPathHelper;
|
|||||||
public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {
|
public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {
|
||||||
|
|
||||||
private static boolean romePresent =
|
private static boolean romePresent =
|
||||||
ClassUtils.isPresent("com.rometools.rome.feed.WireFeed", WebMvcConfigurationSupport.class.getClassLoader());
|
ClassUtils.isPresent("com.rometools.rome.feed.WireFeed",
|
||||||
|
WebMvcConfigurationSupport.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jaxb2Present =
|
private static final boolean jaxb2Present =
|
||||||
ClassUtils.isPresent("javax.xml.bind.Binder", WebMvcConfigurationSupport.class.getClassLoader());
|
ClassUtils.isPresent("javax.xml.bind.Binder",
|
||||||
|
WebMvcConfigurationSupport.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jackson2Present =
|
private static final boolean jackson2Present =
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", WebMvcConfigurationSupport.class.getClassLoader()) &&
|
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper",
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", WebMvcConfigurationSupport.class.getClassLoader());
|
WebMvcConfigurationSupport.class.getClassLoader()) &&
|
||||||
|
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator",
|
||||||
|
WebMvcConfigurationSupport.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean jackson2XmlPresent =
|
private static final boolean jackson2XmlPresent =
|
||||||
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper", WebMvcConfigurationSupport.class.getClassLoader());
|
ClassUtils.isPresent("com.fasterxml.jackson.dataformat.xml.XmlMapper",
|
||||||
|
WebMvcConfigurationSupport.class.getClassLoader());
|
||||||
|
|
||||||
private static final boolean gsonPresent =
|
private static final boolean gsonPresent =
|
||||||
ClassUtils.isPresent("com.google.gson.Gson", WebMvcConfigurationSupport.class.getClassLoader());
|
ClassUtils.isPresent("com.google.gson.Gson",
|
||||||
|
WebMvcConfigurationSupport.class.getClassLoader());
|
||||||
|
|
||||||
|
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user