vertx-guice

Enable Verticle dependency injection in Vert.x using Guice.

Лицензия

Лицензия

Категории

Категории

GUI Взаимодействие с пользователем Guice Библиотеки уровня приложения Dependency Injection
Группа

Группа

com.intapp
Идентификатор

Идентификатор

vertx-guice
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

vertx-guice
Enable Verticle dependency injection in Vert.x using Guice.
Ссылка на сайт

Ссылка на сайт

https://github.com/intappx/vertx-guice
Организация-разработчик

Организация-разработчик

Intapp Inc.
Система контроля версий

Система контроля версий

https://github.com/intappx/vertx-guice

Скачать vertx-guice

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.intapp/vertx-guice/ -->
<dependency>
    <groupId>com.intapp</groupId>
    <artifactId>vertx-guice</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.intapp/vertx-guice/
implementation 'com.intapp:vertx-guice:1.0'
// https://jarcasting.com/artifacts/com.intapp/vertx-guice/
implementation ("com.intapp:vertx-guice:1.0")
'com.intapp:vertx-guice:jar:1.0'
<dependency org="com.intapp" name="vertx-guice" rev="1.0">
  <artifact name="vertx-guice" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.intapp', module='vertx-guice', version='1.0')
)
libraryDependencies += "com.intapp" % "vertx-guice" % "1.0"
[com.intapp/vertx-guice "1.0"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
io.vertx : vertx-core jar 3.2.1
com.google.inject : guice jar 4.0

test (5)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.11
org.assertj : assertj-core-java8 jar 1.0.0m1
org.mockito : mockito-core jar 1.10.19
io.vertx : vertx-core jar 3.2.1
io.vertx : vertx-rx-java jar 3.2.1

Модули Проекта

Данный проект не имеет модулей.

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.

Vert.x Launcher

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.

Creating and running Vert.x manually

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'
Using dependency injection with Vert.x services

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)
com.intapp

Intapp X

Версии библиотеки

Версия
1.0