org.springframework.http.converter.xml.SourceHttpMessageConverter Java Examples

The following examples show how to use org.springframework.http.converter.xml.SourceHttpMessageConverter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouterFunctionMapping.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Initializes a default set of {@linkplain HttpMessageConverter message converters}.
 */
private void initMessageConverters() {
	List<HttpMessageConverter<?>> messageConverters = new ArrayList<>(4);
	messageConverters.add(new ByteArrayHttpMessageConverter());
	messageConverters.add(new StringHttpMessageConverter());

	try {
		messageConverters.add(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}
	messageConverters.add(new AllEncompassingFormHttpMessageConverter());

	this.messageConverters = messageConverters;
}
 
Example #2
Source File: AllEncompassingFormHttpMessageConverter.java    From onetwo with Apache License 2.0 6 votes vote down vote up
public AllEncompassingFormHttpMessageConverter() {
	addPartConverter(new SourceHttpMessageConverter<>());

	if (jaxb2Present && !jackson2XmlPresent) {
		addPartConverter(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		addPartConverter(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		addPartConverter(new GsonHttpMessageConverter());
	}
	/*else if (jsonbPresent) {
		addPartConverter(new JsonbHttpMessageConverter());
	}*/

	if (jackson2XmlPresent) {
		addPartConverter(new MappingJackson2XmlHttpMessageConverter());
	}

	/*if (jackson2SmilePresent) {
		addPartConverter(new MappingJackson2SmileHttpMessageConverter());
	}*/
}
 
Example #3
Source File: WebConfiguration.java    From java-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
	StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
	stringConverter.setWriteAcceptCharset(false);

	converters.add(new ByteArrayHttpMessageConverter());
	converters.add(stringConverter);
	converters.add(new ResourceHttpMessageConverter());
	converters.add(new SourceHttpMessageConverter<Source>());
	converters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #4
Source File: AllEncompassingFormHttpMessageConverter.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
public AllEncompassingFormHttpMessageConverter() {
	addPartConverter(new SourceHttpMessageConverter<Source>());

	if (jaxb2Present && !jackson2Present) {
		addPartConverter(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		addPartConverter(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		addPartConverter(new GsonHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		addPartConverter(new MappingJackson2XmlHttpMessageConverter());
	}
}
 
Example #5
Source File: AllEncompassingFormHttpMessageConverter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public AllEncompassingFormHttpMessageConverter() {
	addPartConverter(new SourceHttpMessageConverter<Source>());

	if (jaxb2Present && !jackson2XmlPresent) {
		addPartConverter(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		addPartConverter(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		addPartConverter(new GsonHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		addPartConverter(new MappingJackson2XmlHttpMessageConverter());
	}
}
 
Example #6
Source File: HttpClientConfig.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
private List<HttpMessageConverter<?>> converters() {
  List<HttpMessageConverter<?>> result = Lists.newArrayList();
  result.add(new ByteArrayHttpMessageConverter());
  result.add(new StringHttpMessageConverter());
  result.add(new ResourceHttpMessageConverter());
  result.add(new SourceHttpMessageConverter<>());
  result.add(new AllEncompassingFormHttpMessageConverter());
  result.add(new Jaxb2RootElementHttpMessageConverter());
  result.add(gsonHttpMessageConverter);
  return result;
}
 
Example #7
Source File: DefaultAuthServiceImpl.java    From SENS with GNU General Public License v3.0 5 votes vote down vote up
public static RestTemplate getRestTemplate() {// 手动添加
    SimpleClientHttpRequestFactory requestFactory=new SimpleClientHttpRequestFactory();
    requestFactory.setReadTimeout(120000);
    List<HttpMessageConverter<?>> messageConverters = new LinkedList<>();
    messageConverters.add(new ByteArrayHttpMessageConverter());
    messageConverters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
    messageConverters.add(new ResourceHttpMessageConverter());
    messageConverters.add(new SourceHttpMessageConverter<Source>());
    messageConverters.add(new AllEncompassingFormHttpMessageConverter());
    messageConverters.add(new MappingJackson2HttpMessageConverter());
    RestTemplate restTemplate=new RestTemplate(messageConverters);
    restTemplate.setRequestFactory(requestFactory);
    return restTemplate;
}
 
Example #8
Source File: RestTemplateFactory.java    From sdk-rest with MIT License 5 votes vote down vote up
private static RestTemplate createRestTemplate() {
	List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
	messageConverters.add(new ByteArrayHttpMessageConverter());
	messageConverters.add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
	messageConverters.add(new ResourceHttpMessageConverter());
	messageConverters.add(new SourceHttpMessageConverter<Source>());
	messageConverters.add(new AllEncompassingFormHttpMessageConverter());
	messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
	messageConverters.add(new MappingJackson2HttpMessageConverter());

	return new RestTemplate(messageConverters);
}
 
Example #9
Source File: WebConfig.java    From nakadi with MIT License 5 votes vote down vote up
@Override
protected void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
    final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
    stringConverter.setWriteAcceptCharset(false);

    converters.add(new ByteArrayHttpMessageConverter());
    converters.add(stringConverter);
    converters.add(new ResourceHttpMessageConverter());
    converters.add(new SourceHttpMessageConverter<>());

    converters.add(mappingJackson2HttpMessageConverter());
    super.configureMessageConverters(converters);
}
 
Example #10
Source File: SpringParameterProvider.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
private List<HttpMessageConverter<?>> getHttpMessageConverters() {
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
    stringHttpMessageConverter.setWriteAcceptCharset(false);  // see SPR-7316

    List<HttpMessageConverter<?>> converters = new ArrayList<>(4);
    converters.add(new ByteArrayHttpMessageConverter());
    converters.add(stringHttpMessageConverter);
    converters.add(new SourceHttpMessageConverter<>());
    converters.add(new AllEncompassingFormHttpMessageConverter());

    return converters;
}
 
Example #11
Source File: RestTemplate.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new instance of the {@link RestTemplate} using default settings.
 * Default {@link HttpMessageConverter}s are initialized.
 */
public RestTemplate() {
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(new StringHttpMessageConverter());
	this.messageConverters.add(new ResourceHttpMessageConverter());
	this.messageConverters.add(new SourceHttpMessageConverter<Source>());
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());

	if (romePresent) {
		this.messageConverters.add(new AtomFeedHttpMessageConverter());
		this.messageConverters.add(new RssChannelHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
	}
	else if (jaxb2Present) {
		this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		this.messageConverters.add(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		this.messageConverters.add(new GsonHttpMessageConverter());
	}
}
 
Example #12
Source File: RequestMappingHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public RequestMappingHandlerAdapter() {
	StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
	stringHttpMessageConverter.setWriteAcceptCharset(false);  // see SPR-7316

	this.messageConverters = new ArrayList<HttpMessageConverter<?>>(4);
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(stringHttpMessageConverter);
	this.messageConverters.add(new SourceHttpMessageConverter<Source>());
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #13
Source File: ExceptionHandlerExceptionResolver.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public ExceptionHandlerExceptionResolver() {
	StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
	stringHttpMessageConverter.setWriteAcceptCharset(false); // See SPR-7316

	this.messageConverters = new ArrayList<HttpMessageConverter<?>>();
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(stringHttpMessageConverter);
	this.messageConverters.add(new SourceHttpMessageConverter<Source>());
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #14
Source File: AnnotationMethodHandlerAdapter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public AnnotationMethodHandlerAdapter() {
	// no restriction of HTTP methods by default
	super(false);

	// See SPR-7316
	StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
	stringHttpMessageConverter.setWriteAcceptCharset(false);
	this.messageConverters = new HttpMessageConverter<?>[] {
		new ByteArrayHttpMessageConverter(), stringHttpMessageConverter,
		new SourceHttpMessageConverter<Source>(),
		new org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter() };
}
 
Example #15
Source File: RestTemplate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new instance of the {@link RestTemplate} using default settings.
 * Default {@link HttpMessageConverter}s are initialized.
 */
public RestTemplate() {
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(new StringHttpMessageConverter());
	this.messageConverters.add(new ResourceHttpMessageConverter());
	this.messageConverters.add(new SourceHttpMessageConverter<Source>());
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());

	if (romePresent) {
		this.messageConverters.add(new AtomFeedHttpMessageConverter());
		this.messageConverters.add(new RssChannelHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
	}
	else if (jaxb2Present) {
		this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		this.messageConverters.add(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		this.messageConverters.add(new GsonHttpMessageConverter());
	}
}
 
Example #16
Source File: RequestMappingHandlerAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public RequestMappingHandlerAdapter() {
	StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
	stringHttpMessageConverter.setWriteAcceptCharset(false);  // see SPR-7316

	this.messageConverters = new ArrayList<HttpMessageConverter<?>>(4);
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(stringHttpMessageConverter);
	this.messageConverters.add(new SourceHttpMessageConverter<Source>());
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #17
Source File: ExceptionHandlerExceptionResolver.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ExceptionHandlerExceptionResolver() {
	StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
	stringHttpMessageConverter.setWriteAcceptCharset(false);  // see SPR-7316

	this.messageConverters = new ArrayList<HttpMessageConverter<?>>();
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(stringHttpMessageConverter);
	this.messageConverters.add(new SourceHttpMessageConverter<Source>());
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #18
Source File: AnnotationMethodHandlerAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AnnotationMethodHandlerAdapter() {
	// no restriction of HTTP methods by default
	super(false);

	// See SPR-7316
	StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
	stringHttpMessageConverter.setWriteAcceptCharset(false);
	this.messageConverters = new HttpMessageConverter<?>[] {
		new ByteArrayHttpMessageConverter(), stringHttpMessageConverter,
		new SourceHttpMessageConverter<Source>(),
		new org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter() };
}
 
Example #19
Source File: AllEncompassingFormHttpMessageConverter.java    From java-technology-stack with MIT License 5 votes vote down vote up
public AllEncompassingFormHttpMessageConverter() {
	try {
		addPartConverter(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}

	if (jaxb2Present && !jackson2XmlPresent) {
		addPartConverter(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		addPartConverter(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		addPartConverter(new GsonHttpMessageConverter());
	}
	else if (jsonbPresent) {
		addPartConverter(new JsonbHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		addPartConverter(new MappingJackson2XmlHttpMessageConverter());
	}

	if (jackson2SmilePresent) {
		addPartConverter(new MappingJackson2SmileHttpMessageConverter());
	}
}
 
Example #20
Source File: RequestMappingHandlerAdapter.java    From java-technology-stack with MIT License 5 votes vote down vote up
public RequestMappingHandlerAdapter() {
	StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
	stringHttpMessageConverter.setWriteAcceptCharset(false);  // see SPR-7316

	this.messageConverters = new ArrayList<>(4);
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(stringHttpMessageConverter);
	try {
		this.messageConverters.add(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #21
Source File: ExceptionHandlerExceptionResolver.java    From java-technology-stack with MIT License 5 votes vote down vote up
public ExceptionHandlerExceptionResolver() {
	StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
	stringHttpMessageConverter.setWriteAcceptCharset(false);  // see SPR-7316

	this.messageConverters = new ArrayList<>();
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(stringHttpMessageConverter);
	try {
		this.messageConverters.add(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #22
Source File: AllEncompassingFormHttpMessageConverter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public AllEncompassingFormHttpMessageConverter() {
	try {
		addPartConverter(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}

	if (jaxb2Present && !jackson2XmlPresent) {
		addPartConverter(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		addPartConverter(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		addPartConverter(new GsonHttpMessageConverter());
	}
	else if (jsonbPresent) {
		addPartConverter(new JsonbHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		addPartConverter(new MappingJackson2XmlHttpMessageConverter());
	}

	if (jackson2SmilePresent) {
		addPartConverter(new MappingJackson2SmileHttpMessageConverter());
	}
}
 
Example #23
Source File: RequestMappingHandlerAdapter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public RequestMappingHandlerAdapter() {
	this.messageConverters = new ArrayList<>(4);
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(new StringHttpMessageConverter());
	try {
		this.messageConverters.add(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #24
Source File: ExceptionHandlerExceptionResolver.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public ExceptionHandlerExceptionResolver() {
	this.messageConverters = new ArrayList<>();
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(new StringHttpMessageConverter());
	try {
		this.messageConverters.add(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
 
Example #25
Source File: WebMvcConfigurationSupport.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adds a set of default HttpMessageConverter instances to the given list.
 * Subclasses can call this method from {@link #configureMessageConverters(List)}.
 * @param messageConverters the list to add the default message converters to
 */
protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
	StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
	stringConverter.setWriteAcceptCharset(false);

	messageConverters.add(new ByteArrayHttpMessageConverter());
	messageConverters.add(stringConverter);
	messageConverters.add(new ResourceHttpMessageConverter());
	messageConverters.add(new SourceHttpMessageConverter<Source>());
	messageConverters.add(new AllEncompassingFormHttpMessageConverter());

	if (romePresent) {
		messageConverters.add(new AtomFeedHttpMessageConverter());
		messageConverters.add(new RssChannelHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		messageConverters.add(new MappingJackson2XmlHttpMessageConverter(
				Jackson2ObjectMapperBuilder.xml().applicationContext(this.applicationContext).build()));
	}
	else if (jaxb2Present) {
		messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		messageConverters.add(new MappingJackson2HttpMessageConverter(
				Jackson2ObjectMapperBuilder.json().applicationContext(this.applicationContext).build()));
	}
	else if (gsonPresent) {
		messageConverters.add(new GsonHttpMessageConverter());
	}
}
 
Example #26
Source File: RestTemplate.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Create a new instance of the {@link RestTemplate} using default settings.
 * Default {@link HttpMessageConverter HttpMessageConverters} are initialized.
 */
public RestTemplate() {
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(new StringHttpMessageConverter());
	this.messageConverters.add(new ResourceHttpMessageConverter(false));
	try {
		this.messageConverters.add(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());

	if (romePresent) {
		this.messageConverters.add(new AtomFeedHttpMessageConverter());
		this.messageConverters.add(new RssChannelHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
	}
	else if (jaxb2Present) {
		this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		this.messageConverters.add(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		this.messageConverters.add(new GsonHttpMessageConverter());
	}
	else if (jsonbPresent) {
		this.messageConverters.add(new JsonbHttpMessageConverter());
	}

	if (jackson2SmilePresent) {
		this.messageConverters.add(new MappingJackson2SmileHttpMessageConverter());
	}
	if (jackson2CborPresent) {
		this.messageConverters.add(new MappingJackson2CborHttpMessageConverter());
	}

	this.uriTemplateHandler = initUriTemplateHandler();
}
 
Example #27
Source File: RestTemplate.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Create a new instance of the {@link RestTemplate} using default settings.
 * Default {@link HttpMessageConverter HttpMessageConverters} are initialized.
 */
public RestTemplate() {
	this.messageConverters.add(new ByteArrayHttpMessageConverter());
	this.messageConverters.add(new StringHttpMessageConverter());
	this.messageConverters.add(new ResourceHttpMessageConverter(false));
	try {
		this.messageConverters.add(new SourceHttpMessageConverter<>());
	}
	catch (Error err) {
		// Ignore when no TransformerFactory implementation is available
	}
	this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());

	if (romePresent) {
		this.messageConverters.add(new AtomFeedHttpMessageConverter());
		this.messageConverters.add(new RssChannelHttpMessageConverter());
	}

	if (jackson2XmlPresent) {
		this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
	}
	else if (jaxb2Present) {
		this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
	}

	if (jackson2Present) {
		this.messageConverters.add(new MappingJackson2HttpMessageConverter());
	}
	else if (gsonPresent) {
		this.messageConverters.add(new GsonHttpMessageConverter());
	}
	else if (jsonbPresent) {
		this.messageConverters.add(new JsonbHttpMessageConverter());
	}

	if (jackson2SmilePresent) {
		this.messageConverters.add(new MappingJackson2SmileHttpMessageConverter());
	}
	if (jackson2CborPresent) {
		this.messageConverters.add(new MappingJackson2CborHttpMessageConverter());
	}

	this.uriTemplateHandler = initUriTemplateHandler();
}