@Override public void onStartup(Container container) { logger.trace("Setting up Guice bridge {}", container); ServiceLocator locator = container.getApplicationHandler() .getServiceLocator(); GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator); GuiceIntoHK2Bridge guiceBridge = locator .getService(GuiceIntoHK2Bridge.class); guiceBridge.bridgeGuiceInjector(injector); logger.trace("Finished setting up Guice bridge {}", container); logger.trace("Starting up catalogue synchroniser"); backgroundSync = injector.getInstance(BackgroundSync.class); backgroundSync.start(); logger.trace("Started up catalogue synchroniser"); }
/** * 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); } }); }
@Override public void onShutdown(final Container container) { final ApplicationHandler handler = container.getApplicationHandler(); final InjectionManager injectionManager = handler.getInjectionManager(); // Call @PreDestroy method on Application. injectionManager.preDestroy(getWrappedApplication(handler.getConfiguration())); // Shutdown ServiceLocator. injectionManager.shutdown(); }
@Override public void onStartup(Container container) { LOGGER.info("Standalone conversion server is starting: starting up local converter"); LocalConverter.Builder builder = LocalConverter.builder() .baseFolder(baseFolder) .processTimeout(processTimeout, TimeUnit.MILLISECONDS) .workerPool(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MILLISECONDS); for (Map.Entry<Class<? extends IExternalConverter>, Boolean> entry : converterConfiguration.entrySet()) { LOGGER.info("{} converter: %s", entry.getValue() ? "ENABLED" : "DISABLED", entry.getKey()); builder = entry.getValue() ? builder.enable(entry.getKey()) : builder.disable(entry.getKey()); } this.converter = builder.build(); LOGGER.info("Standalone conversion server is starting: local converter is started"); }
@Override public void onStartup(Container container) { this.container = container; logger.debug("onStartup; got container: {}", container); }
@Override public void onReload(Container container) { logger.debug("onReload; old container: {}, new container: {}", this.container, container); //this.container = container; }
@Override public void onShutdown(Container container) { logger.debug("onShutdown; got container: {}", container); }
public NettyRestServerListener(Container container) { this.container = container; }
public ContainerDelegate(Container container) { this.container = container; this.config = container.getConfiguration(); this.handler = container.getApplicationHandler(); }
@Override public void onReload(Container container) { }
@Override public void onShutdown(Container container) { LOGGER.info("Standalone conversion server is shutting down: shutting local converter down"); converter.shutDown(); LOGGER.info("Standalone conversion server is shutting down: local converter was shut down"); }
@Override public void onReload(Container container) { onShutdown(container); onStartup(container); }
@Override public void onStartup(Container container) { this.container = container; }
@Override public void onShutdown(Container container) { }
/** * use for reload Container. * <p> * the tryScope must run success then shutdown ServiceLocator * <p> * otherwise not shut down ServiceLocator * * @param container {@link Container} * @param tryScope try scope */ public abstract void onReloadShutdown(final Container container, Runnable tryScope);