i wanna make request scoped configuration for Jackson serializer based on request parameter, so my problem is the configuration runs in a different thread and only runs when the app stars, how i can make java reconfigure Jackson serializer in every request ?
Asked
Active
Viewed 1,301 times
1 Answers
0
It's not possible to have request scoped config. Instead make the Jackson serializer bean request scoped and return instance with necessary config.
You can use approach described here instanciation of a request scoped bean
@Configuration
public class MyBeansConfig {
@Bean
@Scope(value="request", proxyMode=ScopedProxyMode.TARGET_CLASS)
public RequestScopedBean requestScopedBean() {
//if needed set the required parameters
return new RequestScopedBean();
}
}
Just return here your serializer instance. Then just autowire it wehre it's necessary

StanislavL
- 56,971
- 9
- 68
- 98
-
thanks @StanislavL for your quick reply, the probem that i'm facing is autowiring HttpServerRequest in my configuration and its always null , so the question is how i can autowire request in my BeanSerializerModifier ? – Abdou Rayes Jan 05 '18 at 15:37