Skip to content

Create Vert.x Verticles with dependency injection using HK2

License

Notifications You must be signed in to change notification settings

ef-labs/vertx-hk2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vert.x HK2 Extension

Enable Verticle dependency injection using HK2. Deploy your verticle with the java-hk2: prefix to use the HK2VerticleFactory.

Build Status Maven Central

License

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

Configuration

The vertx-mod-hk2 module configuration is as follows:

{
    "hk2_binder": <hk2_binder>
}
  • hk2_binder - The name of the HK2 binder class which contains the injection configuration. Default is "com.englishtown.vertx.hk2.BootstrapBinder". You can also provide an array of binder classes.

Example

package com.englishtown.vertx.hk2;

import com.englishtown.configuration.ConfigValueManager;
import com.englishtown.configuration.OtherBinder1;
import com.englishtown.configuration.OtherBinder2;
import com.englishtown.configuration.impl.PropertiesConfigValueManager;
import org.glassfish.hk2.utilities.binding.AbstractBinder;

import javax.inject.Singleton;

public class BootstrapBinder extends AbstractBinder {

    @Override
    protected void configure() {

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

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

    }

}

About

Create Vert.x Verticles with dependency injection using HK2

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages