If you read the previous post I wrote about ApplicationComposers run method you surely wonder what a service could look like using groovy and @Grab to resolve maven dependencies?
Here is a quick post showing it:
import org.apache.openejb.testing.ApplicationComposers import org.apache.openejb.testing.Classes import org.apache.openejb.testing.EnableServices import org.apache.openejb.testing.SimpleLog import javax.ws.rs.GET import javax.ws.rs.Path @Grab("org.apache.openejb:javaee-api:7.0-SNAPSHOT") @Grab("org.apache.openejb:openejb-cxf-rs:5.0.0-SNAPSHOT") @Path("hi") class Hi { @GET String hi() { "Hi" } } @SimpleLog @EnableServices("jaxrs") @Classes(Hi.class) class Run { } ApplicationComposers.run(Run.class);
And that’s it,just hit run and you get your service deployed!
Just a little note about groovy: depending the distribution/setup of groovy you use to run it you can maybe desire remove servlet-api which is in groovy binary 2.4 distribution in 2.x version (OpenEJB 5 uses 3.1).
Another note about dependencies: at the moment openejb/javaee-api dependencies are on apache snapshot repository, if you don’t have them locally you can desire to configure grape to resolve them correctly.
Have fun with Groovy and OpenEJB microservices!