Skip to content

codepitbull/vertx2-spring

Repository files navigation

A Simplistic Spring Language Implementation for vert.x 2

This project contains the following parts:

vertx2-spring-lang

The actual SPring language implementation for vert.x. It's just three classes so don't be afraid to take a look. ##vertx2-spring-lang-demo## A little vert.x-module showing how to set up verticals using the language implementation and Spring.

vertx2-spring-lang-app

Just one class in here with a main-method. Run it to start vert.x and have the modules deployed.

Import to IDE

I tested with IntelliJ Idea. Simply clone the repo, point Idea to the included top-level build.gradle and watch how the project is being imported. ##Installation## Use gradle install on vertx2-spring-lang and vertx2-spring-lang-demo to install the modules to your local maven repository.

Running the Example''

After installing the module start the class from vertx2-spring-lang-app, point your browser to http://localhost:8071. ##What just happened## Take a look at mod.json from vertx2-spring-lang-demo. The following line shows how to bootstrap the ApplicationContext:

"main":"spring:de.codepitbull.vertx.spring.lang.demo.TestConfiguration"

Looking at TestConfiguration.java you will see that HttpVerticle is registered a Spring-bean. It derives from SpringVerticle to allow auto wiring of Container and Vertc. But just registering it doesn't do the job, we need to deploy it to vert.x.

For this I use the InitBean. It's a ApplicationListener, so it's waiting until the context is started to do its work. It uses the following line to deploy the vertical:

container.deployVerticle("spring:httpVerticle")

I am using the bean name as it is defined in TestConfiguration to deploy the Spring Bean as a vertical. ##Limitations##

  • It only supports @Configuration-annotated classes. The times of XML are over and I'd like to keep it that way.
  • You can load ONE @Configuration-class for your vert.x instance. As long as I don't see a need to extend this I will keep it that way

###Register it the vert.x-way### To use the language implementation in your vert.x-distribution you have to add it. In the conf-directory open langs.properties and add the following line:

spring=de.codepitbull.vertx˜spring-lang˜1.0.0-final:de.codepitbull.vertx.spring.lang.SpringVerticleFactory

About

A Spring language implementation for vert.x 2.0.0

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published