use of org.springframework.core.codec.ByteBufferDecoder in project spring-framework by spring-projects.
the class WebFluxConfigurationSupport method addDefaultHttpMessageReaders.
/**
* Adds default converters that sub-classes can call from
* {@link #configureMessageReaders(List)} for {@code byte[]},
* {@code ByteBuffer}, {@code String}, {@code Resource}, JAXB2, and Jackson
* (if present on the classpath).
*/
protected final void addDefaultHttpMessageReaders(List<HttpMessageReader<?>> readers) {
readers.add(new DecoderHttpMessageReader<>(new ByteArrayDecoder()));
readers.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder()));
readers.add(new DecoderHttpMessageReader<>(new DataBufferDecoder()));
readers.add(new DecoderHttpMessageReader<>(new StringDecoder()));
readers.add(new DecoderHttpMessageReader<>(new ResourceDecoder()));
if (jaxb2Present) {
readers.add(new DecoderHttpMessageReader<>(new Jaxb2XmlDecoder()));
}
if (jackson2Present) {
readers.add(new Jackson2ServerHttpMessageReader(new DecoderHttpMessageReader<>(new Jackson2JsonDecoder())));
}
}
use of org.springframework.core.codec.ByteBufferDecoder in project spring-framework by spring-projects.
the class DefaultExchangeStrategiesBuilder method defaultReaders.
private void defaultReaders() {
messageReader(new DecoderHttpMessageReader<>(new ByteArrayDecoder()));
messageReader(new DecoderHttpMessageReader<>(new ByteBufferDecoder()));
messageReader(new ServerSentEventHttpMessageReader(sseDecoders()));
messageReader(new DecoderHttpMessageReader<>(new StringDecoder(false)));
if (jaxb2Present) {
messageReader(new DecoderHttpMessageReader<>(new Jaxb2XmlDecoder()));
}
if (jackson2Present) {
messageReader(new DecoderHttpMessageReader<>(new Jackson2JsonDecoder()));
}
}
use of org.springframework.core.codec.ByteBufferDecoder in project spring-security by spring-projects.
the class OAuth2BodyExtractorsTests method createContext.
@BeforeEach
public void createContext() {
final List<HttpMessageReader<?>> messageReaders = new ArrayList<>();
messageReaders.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder()));
messageReaders.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes()));
messageReaders.add(new DecoderHttpMessageReader<>(new Jackson2JsonDecoder()));
messageReaders.add(new FormHttpMessageReader());
this.hints = new HashMap<>();
this.context = new BodyExtractor.Context() {
@Override
public List<HttpMessageReader<?>> messageReaders() {
return messageReaders;
}
@Override
public Optional<ServerHttpResponse> serverResponse() {
return Optional.empty();
}
@Override
public Map<String, Object> hints() {
return OAuth2BodyExtractorsTests.this.hints;
}
};
}
use of org.springframework.core.codec.ByteBufferDecoder in project spring-framework by spring-projects.
the class ControllerMethodResolverTests method setup.
@BeforeEach
public void setup() {
ArgumentResolverConfigurer resolvers = new ArgumentResolverConfigurer();
resolvers.addCustomResolver(new CustomArgumentResolver());
resolvers.addCustomResolver(new CustomSyncArgumentResolver());
ServerCodecConfigurer codecs = ServerCodecConfigurer.create();
codecs.customCodecs().register(new ByteArrayDecoder());
codecs.customCodecs().register(new ByteBufferDecoder());
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
applicationContext.registerBean(TestControllerAdvice.class);
applicationContext.refresh();
this.methodResolver = new ControllerMethodResolver(resolvers, ReactiveAdapterRegistry.getSharedInstance(), applicationContext, codecs.getReaders());
Method method = ResolvableMethod.on(TestController.class).mockCall(TestController::handle).method();
this.handlerMethod = new HandlerMethod(new TestController(), method);
}
use of org.springframework.core.codec.ByteBufferDecoder in project spring-framework by spring-projects.
the class RSocketMessageHandlerTests method metadataExtractorWithExplicitlySetDecoders.
@Test
public void metadataExtractorWithExplicitlySetDecoders() {
DefaultMetadataExtractor extractor = new DefaultMetadataExtractor(StringDecoder.allMimeTypes());
RSocketMessageHandler handler = new RSocketMessageHandler();
handler.setDecoders(Arrays.asList(new ByteArrayDecoder(), new ByteBufferDecoder()));
handler.setEncoders(Collections.singletonList(new ByteBufferEncoder()));
handler.setMetadataExtractor(extractor);
handler.afterPropertiesSet();
assertThat(((DefaultMetadataExtractor) handler.getMetadataExtractor()).getDecoders()).hasSize(1);
}
Aggregations