Polishing
This commit is contained in:
parent
20c2ba35dc
commit
86b7118da8
|
@ -44,7 +44,7 @@ public class ListenableFutureCallbackRegistry<T> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given callback to this registry.
|
* Add the given callback to this registry.
|
||||||
* @param callback the callback to add
|
* @param callback the callback to add
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -67,7 +67,7 @@ public class ListenableFutureCallbackRegistry<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given success callback to this registry.
|
* Add the given success callback to this registry.
|
||||||
* @param callback the success callback to add
|
* @param callback the success callback to add
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +87,7 @@ public class ListenableFutureCallbackRegistry<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given failure callback to this registry.
|
* Add the given failure callback to this registry.
|
||||||
* @param callback the failure callback to add
|
* @param callback the failure callback to add
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
|
@ -107,8 +107,8 @@ public class ListenableFutureCallbackRegistry<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers a {@link ListenableFutureCallback#onSuccess(Object)} call on all
|
* Trigger a {@link ListenableFutureCallback#onSuccess(Object)} call on all
|
||||||
* added callbacks with the given result
|
* added callbacks with the given result.
|
||||||
* @param result the result to trigger the callbacks with
|
* @param result the result to trigger the callbacks with
|
||||||
*/
|
*/
|
||||||
public void success(T result) {
|
public void success(T result) {
|
||||||
|
@ -122,7 +122,7 @@ public class ListenableFutureCallbackRegistry<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
|
* Trigger a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
|
||||||
* added callbacks with the given {@code Throwable}.
|
* added callbacks with the given {@code Throwable}.
|
||||||
* @param ex the exception to trigger the callbacks with
|
* @param ex the exception to trigger the callbacks with
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,15 +18,11 @@ package org.springframework.util.concurrent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.junit.Assert.*;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
|
@ -35,7 +31,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
|
||||||
public class ListenableFutureTaskTests {
|
public class ListenableFutureTaskTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void success() throws ExecutionException, InterruptedException {
|
public void success() throws Exception {
|
||||||
final String s = "Hello World";
|
final String s = "Hello World";
|
||||||
Callable<String> callable = new Callable<String>() {
|
Callable<String> callable = new Callable<String>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,7 +45,6 @@ public class ListenableFutureTaskTests {
|
||||||
public void onSuccess(String result) {
|
public void onSuccess(String result) {
|
||||||
assertEquals(s, result);
|
assertEquals(s, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
fail(ex.getMessage());
|
fail(ex.getMessage());
|
||||||
|
@ -59,7 +54,7 @@ public class ListenableFutureTaskTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void failure() throws ExecutionException, InterruptedException {
|
public void failure() throws Exception {
|
||||||
final String s = "Hello World";
|
final String s = "Hello World";
|
||||||
Callable<String> callable = new Callable<String>() {
|
Callable<String> callable = new Callable<String>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,7 +68,6 @@ public class ListenableFutureTaskTests {
|
||||||
public void onSuccess(String result) {
|
public void onSuccess(String result) {
|
||||||
fail("onSuccess not expected");
|
fail("onSuccess not expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
assertEquals(s, ex.getMessage());
|
assertEquals(s, ex.getMessage());
|
||||||
|
@ -83,7 +77,7 @@ public class ListenableFutureTaskTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void successWithLambdas() throws ExecutionException, InterruptedException {
|
public void successWithLambdas() throws Exception {
|
||||||
final String s = "Hello World";
|
final String s = "Hello World";
|
||||||
Callable<String> callable = () -> s;
|
Callable<String> callable = () -> s;
|
||||||
SuccessCallback<String> successCallback = mock(SuccessCallback.class);
|
SuccessCallback<String> successCallback = mock(SuccessCallback.class);
|
||||||
|
@ -96,7 +90,7 @@ public class ListenableFutureTaskTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void failureWithLambdas() throws ExecutionException, InterruptedException {
|
public void failureWithLambdas() throws Exception {
|
||||||
final String s = "Hello World";
|
final String s = "Hello World";
|
||||||
IOException ex = new IOException(s);
|
IOException ex = new IOException(s);
|
||||||
Callable<String> callable = () -> {
|
Callable<String> callable = () -> {
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the STOMP message broker host.
|
* Return the STOMP message broker host.
|
||||||
*/
|
*/
|
||||||
public String getRelayHost() {
|
public String getRelayHost() {
|
||||||
return this.relayHost;
|
return this.relayHost;
|
||||||
|
@ -172,7 +172,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the STOMP message broker port.
|
* Return the STOMP message broker port.
|
||||||
*/
|
*/
|
||||||
public int getRelayPort() {
|
public int getRelayPort() {
|
||||||
return this.relayPort;
|
return this.relayPort;
|
||||||
|
@ -190,7 +190,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The interval, in milliseconds, at which the "system" connection will
|
* Return the interval, in milliseconds, at which the "system" connection will
|
||||||
* send heartbeats to the STOMP broker.
|
* send heartbeats to the STOMP broker.
|
||||||
*/
|
*/
|
||||||
public long getSystemHeartbeatSendInterval() {
|
public long getSystemHeartbeatSendInterval() {
|
||||||
|
@ -210,7 +210,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The interval, in milliseconds, at which the "system" connection expects
|
* Return the interval, in milliseconds, at which the "system" connection expects
|
||||||
* to receive heartbeats from the STOMP broker.
|
* to receive heartbeats from the STOMP broker.
|
||||||
*/
|
*/
|
||||||
public long getSystemHeartbeatReceiveInterval() {
|
public long getSystemHeartbeatReceiveInterval() {
|
||||||
|
@ -238,9 +238,9 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the clientPasscode to use to create connections to the STOMP broker on
|
* Set the client passcode to use to create connections to the STOMP broker on
|
||||||
* behalf of connected clients.
|
* behalf of connected clients.
|
||||||
* <p> By default this is set to "guest".
|
* <p>By default this is set to "guest".
|
||||||
* @see #setSystemPasscode
|
* @see #setSystemPasscode
|
||||||
*/
|
*/
|
||||||
public void setClientPasscode(String clientPasscode) {
|
public void setClientPasscode(String clientPasscode) {
|
||||||
|
@ -249,7 +249,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the configured passocde to use for connections to the STOMP broker on
|
* Return the configured passcode to use for connections to the STOMP broker on
|
||||||
* behalf of connected clients.
|
* behalf of connected clients.
|
||||||
* @see #getSystemPasscode()
|
* @see #getSystemPasscode()
|
||||||
*/
|
*/
|
||||||
|
@ -269,7 +269,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the login used for the shared "system" connection to the STOMP broker
|
* Return the login used for the shared "system" connection to the STOMP broker.
|
||||||
*/
|
*/
|
||||||
public String getSystemLogin() {
|
public String getSystemLogin() {
|
||||||
return this.systemLogin;
|
return this.systemLogin;
|
||||||
|
@ -286,7 +286,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the passcode used for the shared "system" connection to the STOMP broker
|
* Return the passcode used for the shared "system" connection to the STOMP broker.
|
||||||
*/
|
*/
|
||||||
public String getSystemPasscode() {
|
public String getSystemPasscode() {
|
||||||
return this.systemPasscode;
|
return this.systemPasscode;
|
||||||
|
@ -305,7 +305,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the configured virtual host value.
|
* Return the configured virtual host value.
|
||||||
*/
|
*/
|
||||||
public String getVirtualHost() {
|
public String getVirtualHost() {
|
||||||
return this.virtualHost;
|
return this.virtualHost;
|
||||||
|
@ -419,7 +419,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
"receive BrokerAvailabilityEvent's from an ApplicationListener Spring bean.");
|
"receive BrokerAvailabilityEvent's from an ApplicationListener Spring bean.");
|
||||||
}
|
}
|
||||||
SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(message.getHeaders());
|
SimpMessageType messageType = SimpMessageHeaderAccessor.getMessageType(message.getHeaders());
|
||||||
if (logger.isErrorEnabled() && messageType.equals(SimpMessageType.CONNECT)) {
|
if (logger.isErrorEnabled() && SimpMessageType.CONNECT.equals(messageType)) {
|
||||||
logger.error("Broker not active. Ignoring " + message);
|
logger.error("Broker not active. Ignoring " + message);
|
||||||
}
|
}
|
||||||
else if (logger.isDebugEnabled()) {
|
else if (logger.isDebugEnabled()) {
|
||||||
|
@ -464,7 +464,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
String destination = stompAccessor.getDestination();
|
String destination = stompAccessor.getDestination();
|
||||||
if ((command != null) && command.requiresDestination() && !checkDestinationPrefix(destination)) {
|
if (command != null && command.requiresDestination() && !checkDestinationPrefix(destination)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,12 +673,12 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleFailure(Throwable failure) {
|
public void handleFailure(Throwable ex) {
|
||||||
if (this.tcpConnection != null) {
|
if (this.tcpConnection != null) {
|
||||||
handleTcpConnectionFailure("transport failure.", failure);
|
handleTcpConnectionFailure("transport failure.", ex);
|
||||||
}
|
}
|
||||||
else if (logger.isErrorEnabled()) {
|
else if (logger.isErrorEnabled()) {
|
||||||
logger.error("Transport failure: " + failure);
|
logger.error("Transport failure: " + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
this.tcpConnection = null;
|
this.tcpConnection = null;
|
||||||
clearConnection();
|
clearConnection();
|
||||||
}
|
}
|
||||||
catch (Throwable t) {
|
catch (Throwable ex) {
|
||||||
// Shouldn't happen with connection reset beforehand
|
// Shouldn't happen with connection reset beforehand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -742,7 +742,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
(conn != null ? "before STOMP CONNECTED. " : "while inactive. ") +
|
(conn != null ? "before STOMP CONNECTED. " : "while inactive. ") +
|
||||||
"Consider subscribing to receive BrokerAvailabilityEvent's from " +
|
"Consider subscribing to receive BrokerAvailabilityEvent's from " +
|
||||||
"an ApplicationListener Spring bean. Dropped " +
|
"an ApplicationListener Spring bean. Dropped " +
|
||||||
accessor.getShortLogMessage((byte[]) message.getPayload()));
|
accessor.getShortLogMessage(message.getPayload()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,8 +842,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleTcpConnectionFailure(String error, Throwable t) {
|
protected void handleTcpConnectionFailure(String errorMessage, Throwable ex) {
|
||||||
super.handleTcpConnectionFailure(error, t);
|
super.handleTcpConnectionFailure(errorMessage, ex);
|
||||||
publishBrokerUnavailableEvent();
|
publishBrokerUnavailableEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2014 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.
|
||||||
|
@ -138,20 +138,20 @@ public class HttpEntity<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return ObjectUtils.nullSafeHashCode(this.headers) * 29 + ObjectUtils.nullSafeHashCode(this.body);
|
return (ObjectUtils.nullSafeHashCode(this.headers) * 29 + ObjectUtils.nullSafeHashCode(this.body));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder("<");
|
StringBuilder builder = new StringBuilder("<");
|
||||||
if (body != null) {
|
if (this.body != null) {
|
||||||
builder.append(body);
|
builder.append(this.body);
|
||||||
if (headers != null) {
|
if (this.headers != null) {
|
||||||
builder.append(',');
|
builder.append(',');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (headers != null) {
|
if (this.headers != null) {
|
||||||
builder.append(headers);
|
builder.append(this.headers);
|
||||||
}
|
}
|
||||||
builder.append('>');
|
builder.append('>');
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|
|
@ -128,20 +128,20 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof RequestEntity)) {
|
if (!(other instanceof RequestEntity) || !super.equals(other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RequestEntity<?> otherEntity = (RequestEntity<?>) other;
|
RequestEntity<?> otherEntity = (RequestEntity<?>) other;
|
||||||
return (ObjectUtils.nullSafeEquals(this.method, otherEntity.method) &&
|
return (ObjectUtils.nullSafeEquals(this.method, otherEntity.method) &&
|
||||||
ObjectUtils.nullSafeEquals(this.url, otherEntity.url) &&
|
ObjectUtils.nullSafeEquals(this.url, otherEntity.url));
|
||||||
super.equals(other));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return 29 * super.hashCode() +
|
int hashCode = super.hashCode();
|
||||||
29 * ObjectUtils.nullSafeHashCode(this.method) +
|
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.method);
|
||||||
ObjectUtils.nullSafeHashCode(this.url);
|
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.url);
|
||||||
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -166,6 +166,7 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Static builder methods
|
// Static builder methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -422,6 +423,7 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||||
return method(HttpMethod.OPTIONS, url);
|
return method(HttpMethod.OPTIONS, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a builder that adds headers to the request entity.
|
* Defines a builder that adds headers to the request entity.
|
||||||
* @param <B> the builder subclass
|
* @param <B> the builder subclass
|
||||||
|
@ -471,9 +473,9 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||||
* @see BodyBuilder#body(Object)
|
* @see BodyBuilder#body(Object)
|
||||||
*/
|
*/
|
||||||
RequestEntity<Void> build();
|
RequestEntity<Void> build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a builder that adds a body to the response entity.
|
* Defines a builder that adds a body to the response entity.
|
||||||
*/
|
*/
|
||||||
|
@ -504,9 +506,9 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||||
* @return the built request entity
|
* @return the built request entity
|
||||||
*/
|
*/
|
||||||
<T> RequestEntity<T> body(T body);
|
<T> RequestEntity<T> body(T body);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class DefaultBodyBuilder implements BodyBuilder {
|
private static class DefaultBodyBuilder implements BodyBuilder {
|
||||||
|
|
||||||
private final HttpMethod method;
|
private final HttpMethod method;
|
||||||
|
@ -515,7 +517,6 @@ public class RequestEntity<T> extends HttpEntity<T> {
|
||||||
|
|
||||||
private final HttpHeaders headers = new HttpHeaders();
|
private final HttpHeaders headers = new HttpHeaders();
|
||||||
|
|
||||||
|
|
||||||
public DefaultBodyBuilder(HttpMethod method, URI url) {
|
public DefaultBodyBuilder(HttpMethod method, URI url) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
|
|
@ -121,16 +121,16 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(other instanceof ResponseEntity)) {
|
if (!(other instanceof ResponseEntity) || !super.equals(other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ResponseEntity<?> otherEntity = (ResponseEntity<?>) other;
|
ResponseEntity<?> otherEntity = (ResponseEntity<?>) other;
|
||||||
return (ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode) && super.equals(other));
|
return ObjectUtils.nullSafeEquals(this.statusCode, otherEntity.statusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode);
|
return (super.hashCode() * 29 + ObjectUtils.nullSafeHashCode(this.statusCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2014 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.
|
||||||
|
@ -107,6 +107,7 @@ public interface RestOperations {
|
||||||
*/
|
*/
|
||||||
<T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException;
|
<T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException;
|
||||||
|
|
||||||
|
|
||||||
// HEAD
|
// HEAD
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,6 +135,7 @@ public interface RestOperations {
|
||||||
*/
|
*/
|
||||||
HttpHeaders headForHeaders(URI url) throws RestClientException;
|
HttpHeaders headForHeaders(URI url) throws RestClientException;
|
||||||
|
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,6 +268,7 @@ public interface RestOperations {
|
||||||
*/
|
*/
|
||||||
<T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException;
|
<T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException;
|
||||||
|
|
||||||
|
|
||||||
// PUT
|
// PUT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -302,6 +305,7 @@ public interface RestOperations {
|
||||||
*/
|
*/
|
||||||
void put(URI url, Object request) throws RestClientException;
|
void put(URI url, Object request) throws RestClientException;
|
||||||
|
|
||||||
|
|
||||||
// DELETE
|
// DELETE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -327,6 +331,7 @@ public interface RestOperations {
|
||||||
*/
|
*/
|
||||||
void delete(URI url) throws RestClientException;
|
void delete(URI url) throws RestClientException;
|
||||||
|
|
||||||
|
|
||||||
// OPTIONS
|
// OPTIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -354,6 +359,7 @@ public interface RestOperations {
|
||||||
*/
|
*/
|
||||||
Set<HttpMethod> optionsForAllow(URI url) throws RestClientException;
|
Set<HttpMethod> optionsForAllow(URI url) throws RestClientException;
|
||||||
|
|
||||||
|
|
||||||
// exchange
|
// exchange
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -403,12 +409,10 @@ public interface RestOperations {
|
||||||
* Execute the HTTP method to the given URI template, writing the given
|
* Execute the HTTP method to the given URI template, writing the given
|
||||||
* request entity to the request, and returns the response as {@link ResponseEntity}.
|
* request entity to the request, and returns the response as {@link ResponseEntity}.
|
||||||
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
|
||||||
*
|
|
||||||
* <pre class="code">
|
* <pre class="code">
|
||||||
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
|
||||||
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
|
||||||
* @param url the URL
|
* @param url the URL
|
||||||
* @param method the HTTP method (GET, POST, etc)
|
* @param method the HTTP method (GET, POST, etc)
|
||||||
* @param requestEntity the entity (headers and/or body) to write to the
|
* @param requestEntity the entity (headers and/or body) to write to the
|
||||||
|
@ -416,7 +420,7 @@ public interface RestOperations {
|
||||||
* @param responseType the type of the return value
|
* @param responseType the type of the return value
|
||||||
* @param uriVariables the variables to expand in the template
|
* @param uriVariables the variables to expand in the template
|
||||||
* @return the response as entity
|
* @return the response as entity
|
||||||
* @since 3.2.0
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
<T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> requestEntity,
|
<T> ResponseEntity<T> exchange(String url,HttpMethod method, HttpEntity<?> requestEntity,
|
||||||
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException;
|
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException;
|
||||||
|
@ -425,19 +429,17 @@ public interface RestOperations {
|
||||||
* Execute the HTTP method to the given URI template, writing the given
|
* Execute the HTTP method to the given URI template, writing the given
|
||||||
* request entity to the request, and returns the response as {@link ResponseEntity}.
|
* request entity to the request, and returns the response as {@link ResponseEntity}.
|
||||||
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
|
||||||
*
|
|
||||||
* <pre class="code">
|
* <pre class="code">
|
||||||
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
|
||||||
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
|
||||||
* @param url the URL
|
* @param url the URL
|
||||||
* @param method the HTTP method (GET, POST, etc)
|
* @param method the HTTP method (GET, POST, etc)
|
||||||
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
|
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
|
||||||
* @param responseType the type of the return value
|
* @param responseType the type of the return value
|
||||||
* @param uriVariables the variables to expand in the template
|
* @param uriVariables the variables to expand in the template
|
||||||
* @return the response as entity
|
* @return the response as entity
|
||||||
* @since 3.2.0
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
|
<T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||||
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
|
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException;
|
||||||
|
@ -446,18 +448,16 @@ public interface RestOperations {
|
||||||
* Execute the HTTP method to the given URI template, writing the given
|
* Execute the HTTP method to the given URI template, writing the given
|
||||||
* request entity to the request, and returns the response as {@link ResponseEntity}.
|
* request entity to the request, and returns the response as {@link ResponseEntity}.
|
||||||
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information:
|
||||||
*
|
|
||||||
* <pre class="code">
|
* <pre class="code">
|
||||||
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
|
* ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
|
||||||
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
* ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
|
||||||
* @param url the URL
|
* @param url the URL
|
||||||
* @param method the HTTP method (GET, POST, etc)
|
* @param method the HTTP method (GET, POST, etc)
|
||||||
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
|
* @param requestEntity the entity (headers and/or body) to write to the request, may be {@code null}
|
||||||
* @param responseType the type of the return value
|
* @param responseType the type of the return value
|
||||||
* @return the response as entity
|
* @return the response as entity
|
||||||
* @since 3.2.0
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
|
<T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
|
||||||
ParameterizedTypeReference<T> responseType) throws RestClientException;
|
ParameterizedTypeReference<T> responseType) throws RestClientException;
|
||||||
|
@ -466,40 +466,35 @@ public interface RestOperations {
|
||||||
* Execute the request specified in the given {@link RequestEntity} and return
|
* Execute the request specified in the given {@link RequestEntity} and return
|
||||||
* the response as {@link ResponseEntity}. Typically used in combination
|
* the response as {@link ResponseEntity}. Typically used in combination
|
||||||
* with the static builder methods on {@code RequestEntity}, for instance:
|
* with the static builder methods on {@code RequestEntity}, for instance:
|
||||||
*
|
|
||||||
* <pre class="code">
|
* <pre class="code">
|
||||||
* MyRequest body = ...
|
* MyRequest body = ...
|
||||||
* RequestEntity request = RequestEntity.post("http://example.com/{foo}", "bar").accept(MediaType.APPLICATION_JSON).body(body);
|
* RequestEntity request = RequestEntity.post("http://example.com/{foo}", "bar").accept(MediaType.APPLICATION_JSON).body(body);
|
||||||
* ResponseEntity<MyResponse> response = template.exchange(request, MyResponse.class);
|
* ResponseEntity<MyResponse> response = template.exchange(request, MyResponse.class);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
|
||||||
* @param requestEntity the entity to write to the request
|
* @param requestEntity the entity to write to the request
|
||||||
* @param responseType the type of the return value
|
* @param responseType the type of the return value
|
||||||
* @return the response as entity
|
* @return the response as entity
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
<T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity,
|
<T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType) throws RestClientException;
|
||||||
Class<T> responseType) throws RestClientException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the request specified in the given {@link RequestEntity} and return
|
* Execute the request specified in the given {@link RequestEntity} and return
|
||||||
* the response as {@link ResponseEntity}. The given
|
* the response as {@link ResponseEntity}. The given
|
||||||
* {@link ParameterizedTypeReference} is used to pass generic type information:
|
* {@link ParameterizedTypeReference} is used to pass generic type information:
|
||||||
*
|
|
||||||
* <pre class="code">
|
* <pre class="code">
|
||||||
* MyRequest body = ...
|
* MyRequest body = ...
|
||||||
* RequestEntity request = RequestEntity.post("http://example.com/{foo}", "bar").accept(MediaType.APPLICATION_JSON).body(body);
|
* RequestEntity request = RequestEntity.post("http://example.com/{foo}", "bar").accept(MediaType.APPLICATION_JSON).body(body);
|
||||||
* ParameterizedTypeReference<List<MyResponse>> myBean = new ParameterizedTypeReference<List<MyResponse>>() {};
|
* ParameterizedTypeReference<List<MyResponse>> myBean = new ParameterizedTypeReference<List<MyResponse>>() {};
|
||||||
* ResponseEntity<List<MyResponse>> response = template.exchange(request, myBean);
|
* ResponseEntity<List<MyResponse>> response = template.exchange(request, myBean);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
|
||||||
* @param requestEntity the entity to write to the request
|
* @param requestEntity the entity to write to the request
|
||||||
* @param responseType the type of the return value
|
* @param responseType the type of the return value
|
||||||
* @return the response as entity
|
* @return the response as entity
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
<T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity,
|
<T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
|
||||||
ParameterizedTypeReference<T> responseType) throws RestClientException;
|
throws RestClientException;
|
||||||
|
|
||||||
|
|
||||||
// general execution
|
// general execution
|
||||||
|
|
|
@ -269,6 +269,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||||
return execute(url, HttpMethod.GET, requestCallback, responseExtractor);
|
return execute(url, HttpMethod.GET, requestCallback, responseExtractor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// HEAD
|
// HEAD
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -286,6 +287,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||||
return execute(url, HttpMethod.HEAD, null, headersExtractor());
|
return execute(url, HttpMethod.HEAD, null, headersExtractor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -362,6 +364,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||||
return execute(url, HttpMethod.POST, requestCallback, responseExtractor);
|
return execute(url, HttpMethod.POST, requestCallback, responseExtractor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// PUT
|
// PUT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -382,6 +385,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||||
execute(url, HttpMethod.PUT, requestCallback, null);
|
execute(url, HttpMethod.PUT, requestCallback, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// DELETE
|
// DELETE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -399,6 +403,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||||
execute(url, HttpMethod.DELETE, null, null);
|
execute(url, HttpMethod.DELETE, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// OPTIONS
|
// OPTIONS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -422,6 +427,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||||
return headers.getAllow();
|
return headers.getAllow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// exchange
|
// exchange
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -148,8 +148,9 @@ 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 = ClassUtils.isPresent(
|
private static final boolean javaxValidationPresent =
|
||||||
"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());
|
||||||
|
|
||||||
|
@ -532,12 +533,14 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
messageConverters.add(createConverterDefinition(AtomFeedHttpMessageConverter.class, source));
|
messageConverters.add(createConverterDefinition(AtomFeedHttpMessageConverter.class, source));
|
||||||
messageConverters.add(createConverterDefinition(RssChannelHttpMessageConverter.class, source));
|
messageConverters.add(createConverterDefinition(RssChannelHttpMessageConverter.class, source));
|
||||||
}
|
}
|
||||||
if(jackson2XmlPresent) {
|
|
||||||
|
if (jackson2XmlPresent) {
|
||||||
messageConverters.add(createConverterDefinition(MappingJackson2XmlHttpMessageConverter.class, source));
|
messageConverters.add(createConverterDefinition(MappingJackson2XmlHttpMessageConverter.class, source));
|
||||||
}
|
}
|
||||||
else if (jaxb2Present) {
|
else if (jaxb2Present) {
|
||||||
messageConverters.add(createConverterDefinition(Jaxb2RootElementHttpMessageConverter.class, source));
|
messageConverters.add(createConverterDefinition(Jaxb2RootElementHttpMessageConverter.class, source));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jackson2Present) {
|
if (jackson2Present) {
|
||||||
messageConverters.add(createConverterDefinition(MappingJackson2HttpMessageConverter.class, source));
|
messageConverters.add(createConverterDefinition(MappingJackson2HttpMessageConverter.class, source));
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@ import org.springframework.web.servlet.resource.VersionResourceResolver;
|
||||||
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a
|
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser} that parses a
|
||||||
* {@code resources} element to register a {@link ResourceHttpRequestHandler} and
|
* {@code resources} element to register a {@link ResourceHttpRequestHandler} and
|
||||||
* register a {@link SimpleUrlHandlerMapping} for mapping resource requests,
|
* register a {@link SimpleUrlHandlerMapping} for mapping resource requests,
|
||||||
* and a {@link HttpRequestHandlerAdapter}.
|
* and a {@link HttpRequestHandlerAdapter}. Will also create a resource handling
|
||||||
* Will also create a resource handling chain with {@link ResourceResolver}s and {@link ResourceTransformer}s.
|
* chain with {@link ResourceResolver}s and {@link ResourceTransformer}s.
|
||||||
*
|
*
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @author Jeremy Grelle
|
* @author Jeremy Grelle
|
||||||
|
@ -62,11 +62,16 @@ import org.springframework.web.servlet.resource.VersionResourceResolver;
|
||||||
class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
private static final String RESOURCE_CHAIN_CACHE = "spring-resource-chain-cache";
|
private static final String RESOURCE_CHAIN_CACHE = "spring-resource-chain-cache";
|
||||||
|
|
||||||
private static final String VERSION_RESOLVER_ELEMENT = "version-resolver";
|
private static final String VERSION_RESOLVER_ELEMENT = "version-resolver";
|
||||||
|
|
||||||
private static final String VERSION_STRATEGY_ELEMENT = "version-strategy";
|
private static final String VERSION_STRATEGY_ELEMENT = "version-strategy";
|
||||||
|
|
||||||
private static final String FIXED_VERSION_STRATEGY_ELEMENT = "fixed-version-strategy";
|
private static final String FIXED_VERSION_STRATEGY_ELEMENT = "fixed-version-strategy";
|
||||||
|
|
||||||
private static final String CONTENT_VERSION_STRATEGY_ELEMENT = "content-version-strategy";
|
private static final String CONTENT_VERSION_STRATEGY_ELEMENT = "content-version-strategy";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||||
Object source = parserContext.extractSource(element);
|
Object source = parserContext.extractSource(element);
|
||||||
|
@ -129,7 +134,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
Element resourceChainElement = DomUtils.getChildElementByTagName(element, "resource-chain");
|
Element resourceChainElement = DomUtils.getChildElementByTagName(element, "resource-chain");
|
||||||
if(resourceChainElement != null) {
|
if (resourceChainElement != null) {
|
||||||
parseResourceChain(resourceHandlerDef, parserContext, resourceChainElement, source);
|
parseResourceChain(resourceHandlerDef, parserContext, resourceChainElement, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +157,8 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
resourceTransformers.setSource(source);
|
resourceTransformers.setSource(source);
|
||||||
|
|
||||||
parseResourceCache(resourceResolvers, resourceTransformers, element, source);
|
parseResourceCache(resourceResolvers, resourceTransformers, element, source);
|
||||||
parseResourceResolversTransformers(isAutoRegistration, resourceResolvers
|
parseResourceResolversTransformers(isAutoRegistration, resourceResolvers, resourceTransformers,
|
||||||
, resourceTransformers, parserContext, element, source);
|
parserContext, element, source);
|
||||||
|
|
||||||
if (!resourceResolvers.isEmpty()) {
|
if (!resourceResolvers.isEmpty()) {
|
||||||
resourceHandlerDef.getPropertyValues().add("resourceResolvers", resourceResolvers);
|
resourceHandlerDef.getPropertyValues().add("resourceResolvers", resourceResolvers);
|
||||||
|
@ -164,11 +169,10 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseResourceCache(ManagedList<? super Object> resourceResolvers,
|
private void parseResourceCache(ManagedList<? super Object> resourceResolvers,
|
||||||
ManagedList<? super Object> resourceTransformers,
|
ManagedList<? super Object> resourceTransformers, Element element, Object source) {
|
||||||
Element element, Object source) {
|
|
||||||
|
|
||||||
Element resourceCacheElement = DomUtils.getChildElementByTagName(element, "resource-cache");
|
Element resourceCacheElement = DomUtils.getChildElementByTagName(element, "resource-cache");
|
||||||
if(resourceCacheElement != null) {
|
if (resourceCacheElement != null) {
|
||||||
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
|
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
|
||||||
|
|
||||||
RootBeanDefinition cachingResolverDef = new RootBeanDefinition(CachingResourceResolver.class);
|
RootBeanDefinition cachingResolverDef = new RootBeanDefinition(CachingResourceResolver.class);
|
||||||
|
@ -191,7 +195,6 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
else {
|
else {
|
||||||
ConstructorArgumentValues cacheCavs = new ConstructorArgumentValues();
|
ConstructorArgumentValues cacheCavs = new ConstructorArgumentValues();
|
||||||
cacheCavs.addIndexedArgumentValue(0, RESOURCE_CHAIN_CACHE);
|
cacheCavs.addIndexedArgumentValue(0, RESOURCE_CHAIN_CACHE);
|
||||||
|
|
||||||
RootBeanDefinition cacheDef = new RootBeanDefinition(ConcurrentMapCache.class);
|
RootBeanDefinition cacheDef = new RootBeanDefinition(ConcurrentMapCache.class);
|
||||||
cacheDef.setSource(source);
|
cacheDef.setSource(source);
|
||||||
cacheDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
cacheDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
|
@ -211,25 +214,25 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
Element resolversElement = DomUtils.getChildElementByTagName(element, "resolvers");
|
Element resolversElement = DomUtils.getChildElementByTagName(element, "resolvers");
|
||||||
if (resolversElement != null) {
|
if (resolversElement != null) {
|
||||||
for (Element beanElement : DomUtils.getChildElements(resolversElement)) {
|
for (Element beanElement : DomUtils.getChildElements(resolversElement)) {
|
||||||
if(VERSION_RESOLVER_ELEMENT.equals(beanElement.getLocalName())) {
|
if (VERSION_RESOLVER_ELEMENT.equals(beanElement.getLocalName())) {
|
||||||
RootBeanDefinition versionResolverDef = parseVersionResolver(parserContext, beanElement, source);
|
RootBeanDefinition versionResolverDef = parseVersionResolver(parserContext, beanElement, source);
|
||||||
versionResolverDef.setSource(source);
|
versionResolverDef.setSource(source);
|
||||||
resourceResolvers.add(versionResolverDef);
|
resourceResolvers.add(versionResolverDef);
|
||||||
|
if (isAutoRegistration) {
|
||||||
if(isAutoRegistration) {
|
|
||||||
RootBeanDefinition cssLinkTransformerDef = new RootBeanDefinition(CssLinkResourceTransformer.class);
|
RootBeanDefinition cssLinkTransformerDef = new RootBeanDefinition(CssLinkResourceTransformer.class);
|
||||||
cssLinkTransformerDef.setSource(source);
|
cssLinkTransformerDef.setSource(source);
|
||||||
cssLinkTransformerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
cssLinkTransformerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
resourceTransformers.add(cssLinkTransformerDef);
|
resourceTransformers.add(cssLinkTransformerDef);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Object object = parserContext.getDelegate().parsePropertySubElement(beanElement, null);
|
Object object = parserContext.getDelegate().parsePropertySubElement(beanElement, null);
|
||||||
resourceResolvers.add(object);
|
resourceResolvers.add(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isAutoRegistration) {
|
if (isAutoRegistration) {
|
||||||
RootBeanDefinition pathResolverDef = new RootBeanDefinition(PathResourceResolver.class);
|
RootBeanDefinition pathResolverDef = new RootBeanDefinition(PathResourceResolver.class);
|
||||||
pathResolverDef.setSource(source);
|
pathResolverDef.setSource(source);
|
||||||
pathResolverDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
pathResolverDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
|
@ -256,7 +259,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
for (Element beanElement : DomUtils.getChildElements(element)) {
|
for (Element beanElement : DomUtils.getChildElements(element)) {
|
||||||
String[] patterns = StringUtils.commaDelimitedListToStringArray(beanElement.getAttribute("patterns"));
|
String[] patterns = StringUtils.commaDelimitedListToStringArray(beanElement.getAttribute("patterns"));
|
||||||
Object strategy = null;
|
Object strategy = null;
|
||||||
if(FIXED_VERSION_STRATEGY_ELEMENT.equals(beanElement.getLocalName())) {
|
if (FIXED_VERSION_STRATEGY_ELEMENT.equals(beanElement.getLocalName())) {
|
||||||
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
|
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
|
||||||
cavs.addIndexedArgumentValue(0, beanElement.getAttribute("version"));
|
cavs.addIndexedArgumentValue(0, beanElement.getAttribute("version"));
|
||||||
RootBeanDefinition strategyDef = new RootBeanDefinition(FixedVersionStrategy.class);
|
RootBeanDefinition strategyDef = new RootBeanDefinition(FixedVersionStrategy.class);
|
||||||
|
@ -282,4 +285,5 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
return versionResolverDef;
|
return versionResolverDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,10 @@ import org.springframework.web.context.ServletContextAware;
|
||||||
import org.springframework.web.method.support.CompositeUriComponentsContributor;
|
import org.springframework.web.method.support.CompositeUriComponentsContributor;
|
||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||||
import org.springframework.web.servlet.*;
|
import org.springframework.web.servlet.HandlerAdapter;
|
||||||
|
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||||
|
import org.springframework.web.servlet.HandlerMapping;
|
||||||
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
||||||
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
|
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
|
||||||
import org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor;
|
import org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor;
|
||||||
|
@ -657,12 +660,14 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||||
messageConverters.add(new AtomFeedHttpMessageConverter());
|
messageConverters.add(new AtomFeedHttpMessageConverter());
|
||||||
messageConverters.add(new RssChannelHttpMessageConverter());
|
messageConverters.add(new RssChannelHttpMessageConverter());
|
||||||
}
|
}
|
||||||
if(jackson2XmlPresent) {
|
|
||||||
|
if (jackson2XmlPresent) {
|
||||||
messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
|
messageConverters.add(new MappingJackson2XmlHttpMessageConverter());
|
||||||
}
|
}
|
||||||
else if (jaxb2Present) {
|
else if (jaxb2Present) {
|
||||||
messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
|
messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jackson2Present) {
|
if (jackson2Present) {
|
||||||
messageConverters.add(new MappingJackson2HttpMessageConverter());
|
messageConverters.add(new MappingJackson2HttpMessageConverter());
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,8 @@ public interface HandlerMethodMappingNamingStrategy<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the name for the given HandlerMethod and mapping.
|
* Determine the name for the given HandlerMethod and mapping.
|
||||||
*
|
|
||||||
* @param handlerMethod the handler method
|
* @param handlerMethod the handler method
|
||||||
* @param mapping the mapping
|
* @param mapping the mapping
|
||||||
*
|
|
||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
String getName(HandlerMethod handlerMethod, T mapping);
|
String getName(HandlerMethod handlerMethod, T mapping);
|
||||||
|
|
|
@ -81,15 +81,12 @@ public class ParameterizableViewController extends AbstractController {
|
||||||
/**
|
/**
|
||||||
* Configure the HTTP status code that this controller should set on the
|
* Configure the HTTP status code that this controller should set on the
|
||||||
* response.
|
* response.
|
||||||
*
|
|
||||||
* <p>When a "redirect:" prefixed view name is configured, there is no need
|
* <p>When a "redirect:" prefixed view name is configured, there is no need
|
||||||
* to set this property since RedirectView will do that. However this property
|
* to set this property since RedirectView will do that. However this property
|
||||||
* may still be used to override the 3xx status code of {@code RedirectView}.
|
* may still be used to override the 3xx status code of {@code RedirectView}.
|
||||||
* For full control over redirecting provide a {@code RedirectView} instance.
|
* For full control over redirecting provide a {@code RedirectView} instance.
|
||||||
*
|
|
||||||
* <p>If the status code is 204 and no view is configured, the request is
|
* <p>If the status code is 204 and no view is configured, the request is
|
||||||
* fully handled within the controller.
|
* fully handled within the controller.
|
||||||
*
|
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public void setStatusCode(HttpStatus statusCode) {
|
public void setStatusCode(HttpStatus statusCode) {
|
||||||
|
@ -123,12 +120,11 @@ public class ParameterizableViewController extends AbstractController {
|
||||||
return this.statusOnly;
|
return this.statusOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a ModelAndView object with the specified view name.
|
* Return a ModelAndView object with the specified view name.
|
||||||
*
|
|
||||||
* <p>The content of the {@link RequestContextUtils#getInputFlashMap
|
* <p>The content of the {@link RequestContextUtils#getInputFlashMap
|
||||||
* "input" FlashMap} is also added to the model.
|
* "input" FlashMap} is also added to the model.
|
||||||
*
|
|
||||||
* @see #getViewName()
|
* @see #getViewName()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@ -382,10 +381,8 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
protected void appendCurrentQueryParams(StringBuilder targetUrl, HttpServletRequest request) {
|
protected void appendCurrentQueryParams(StringBuilder targetUrl, HttpServletRequest request) {
|
||||||
|
|
||||||
String query = request.getQueryString();
|
String query = request.getQueryString();
|
||||||
if (StringUtils.hasText(query)) {
|
if (StringUtils.hasText(query)) {
|
||||||
|
|
||||||
// Extract anchor fragment, if any.
|
// Extract anchor fragment, if any.
|
||||||
String fragment = null;
|
String fragment = null;
|
||||||
int anchorIndex = targetUrl.indexOf("#");
|
int anchorIndex = targetUrl.indexOf("#");
|
||||||
|
@ -400,7 +397,6 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||||
else {
|
else {
|
||||||
targetUrl.append('&').append(query);
|
targetUrl.append('&').append(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append anchor fragment, if any, to end of URL.
|
// Append anchor fragment, if any, to end of URL.
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
targetUrl.append(fragment);
|
targetUrl.append(fragment);
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
|
|
||||||
package org.springframework.web.servlet.view;
|
package org.springframework.web.servlet.view;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
@ -26,12 +32,6 @@ import org.springframework.web.context.ServletContextAware;
|
||||||
import org.springframework.web.servlet.View;
|
import org.springframework.web.servlet.View;
|
||||||
import org.springframework.web.servlet.ViewResolver;
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link org.springframework.web.servlet.ViewResolver} that delegates to others.
|
* A {@link org.springframework.web.servlet.ViewResolver} that delegates to others.
|
||||||
*
|
*
|
||||||
|
|
|
@ -82,6 +82,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
|
||||||
super(new ObjectMapper(), DEFAULT_CONTENT_TYPE);
|
super(new ObjectMapper(), DEFAULT_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a custom prefix to use for this view's JSON output.
|
* Specify a custom prefix to use for this view's JSON output.
|
||||||
* Default is none.
|
* Default is none.
|
||||||
|
@ -207,9 +208,10 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
|
||||||
Object value = super.filterAndWrapModel(model, request);
|
Object value = super.filterAndWrapModel(model, request);
|
||||||
String jsonpParameterValue = getJsonpParameterValue(request);
|
String jsonpParameterValue = getJsonpParameterValue(request);
|
||||||
if (jsonpParameterValue != null) {
|
if (jsonpParameterValue != null) {
|
||||||
if(value instanceof MappingJacksonValue) {
|
if (value instanceof MappingJacksonValue) {
|
||||||
((MappingJacksonValue) value).setJsonpFunction(jsonpParameterValue);
|
((MappingJacksonValue) value).setJsonpFunction(jsonpParameterValue);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
MappingJacksonValue container = new MappingJacksonValue(value);
|
MappingJacksonValue container = new MappingJacksonValue(value);
|
||||||
container.setJsonpFunction(jsonpParameterValue);
|
container.setJsonpFunction(jsonpParameterValue);
|
||||||
value = container;
|
value = container;
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class MappingJackson2XmlView extends AbstractJackson2View {
|
||||||
super(new XmlMapper(), DEFAULT_CONTENT_TYPE);
|
super(new XmlMapper(), DEFAULT_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -73,11 +74,11 @@ public class MappingJackson2XmlView extends AbstractJackson2View {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Model contains no object with key [" + this.modelKey + "]");
|
"Model contains no object with key [" + this.modelKey + "]");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
for (Map.Entry<String, Object> entry : model.entrySet()) {
|
for (Map.Entry<String, Object> entry : model.entrySet()) {
|
||||||
if (!(entry.getValue() instanceof BindingResult) &&
|
if (!(entry.getValue() instanceof BindingResult) && !entry.getKey().equals(JsonView.class.getName())) {
|
||||||
!entry.getKey().equals(JsonView.class.getName())) {
|
if (value != null) {
|
||||||
if(value != null) {
|
|
||||||
throw new IllegalStateException("Model contains more than one object to render, only one is supported");
|
throw new IllegalStateException("Model contains more than one object to render, only one is supported");
|
||||||
}
|
}
|
||||||
value = entry.getValue();
|
value = entry.getValue();
|
||||||
|
|
|
@ -23,9 +23,9 @@ import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.util.concurrent.ListenableFuture;
|
import org.springframework.util.concurrent.ListenableFuture;
|
||||||
import org.springframework.util.concurrent.ListenableFutureCallback;
|
import org.springframework.util.concurrent.ListenableFutureCallback;
|
||||||
import org.springframework.web.socket.WebSocketHandler;
|
import org.springframework.web.socket.WebSocketHandler;
|
||||||
|
import org.springframework.web.socket.WebSocketHttpHeaders;
|
||||||
import org.springframework.web.socket.WebSocketSession;
|
import org.springframework.web.socket.WebSocketSession;
|
||||||
import org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator;
|
import org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator;
|
||||||
import org.springframework.web.socket.WebSocketHttpHeaders;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A WebSocket connection manager that is given a URI, a {@link WebSocketClient}, and a
|
* A WebSocket connection manager that is given a URI, a {@link WebSocketClient}, and a
|
||||||
|
|
Loading…
Reference in New Issue