cancel
Showing results for 
Search instead for 
Did you mean: 

Custom RestVariableConverters

jsalmon
Champ in-the-making
Champ in-the-making
Hi,

First off, thank you for Activiti! It looks really great so far.

I'm trying to implement a custom RestVariableConverter in order to return my POJO variables as JSON in REST responses. My question is fairly similar to this one, but I didn't find a satisfactory answer there.

I don't want to clone the REST app. I was hoping I could provide a Spring @Configuration class with a RestResponseFactory @Bean and have Spring Boot pick it up automatically, but it doesn't.

How else can I provide a custom RestResponseFactory? By the way, I'm using 5.17.0.

Cheers,
Justin
3 REPLIES 3

jsalmon
Champ in-the-making
Champ in-the-making
Okay, so I managed to do this by copying org.activiti.spring.boot.RestApiAutoConfiguration and returning a custom RestResponseFactory bean. But I feel like there should be a better way of doing it?

trademak
Star Contributor
Star Contributor
The REST web application is just an example application with a default config. All the logic is part of the activiti-rest module. An alternative is to use the Spring XML configuration instead.

Best regards,

blaketsk
Champ in-the-making
Champ in-the-making

You don't need to copy RestApiAutoConfiguration. Try this:

@Autowired

private RestResponseFactory restResponseFactory;

@PostConstruct

public void addCustomConverters()  {

   restResponseFactory.getVariableConverters().add(new YourCustomRestVariableConverter());

}