Remove outdated DataBufferFactory properties

Removed in favor of accessing the factory from the response.
This commit is contained in:
Rossen Stoyanchev 2016-06-01 18:07:54 -04:00
parent 431fedccc7
commit 03a997c9d4
5 changed files with 6 additions and 54 deletions

View File

@ -23,14 +23,10 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.MediaType;
import org.springframework.ui.ModelMap;
import org.springframework.util.Assert;
@ -49,8 +45,6 @@ public abstract class AbstractView implements View, ApplicationContextAware {
private final List<MediaType> mediaTypes = new ArrayList<>(4);
private DataBufferFactory bufferAllocator = new DefaultDataBufferFactory();
private ApplicationContext applicationContext;
@ -79,23 +73,6 @@ public abstract class AbstractView implements View, ApplicationContextAware {
return this.mediaTypes;
}
/**
* Configure the {@link DataBufferFactory} to use for write I/O.
* <p>By default this is set to {@link DefaultDataBufferFactory}.
* @param bufferAllocator the factory to use
*/
public void setBufferAllocator(DataBufferFactory bufferAllocator) {
Assert.notNull(bufferAllocator, "'bufferAllocator' is required.");
this.bufferAllocator = bufferAllocator;
}
/**
* Return the configured buffer factory, never {@code null}.
*/
public DataBufferFactory getBufferAllocator() {
return this.bufferAllocator;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;

View File

@ -193,7 +193,6 @@ public class UrlBasedViewResolver extends ViewResolverSupport implements ViewRes
protected AbstractUrlBasedView createUrlBasedView(String viewName) {
AbstractUrlBasedView view = (AbstractUrlBasedView) BeanUtils.instantiateClass(getViewClass());
view.setSupportedMediaTypes(getSupportedMediaTypes());
view.setBufferAllocator(getBufferAllocator());
view.setUrl(getPrefix() + viewName + getSuffix());
return view;
}

View File

@ -22,8 +22,6 @@ import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.Ordered;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
@ -40,8 +38,6 @@ public abstract class ViewResolverSupport implements ApplicationContextAware, Or
private List<MediaType> mediaTypes = new ArrayList<>(4);
private DataBufferFactory bufferAllocator = new DefaultDataBufferFactory();
private ApplicationContext applicationContext;
private int order = Integer.MAX_VALUE;
@ -71,23 +67,6 @@ public abstract class ViewResolverSupport implements ApplicationContextAware, Or
return this.mediaTypes;
}
/**
* Configure the {@link DataBufferFactory} to use for write I/O.
* <p>By default this is set to {@link DefaultDataBufferFactory}.
* @param bufferAllocator the factory to use
*/
public void setBufferAllocator(DataBufferFactory bufferAllocator) {
Assert.notNull(bufferAllocator, "'bufferAllocator' is required.");
this.bufferAllocator = bufferAllocator;
}
/**
* Return the configured buffer factory, never {@code null}.
*/
public DataBufferFactory getBufferAllocator() {
return this.bufferAllocator;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;

View File

@ -164,7 +164,7 @@ public class FreeMarkerView extends AbstractUrlBasedView {
logger.debug("Rendering FreeMarker template [" + getUrl() + "].");
}
Locale locale = Locale.getDefault(); // TODO
DataBuffer dataBuffer = getBufferAllocator().allocateBuffer();
DataBuffer dataBuffer = exchange.getResponse().bufferFactory().allocateBuffer();
try {
Writer writer = new OutputStreamWriter(dataBuffer.asOutputStream());
getTemplate(locale).process(freeMarkerModel, writer);

View File

@ -82,7 +82,9 @@ import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigu
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerViewResolver;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
import static org.junit.Assert.*;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@ -382,9 +384,6 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati
@SuppressWarnings("unused")
static class FrameworkConfig {
private DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
@Bean
public RequestMappingHandlerMapping handlerMapping() {
return new RequestMappingHandlerMapping();
@ -429,9 +428,7 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati
@Bean
public ViewResolver freeMarkerViewResolver() {
FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver("", ".ftl");
viewResolver.setBufferAllocator(this.dataBufferFactory);
return viewResolver;
return new FreeMarkerViewResolver("", ".ftl");
}
@Bean
@ -564,7 +561,7 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati
@RequestMapping("/stream-create")
public Publisher<Void> streamCreate(@RequestBody Flux<Person> personStream) {
return personStream.toList().doOnSuccess(persons::addAll).then();
return personStream.asList().doOnSuccess(persons::addAll).then();
}
@RequestMapping("/person-capitalize")