Giter Club home page Giter Club logo

vertx-guice's Introduction

vertx-guice

Enable Verticle dependency injection in Vert.x using Guice.

Build Status Code Coverage Maven Central

It is designed to use single injector per Vert.x instance. It means that `Singleton' scope is supported and works as expected. This was the main reason to implement this library instead of using vertx-guice library from English Town.

What does it provide

  • GuiceVerticleFactory which uses Guice for verticle creation. To be used, it should be registered in Vertx and verticle should be deployed with java-guice: prefix.
  • GuiceVertxLauncher which extends default vert.x launcher. It performs all necessary work related to the creating single injector per Vert.x instance, registering GuiceVerticleFactory. To register application specific dependencies, you can also create a sub-class of GuiceVertxLauncher and use it to start your application.
  • GuiceVertxDeploymentManager which implements convenient methods to deploy verticles programmatically by specified class using GuiceVerticleFactory factory.
  • VertxModule which contains binding for vertx itself and it's cached objects like EventBus, FileSystem, SharedData.

How to use

Several examples were added which covers main scenarios of the adding dependency injection support.

Shows the way to use GuiceVertxLauncher to run application with registering application specific modules and deploying verticle with injecting dependencies.

Basically it covers the following:

  • Extending GuiceVertxLauncher to register application specific modules
  • Customized run gradle task which deploys verticle with constructor dependency injection.

Note some of the useful information about Vert.x launcher and gradle configuration can be found in vertx 3.0 examples.

Example which shows the following:

  • Creating vertx manually in application main entry point
  • Creating single injector with Vertx and application specific modules
  • Registering 'GuiceVerticleFactory'.
  • Deploying verticle programmatically which uses 'GuiceVerticleFactory'

There is an Vert.x Service Proxy library which allows to develop less verbosity code for asynchronous verticles (which works over event bus). This example shows the following:

  • Particular the same stuff from manual example with addition that Vertx service concept is used.
  • Dependency injection in service itself
  • Hiding service registration and proxy creation by using Guice Provider concept
  • Using of the service via injected generated proxy in verticle
  • Gradle configuration

TO-DO

  • Request Scope Support (if there will be a real use case for this)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.