Java Code Examples for org.springframework.http.codec.ServerCodecConfigurer#getReaders()
The following examples show how to use
org.springframework.http.codec.ServerCodecConfigurer#getReaders() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestMappingHandlerAdapter.java From spring-analysis-note with MIT License | 6 votes |
@Override public void afterPropertiesSet() throws Exception { Assert.notNull(this.applicationContext, "ApplicationContext is required"); if (CollectionUtils.isEmpty(this.messageReaders)) { ServerCodecConfigurer codecConfigurer = ServerCodecConfigurer.create(); this.messageReaders = codecConfigurer.getReaders(); } if (this.argumentResolverConfigurer == null) { this.argumentResolverConfigurer = new ArgumentResolverConfigurer(); } if (this.reactiveAdapterRegistry == null) { this.reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); } this.methodResolver = new ControllerMethodResolver(this.argumentResolverConfigurer, this.reactiveAdapterRegistry, this.applicationContext, this.messageReaders); this.modelInitializer = new ModelInitializer(this.methodResolver, this.reactiveAdapterRegistry); }
Example 2
Source File: ControllerMethodResolverTests.java From spring-analysis-note with MIT License | 6 votes |
@Before public void setup() { ArgumentResolverConfigurer resolvers = new ArgumentResolverConfigurer(); resolvers.addCustomResolver(new CustomArgumentResolver()); resolvers.addCustomResolver(new CustomSyncArgumentResolver()); ServerCodecConfigurer codecs = ServerCodecConfigurer.create(); codecs.customCodecs().decoder(new ByteArrayDecoder()); codecs.customCodecs().decoder(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); }
Example 3
Source File: RequestMappingHandlerAdapter.java From java-technology-stack with MIT License | 6 votes |
@Override public void afterPropertiesSet() throws Exception { Assert.notNull(this.applicationContext, "ApplicationContext is required"); if (CollectionUtils.isEmpty(this.messageReaders)) { ServerCodecConfigurer codecConfigurer = ServerCodecConfigurer.create(); this.messageReaders = codecConfigurer.getReaders(); } if (this.argumentResolverConfigurer == null) { this.argumentResolverConfigurer = new ArgumentResolverConfigurer(); } if (this.reactiveAdapterRegistry == null) { this.reactiveAdapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); } this.methodResolver = new ControllerMethodResolver(this.argumentResolverConfigurer, this.reactiveAdapterRegistry, this.applicationContext, this.messageReaders); this.modelInitializer = new ModelInitializer(this.methodResolver, this.reactiveAdapterRegistry); }
Example 4
Source File: ControllerMethodResolverTests.java From java-technology-stack with MIT License | 6 votes |
@Before public void setup() { ArgumentResolverConfigurer resolvers = new ArgumentResolverConfigurer(); resolvers.addCustomResolver(new CustomArgumentResolver()); resolvers.addCustomResolver(new CustomSyncArgumentResolver()); ServerCodecConfigurer codecs = ServerCodecConfigurer.create(); codecs.customCodecs().decoder(new ByteArrayDecoder()); codecs.customCodecs().decoder(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); }
Example 5
Source File: ModifyRequestBodyGatewayFilterFactorySslTimeoutTests.java From spring-cloud-gateway with Apache License 2.0 | 6 votes |
@Bean @Primary public ModifyRequestBodyGatewayFilterFactory testModifyRequestBodyGatewayFilterFactory( ServerCodecConfigurer codecConfigurer, AtomicInteger count) { return new ModifyRequestBodyGatewayFilterFactory( codecConfigurer.getReaders()) { @Override protected Mono<Void> release(ServerWebExchange exchange, CachedBodyOutputMessage outputMessage, Throwable throwable) { if (outputMessage.isCached()) { count.incrementAndGet(); } return super.release(exchange, outputMessage, throwable); } }; }
Example 6
Source File: RouterFunctionMapping.java From spring-analysis-note with MIT License | 5 votes |
@Override public void afterPropertiesSet() throws Exception { if (CollectionUtils.isEmpty(this.messageReaders)) { ServerCodecConfigurer codecConfigurer = ServerCodecConfigurer.create(); this.messageReaders = codecConfigurer.getReaders(); } if (this.routerFunction == null) { initRouterFunctions(); } }
Example 7
Source File: RouterFunctionMapping.java From java-technology-stack with MIT License | 5 votes |
@Override public void afterPropertiesSet() throws Exception { if (CollectionUtils.isEmpty(this.messageReaders)) { ServerCodecConfigurer codecConfigurer = ServerCodecConfigurer.create(); this.messageReaders = codecConfigurer.getReaders(); } if (this.routerFunction == null) { initRouterFunctions(); } }
Example 8
Source File: SpringWebfluxUnhandledExceptionHandler.java From backstopper with Apache License 2.0 | 5 votes |
@Inject public SpringWebfluxUnhandledExceptionHandler( @NotNull ProjectApiErrors projectApiErrors, @NotNull ApiExceptionHandlerUtils generalUtils, @NotNull SpringWebfluxApiExceptionHandlerUtils springUtils, @NotNull ObjectProvider<ViewResolver> viewResolversProvider, @NotNull ServerCodecConfigurer serverCodecConfigurer ) { super(projectApiErrors, generalUtils); //noinspection ConstantConditions if (springUtils == null) { throw new NullPointerException("springUtils cannot be null."); } //noinspection ConstantConditions if (viewResolversProvider == null) { throw new NullPointerException("viewResolversProvider cannot be null."); } //noinspection ConstantConditions if (serverCodecConfigurer == null) { throw new NullPointerException("serverCodecConfigurer cannot be null."); } this.singletonGenericServiceError = Collections.singleton(projectApiErrors.getGenericServiceError()); this.genericServiceErrorHttpStatusCode = projectApiErrors.getGenericServiceError().getHttpStatusCode(); this.springUtils = springUtils; this.viewResolvers = viewResolversProvider.orderedStream().collect(Collectors.toList()); this.messageReaders = serverCodecConfigurer.getReaders(); this.messageWriters = serverCodecConfigurer.getWriters(); }
Example 9
Source File: SpringWebfluxApiExceptionHandler.java From backstopper with Apache License 2.0 | 5 votes |
@Inject public SpringWebfluxApiExceptionHandler( @NotNull ProjectApiErrors projectApiErrors, @NotNull SpringWebFluxApiExceptionHandlerListenerList apiExceptionHandlerListeners, @NotNull ApiExceptionHandlerUtils generalUtils, @NotNull SpringWebfluxApiExceptionHandlerUtils springUtils, @NotNull ObjectProvider<ViewResolver> viewResolversProvider, @NotNull ServerCodecConfigurer serverCodecConfigurer ) { super(projectApiErrors, apiExceptionHandlerListeners.listeners, generalUtils); //noinspection ConstantConditions if (springUtils == null) { throw new NullPointerException("springUtils cannot be null."); } //noinspection ConstantConditions if (viewResolversProvider == null) { throw new NullPointerException("viewResolversProvider cannot be null."); } //noinspection ConstantConditions if (serverCodecConfigurer == null) { throw new NullPointerException("serverCodecConfigurer cannot be null."); } this.springUtils = springUtils; this.viewResolvers = viewResolversProvider.orderedStream().collect(Collectors.toList()); this.messageReaders = serverCodecConfigurer.getReaders(); this.messageWriters = serverCodecConfigurer.getWriters(); }
Example 10
Source File: GatewayAutoConfiguration.java From spring-cloud-gateway with Apache License 2.0 | 5 votes |
@Bean public ModifyResponseBodyGatewayFilterFactory modifyResponseBodyGatewayFilterFactory( ServerCodecConfigurer codecConfigurer, Set<MessageBodyDecoder> bodyDecoders, Set<MessageBodyEncoder> bodyEncoders) { return new ModifyResponseBodyGatewayFilterFactory(codecConfigurer.getReaders(), bodyDecoders, bodyEncoders); }
Example 11
Source File: RequestProcessor.java From spring-cloud-function with Apache License 2.0 | 5 votes |
public RequestProcessor(FunctionInspector inspector, FunctionCatalog functionCatalog, ObjectProvider<JsonMapper> mapper, StringConverter converter, ObjectProvider<ServerCodecConfigurer> codecs) { this.mapper = mapper.getIfAvailable(); this.inspector = inspector; this.functionCatalog = functionCatalog; this.converter = converter; ServerCodecConfigurer source = codecs.getIfAvailable(); this.messageReaders = source == null ? null : source.getReaders(); }
Example 12
Source File: GlobalErrorWebExceptionHandler.java From springboot-learning-example with Apache License 2.0 | 4 votes |
public GlobalErrorWebExceptionHandler(GlobalErrorAttributes g, ApplicationContext applicationContext, ServerCodecConfigurer serverCodecConfigurer) { super(g, new ResourceProperties(), applicationContext); super.setMessageWriters(serverCodecConfigurer.getWriters()); super.setMessageReaders(serverCodecConfigurer.getReaders()); }
Example 13
Source File: GlobalErrorWebExceptionHandler.java From microservice-integration with MIT License | 4 votes |
public GlobalErrorWebExceptionHandler(GlobalErrorAttributes g, ApplicationContext applicationContext, ServerCodecConfigurer serverCodecConfigurer) { super(g, new ResourceProperties(), applicationContext); super.setMessageWriters(serverCodecConfigurer.getWriters()); super.setMessageReaders(serverCodecConfigurer.getReaders()); }
Example 14
Source File: GatewayAutoConfiguration.java From spring-cloud-gateway with Apache License 2.0 | 4 votes |
@Bean public ReadBodyPredicateFactory readBodyPredicateFactory( ServerCodecConfigurer codecConfigurer) { return new ReadBodyPredicateFactory(codecConfigurer.getReaders()); }
Example 15
Source File: GatewayAutoConfiguration.java From spring-cloud-gateway with Apache License 2.0 | 4 votes |
@Bean public ModifyRequestBodyGatewayFilterFactory modifyRequestBodyGatewayFilterFactory( ServerCodecConfigurer codecConfigurer) { return new ModifyRequestBodyGatewayFilterFactory(codecConfigurer.getReaders()); }
Example 16
Source File: GlobalErrorWebExceptionHandler.java From tutorials with MIT License | 4 votes |
public GlobalErrorWebExceptionHandler(GlobalErrorAttributes g, ApplicationContext applicationContext, ServerCodecConfigurer serverCodecConfigurer) { super(g, new ResourceProperties(), applicationContext); super.setMessageWriters(serverCodecConfigurer.getWriters()); super.setMessageReaders(serverCodecConfigurer.getReaders()); }