Browse Source

Rename ViewResolverResultHandler to ViewResolution~

pull/1111/head
Rossen Stoyanchev 9 years ago
parent
commit
793638e610
  1. 3
      spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandler.java
  2. 21
      spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java
  3. 6
      spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolver.java
  4. 6
      spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java
  5. 26
      spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java

3
spring-web-reactive/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandler.java

@ -92,7 +92,8 @@ public class ResponseBodyResultHandler implements HandlerResultHandler, Ordered @@ -92,7 +92,8 @@ public class ResponseBodyResultHandler implements HandlerResultHandler, Ordered
* {@code RequestedContentTypeResolver}.
*
* @param messageConverters converters for writing the response body with
* @param conversionService for converting to Flux and Mono from other reactive types
* @param conversionService for converting other reactive types (e.g.
* rx.Observable, rx.Single, etc.) to Flux or Mono
*/
public ResponseBodyResultHandler(List<HttpMessageConverter<?>> messageConverters,
ConversionService conversionService, RequestedContentTypeResolver contentTypeResolver) {

21
spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolverResultHandler.java → spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java

@ -36,17 +36,17 @@ import org.springframework.web.server.ServerWebExchange; @@ -36,17 +36,17 @@ import org.springframework.web.server.ServerWebExchange;
/**
* {@code HandlerResultHandler} that resolves a String return value from a
* handler to a {@link View} which is then used to render the response.
* A handler may also return a {@code View} instance and/or async variants that
* provide a String view name or a {@code View}.
* {@code HandlerResultHandler} that performs view resolution by resolving a
* {@link View} instance first and then rendering the response with it.
* If the return value is a String, the configured {@link ViewResolver}s will
* be consulted to resolve that to a {@link View} instance.
*
* <p>This result handler should be ordered after others that may also interpret
* a String return value for example in combination with {@code @ResponseBody}.
* <p>This result handler should be ordered late relative to other result
* handlers. See {@link #setOrder(int)} for more details.
*
* @author Rossen Stoyanchev
*/
public class ViewResolverResultHandler implements HandlerResultHandler, Ordered {
public class ViewResolutionResultHandler implements HandlerResultHandler, Ordered {
private final List<ViewResolver> viewResolvers = new ArrayList<>(4);
@ -55,7 +55,12 @@ public class ViewResolverResultHandler implements HandlerResultHandler, Ordered @@ -55,7 +55,12 @@ public class ViewResolverResultHandler implements HandlerResultHandler, Ordered
private int order = Ordered.LOWEST_PRECEDENCE;
public ViewResolverResultHandler(List<ViewResolver> resolvers, ConversionService service) {
/**
* Constructor with {@code ViewResolver}s tand a {@code ConversionService}.
* @param resolvers the resolver to use
* @param service for converting other reactive types (e.g. rx.Single) to Mono
*/
public ViewResolutionResultHandler(List<ViewResolver> resolvers, ConversionService service) {
Assert.notEmpty(resolvers, "At least one ViewResolver is required.");
Assert.notNull(service, "'conversionService' is required.");
this.viewResolvers.addAll(resolvers);

6
spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/ViewResolver.java

@ -10,11 +10,11 @@ import reactor.core.publisher.Mono; @@ -10,11 +10,11 @@ import reactor.core.publisher.Mono;
*
* <p>The process of view resolution is driven through a ViewResolver-based
* {@code HandlerResultHandler} implementation called
* {@link org.springframework.web.reactive.result.view.ViewResolverResultHandler
* ViewResolverResultHandler}.
* {@link ViewResolutionResultHandler
* ViewResolutionResultHandler}.
*
* @author Rossen Stoyanchev
* @see org.springframework.web.reactive.result.view.ViewResolverResultHandler
* @see ViewResolutionResultHandler
*/
public interface ViewResolver {

6
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java

@ -76,8 +76,8 @@ import org.springframework.web.bind.annotation.RestController; @@ -76,8 +76,8 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.reactive.result.SimpleResultHandler;
import org.springframework.web.reactive.result.view.ViewResolutionResultHandler;
import org.springframework.web.reactive.result.view.ViewResolver;
import org.springframework.web.reactive.result.view.ViewResolverResultHandler;
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerViewResolver;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
@ -424,9 +424,9 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati @@ -424,9 +424,9 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati
}
@Bean
public ViewResolverResultHandler viewResolverResultHandler() {
public ViewResolutionResultHandler viewResolverResultHandler() {
List<ViewResolver> resolvers = Collections.singletonList(freeMarkerViewResolver());
return new ViewResolverResultHandler(resolvers, conversionService());
return new ViewResolutionResultHandler(resolvers, conversionService());
}
@Bean

26
spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/ViewResolverResultHandlerTests.java → spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java

@ -63,10 +63,10 @@ import static org.mockito.Mockito.mock; @@ -63,10 +63,10 @@ import static org.mockito.Mockito.mock;
/**
* Unit tests for {@link ViewResolverResultHandler}.
* Unit tests for {@link ViewResolutionResultHandler}.
* @author Rossen Stoyanchev
*/
public class ViewResolverResultHandlerTests {
public class ViewResolutionResultHandlerTests {
private static final Charset UTF_8 = Charset.forName("UTF-8");
@ -107,7 +107,7 @@ public class ViewResolverResultHandlerTests { @@ -107,7 +107,7 @@ public class ViewResolverResultHandlerTests {
ResolvableType returnType = ResolvableType.forMethodParameter(method, -1);
HandlerResult result = new HandlerResult(new Object(), returnValue, returnType, this.model);
List<ViewResolver> resolvers = Collections.singletonList(mock(ViewResolver.class));
ViewResolverResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService);
assertTrue(handler.supports(result));
}
@ -115,7 +115,7 @@ public class ViewResolverResultHandlerTests { @@ -115,7 +115,7 @@ public class ViewResolverResultHandlerTests {
public void viewReference() throws Exception {
TestView view = new TestView("account");
List<ViewResolver> resolvers = Collections.singletonList(mock(ViewResolver.class));
ViewResolverResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService);
handle(handler, view, ResolvableType.forClass(View.class));
new TestSubscriber<DataBuffer>().bindTo(this.response.getBody())
@ -126,7 +126,7 @@ public class ViewResolverResultHandlerTests { @@ -126,7 +126,7 @@ public class ViewResolverResultHandlerTests {
public void viewReferenceMono() throws Exception {
TestView view = new TestView("account");
List<ViewResolver> resolvers = Collections.singletonList(mock(ViewResolver.class));
ViewResolverResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService);
handle(handler, Mono.just(view), methodReturnType("handleMonoView"));
new TestSubscriber<DataBuffer>().bindTo(this.response.getBody())
@ -138,7 +138,7 @@ public class ViewResolverResultHandlerTests { @@ -138,7 +138,7 @@ public class ViewResolverResultHandlerTests {
TestView view = new TestView("account");
TestViewResolver resolver = new TestViewResolver().addView(view);
List<ViewResolver> resolvers = Collections.singletonList(resolver);
ViewResolverResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService);
handle(handler, "account", ResolvableType.forClass(String.class));
TestSubscriber<DataBuffer> subscriber = new TestSubscriber<>();
@ -151,7 +151,7 @@ public class ViewResolverResultHandlerTests { @@ -151,7 +151,7 @@ public class ViewResolverResultHandlerTests {
TestView view = new TestView("account");
TestViewResolver resolver = new TestViewResolver().addView(view);
List<ViewResolver> resolvers = Collections.singletonList(resolver);
ViewResolverResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService);
handle(handler, Mono.just("account"), methodReturnType("handleMonoString"));
new TestSubscriber<DataBuffer>().bindTo(this.response.getBody())
@ -165,7 +165,7 @@ public class ViewResolverResultHandlerTests { @@ -165,7 +165,7 @@ public class ViewResolverResultHandlerTests {
TestViewResolver resolver1 = new TestViewResolver().addView(view1);
TestViewResolver resolver2 = new TestViewResolver().addView(view2);
List<ViewResolver> resolvers = Arrays.asList(resolver1, resolver2);
ViewResolverResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService);
handle(handler, "profile", ResolvableType.forClass(String.class));
new TestSubscriber<DataBuffer>().bindTo(this.response.getBody())
@ -175,7 +175,7 @@ public class ViewResolverResultHandlerTests { @@ -175,7 +175,7 @@ public class ViewResolverResultHandlerTests {
@Test
public void viewNameWithNoMatch() throws Exception {
List<ViewResolver> resolvers = Collections.singletonList(mock(ViewResolver.class));
ViewResolverResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService);
TestSubscriber<Void> subscriber = handle(handler, "account", ResolvableType.forClass(String.class));
subscriber.assertNoValues();
@ -184,7 +184,7 @@ public class ViewResolverResultHandlerTests { @@ -184,7 +184,7 @@ public class ViewResolverResultHandlerTests {
@Test
public void viewNameNotSpecified() throws Exception {
List<ViewResolver> resolvers = Collections.singletonList(mock(ViewResolver.class));
ViewResolverResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService);
TestSubscriber<Void> subscriber = handle(handler, null, ResolvableType.forClass(String.class));
subscriber.assertErrorWith(ex ->
@ -196,7 +196,7 @@ public class ViewResolverResultHandlerTests { @@ -196,7 +196,7 @@ public class ViewResolverResultHandlerTests {
TestView view = new TestView("account");
TestViewResolver resolver = new TestViewResolver().addView(view);
List<ViewResolver> resolvers = Collections.singletonList(resolver);
HandlerResultHandler handler = new ViewResolverResultHandler(resolvers, this.conversionService) {
HandlerResultHandler handler = new ViewResolutionResultHandler(resolvers, this.conversionService) {
@Override
protected String getDefaultViewName(ServerWebExchange exchange, HandlerResult result) {
return "account";
@ -218,8 +218,8 @@ public class ViewResolverResultHandlerTests { @@ -218,8 +218,8 @@ public class ViewResolverResultHandlerTests {
resolver1.setOrder(2);
resolver2.setOrder(1);
ViewResolverResultHandler resultHandler =
new ViewResolverResultHandler(resolvers, this.conversionService);
ViewResolutionResultHandler resultHandler =
new ViewResolutionResultHandler(resolvers, this.conversionService);
assertEquals(Arrays.asList(resolver2, resolver1), resultHandler.getViewResolvers());
}
Loading…
Cancel
Save