How to integrate Groovy DSL in Spring Boot application

Viewed 117

I am developing a dsl which allows to send and receive messages from kafka broker, I developed a kafka producer and consumer with spring boot kafka starter and I was wondering if it is possible to pass its components to the dsl via the groovy Binding class and will groovy find the necessary dependencies.

@Autowired
private KafkaProducer kafkaProducer;

@Autowired
private KafkaProducer kafkaConsumer;

Binding binding = new Binding();
binding.setVariable("kafkaproducer",kafkaProducer);
binding.setVariable("kafkaconsumer",kafkaConsumer);

new GroovyShell(binding).evaluate(new File("DSL.txt").text);

Please give me an idea .

0 Answers
Related