public static void addApplicationContext(ApplicationContext context) { contexts.add(context); if (context instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) context).registerShutdownHook(); DubboShutdownHook.getDubboShutdownHook().unregister(); } BeanFactoryUtils.addApplicationListener(context, shutdownHookListener); }
public static void addApplicationContext(ApplicationContext context) { contexts.add(context); if (context instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) context).registerShutdownHook(); DubboShutdownHook.getDubboShutdownHook().unregister(); } BeanFactoryUtils.addApplicationListener(context, shutdownHookListener); }
private void refreshContext(ConfigurableApplicationContext context) { refresh(context); if (this.registerShutdownHook) { try { context.registerShutdownHook(); } catch (AccessControlException ex) { // Not allowed in some environments. } } }
@SuppressWarnings("resource") private ConfigurableListableBeanFactory createFallbackContext() { ConfigurableApplicationContext applicationContext; if (getClass().getClassLoader().getResource("cucumber.xml") != null) { applicationContext = new ClassPathXmlApplicationContext("cucumber.xml"); } else { applicationContext = new GenericApplicationContext(); } applicationContext.registerShutdownHook(); ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); beanFactory.registerScope(GlueCodeScope.NAME, new GlueCodeScope()); for (Class<?> stepClass : stepClasses) { registerStepClassBeanDefinition(beanFactory, stepClass); } return beanFactory; }
applicationContext = new ClassPathXmlApplicationContext( configLocations); applicationContext.registerShutdownHook();
public void registerShutdownHook() { Map<String, ApplicationContext> contextMap= moduleDefinitionSet.getContextMap(); for (String appName : contextMap.keySet()) { ApplicationContext contex = contextMap.get(appName); if (contex instanceof ConfigurableApplicationContext) { log.trace("registering shutdown hook for bean "+ appName); ((ConfigurableApplicationContext)contex).registerShutdownHook(); } } }
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { if (_applicationContext == null) { _applicationContext = (ConfigurableApplicationContext) applicationContext; _applicationContext.registerShutdownHook(); } else throw new Error("Shouldn't reach here."); }
public static void main(String[] args) { ConfigurableApplicationContext context = SpringApplication.run(Application.class, args); context.registerShutdownHook(); }
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("Beans.xml"); ctx.registerShutdownHook(); // this should be it, destroys are called before your app exits
@Override public void registerShutdownHook() { lock.writeLock().lock(); try { configurableApplicationContext.registerShutdownHook(); } finally { lock.writeLock().unlock(); } }
public static void main(String... args) { ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(DeviceHiveFrontendApplication.class) .web(true) .run(args); context.registerShutdownHook(); }
public static void main(String... args) { ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(DeviceHiveAuthApplication.class) .web(true) .run(args); context.registerShutdownHook(); }
public static void main(String... args) { ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(DeviceHivePluginApplication.class) .web(true) .run(args); context.registerShutdownHook(); }
public static void main(String... args) { ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(DeviceHiveBackendApplication.class) .web(false) .run(args); context.registerShutdownHook(); }
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { Application obj = new Application(); @SuppressWarnings("resource") ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/applicationContext.xml"); applicationContext.registerShutdownHook(); applicationContext.getBeanFactory().autowireBeanProperties( obj, AutowireCapableBeanFactory.AUTOWIRE_NO, false); return application.sources(Application.class); }
private void startContext() { context = new SpringApplication(webServerClass).run("--server.port=" + getAppHttpsPort()); context.registerShutdownHook(); }
private void startContext() { context = new SpringApplication(webServerClass).run("--server.port=" + getAppHttpsPort()); context.registerShutdownHook(); }
public static void addApplicationContext(ApplicationContext context) { contexts.add(context); if (context instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) context).registerShutdownHook(); DubboShutdownHook.getDubboShutdownHook().unregister(); } BeanFactoryUtils.addApplicationListener(context, shutdownHookListener); }
public static void addApplicationContext(ApplicationContext context) { contexts.add(context); if (context instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) context).registerShutdownHook(); DubboShutdownHook.getDubboShutdownHook().unregister(); } BeanFactoryUtils.addApplicationListener(context, shutdownHookListener); }
private BeanFactory getBeanFactory(ServletContextEvent event) { String beanFactorySelector = getBeanFactorySelector(event); String applicationContextKey = getApplicationContextKey(event); BeanFactoryLocator bfl = SingletonBeanFactoryLocator .getInstance(beanFactorySelector); BeanFactoryReference bf = bfl.useBeanFactory(applicationContextKey); BeanFactory beanFactory = bf.getFactory(); if (beanFactory instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) beanFactory).registerShutdownHook(); } return beanFactory; }