We have a Spring 4.0-based web application running in Tomcat 8 (alternatively we have a start-up script for Undertow). Spring MVC is handling requests. I am looking for a way to defer some of request handling code to Clojure library, with minimal changes to legacy Java code.
For instance, requests with URLs ending with .java
would be handled by legacy Java, and requests ending with .clj
would be handled by Clojure. For now, i see three options:
clojure.java.api
to invoke Clojure code from Java.Are above approaches actually feasible? What else would you suggest?
Thanks!
I've done a similar thing but on a DropWizard application rather than a Spring application. I went with approach #1.
I followed the example here - https://stackoverflow.com/a/2187427/827617
to create the library. That way you don't need to use clojure.java.api
, your Clojure library compiles down into a jar that you can include in your Spring application and call directly from Java (the functions that you expose are static methods on a class).