Search in sources :

Example 1 with AbstractContainerLifecycleListener

use of org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener in project jersey by jersey.

the class ReloadTest method configure.

@Override
protected ResourceConfig configure() {
    enable(TestProperties.LOG_TRAFFIC);
    final ResourceConfig result = new ResourceConfig(ArrivalsResource.class);
    result.registerInstances(new AbstractContainerLifecycleListener() {

        @Override
        public void onStartup(Container container) {
            ReloadTest.container = container;
        }
    });
    return result;
}
Also used : Container(org.glassfish.jersey.server.spi.Container) AbstractContainerLifecycleListener(org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 2 with AbstractContainerLifecycleListener

use of org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener in project mycore by MyCoRe-Org.

the class MCRJerseyDefaultConfiguration method setupGuiceBridge.

/**
 * Adds the binding between guice and hk2. This binding is one directional.
 * You can add guice services into hk2 (jersey) resources. You cannot add
 * a hk2 service into guice.
 * <p>
 * <a href="https://hk2.java.net/guice-bridge/">about the bridge</a>
 * </p>
 *
 * @param resourceConfig the jersey resource configuration
 */
protected void setupGuiceBridge(ResourceConfig resourceConfig) {
    LogManager.getLogger().info("Initialize hk2 - guice bridge...");
    resourceConfig.register(new AbstractContainerLifecycleListener() {

        @Override
        public void onStartup(Container container) {
            ServiceLocator serviceLocator = container.getApplicationHandler().getServiceLocator();
            Injector injector = MCRInjectorConfig.injector();
            GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
            GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
            guiceBridge.bridgeGuiceInjector(injector);
        }
    });
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) Container(org.glassfish.jersey.server.spi.Container) GuiceIntoHK2Bridge(org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge) Injector(com.google.inject.Injector) AbstractContainerLifecycleListener(org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener)

Aggregations

AbstractContainerLifecycleListener (org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener)2 Container (org.glassfish.jersey.server.spi.Container)2 Injector (com.google.inject.Injector)1 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1 GuiceIntoHK2Bridge (org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge)1