Browse Source

Polishing

pull/642/head
Juergen Hoeller 12 years ago
parent
commit
d081a4530c
  1. 4
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java
  2. 14
      spring-web/src/main/java/org/springframework/http/HttpEntity.java
  3. 6
      spring-web/src/main/java/org/springframework/http/ResponseEntity.java
  4. 21
      spring-web/src/main/java/org/springframework/web/client/RestOperations.java
  5. 6
      spring-web/src/main/java/org/springframework/web/client/RestTemplate.java

4
spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java

@ -328,7 +328,6 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
@Override @Override
protected void startInternal() { protected void startInternal() {
this.clientInboundChannel.subscribe(this); this.clientInboundChannel.subscribe(this);
this.brokerChannel.subscribe(this); this.brokerChannel.subscribe(this);
@ -382,7 +381,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
String sessionId = headers.getSessionId(); String sessionId = headers.getSessionId();
if (!isBrokerAvailable()) { if (!isBrokerAvailable()) {
if (sessionId == null || sessionId.equals(SystemStompConnectionHandler.SESSION_ID)) { if (sessionId == null || SystemStompConnectionHandler.SESSION_ID.equals(sessionId)) {
throw new MessageDeliveryException("Message broker is not active."); throw new MessageDeliveryException("Message broker is not active.");
} }
if (SimpMessageType.CONNECT.equals(headers.getMessageType()) && logger.isErrorEnabled()) { if (SimpMessageType.CONNECT.equals(headers.getMessageType()) && logger.isErrorEnabled()) {
@ -574,7 +573,6 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
} }
private void initHeartbeats(StompHeaderAccessor connectedHeaders) { private void initHeartbeats(StompHeaderAccessor connectedHeaders) {
// Remote clients do their own heartbeat management
if (this.isRemoteClientSession) { if (this.isRemoteClientSession) {
return; return;
} }

14
spring-web/src/main/java/org/springframework/http/HttpEntity.java

@ -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();

6
spring-web/src/main/java/org/springframework/http/ResponseEntity.java

@ -106,16 +106,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

21
spring-web/src/main/java/org/springframework/web/client/RestOperations.java

@ -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.
@ -106,6 +106,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
/** /**
@ -133,6 +134,7 @@ public interface RestOperations {
*/ */
HttpHeaders headForHeaders(URI url) throws RestClientException; HttpHeaders headForHeaders(URI url) throws RestClientException;
// POST // POST
/** /**
@ -265,6 +267,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
/** /**
@ -301,6 +304,7 @@ public interface RestOperations {
*/ */
void put(URI url, Object request) throws RestClientException; void put(URI url, Object request) throws RestClientException;
// DELETE // DELETE
/** /**
@ -326,6 +330,7 @@ public interface RestOperations {
*/ */
void delete(URI url) throws RestClientException; void delete(URI url) throws RestClientException;
// OPTIONS // OPTIONS
/** /**
@ -353,6 +358,7 @@ public interface RestOperations {
*/ */
Set<HttpMethod> optionsForAllow(URI url) throws RestClientException; Set<HttpMethod> optionsForAllow(URI url) throws RestClientException;
// exchange // exchange
/** /**
@ -402,12 +408,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&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {}; * ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean); * ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,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
@ -415,7 +419,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;
@ -424,19 +428,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&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {}; * ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean); * ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,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;
@ -445,22 +447,21 @@ 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&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {}; * ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyBean&gt;&gt;() {};
* ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,HttpMethod.GET, null, myBean); * ResponseEntity&lt;List&lt;MyBean&gt;&gt; response = template.exchange(&quot;http://example.com&quot;,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;
// general execution // general execution
/** /**

6
spring-web/src/main/java/org/springframework/web/client/RestTemplate.java

@ -284,6 +284,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
@ -301,6 +302,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
@ -377,6 +379,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
@ -397,6 +400,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
execute(url, HttpMethod.PUT, requestCallback, null); execute(url, HttpMethod.PUT, requestCallback, null);
} }
// DELETE // DELETE
@Override @Override
@ -414,6 +418,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
execute(url, HttpMethod.DELETE, null, null); execute(url, HttpMethod.DELETE, null, null);
} }
// OPTIONS // OPTIONS
@Override @Override
@ -437,6 +442,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
return headers.getAllow(); return headers.getAllow();
} }
// exchange // exchange
@Override @Override

Loading…
Cancel
Save