Skip to content

Create Vert.x Modules and Verticles with dependency injection using Guice

License

Notifications You must be signed in to change notification settings

ef-labs/vertx-guice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vert.x Guice Extensions

Enable Verticle dependency injection using Guice. Deploy your verticle with the java-guice: prefix to use the GuiceVerticleFactory.

Build Status Maven Central

License

http://englishtown.mit-license.org/

Configuration

Either provide a com.englishtown.vertx.guice.BootstrapBinder that implements com.google.inject.Module, or via vert.x config, provide a custom class name.

{
    "guice_binder": "my.custom.bootstrap.Binder"
}

Example

package com.englishtown.vertx.guice;

import com.englishtown.configuration.ConfigValueManager;
import com.englishtown.configuration.OtherBinder1;
import com.englishtown.configuration.OtherBinder2;
import com.englishtown.configuration.impl.PropertiesConfigValueManager;
import com.google.inject.AbstractModule;

import javax.inject.Singleton;

public class BootstrapBinder extends AbstractModule {

    @Override
    protected void configure() {

        // Configure bindings
        bind(ConfigValueManager.class).to(PropertiesConfigValueManager.class).in(Singleton.class);

        // Install other binders
        install(new OtherBinder1(), new OtherBinder2());

    }

}

About

Create Vert.x Modules and Verticles with dependency injection using Guice

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages