All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.robe.guice.JerseyModule Maven / Gradle / Ivy

There is a newer version: 0.5.0.0-1039
Show newest version
package io.robe.guice;

import com.google.inject.servlet.ServletModule;
import com.squarespace.jersey2.guice.BootstrapModule;
import com.squarespace.jersey2.guice.BootstrapUtils;
import org.glassfish.hk2.api.ServiceLocator;

//Copied from https://github.com/HubSpot/dropwizard-guice/blob/master/src/main/java/com/hubspot/dropwizard/guice/JerseyModule.java
public class JerseyModule extends ServletModule {

    @Override
    protected void configureServlets() {
        // The order these operations (including the steps in the linker) are important
        ServiceLocator locator = new ServiceLocatorDecorator(BootstrapUtils.newServiceLocator()) {

            @Override
            public void shutdown() {
                // don't shutdown, see issue #67. Remove once jersey2-guice supports Jersey 2.21
            }
        };
        install(new BootstrapModule(locator));

        bind(HK2Linker.class).asEagerSingleton();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy