Java Code Examples for org.springframework.context.ConfigurableApplicationContext#registerShutdownHook()
The following examples show how to use
org.springframework.context.ConfigurableApplicationContext#registerShutdownHook() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-javaformat File: SpringApplication.java License: Apache License 2.0 | 5 votes |
private void refreshContext(ConfigurableApplicationContext context) { refresh(context); if (this.registerShutdownHook) { try { context.registerShutdownHook(); } catch (AccessControlException ex) { // Not allowed in some environments. } } }
Example 2
Source Project: spring-boot-data-geode File: TestRefreshableApplicationContextLoader.java License: Apache License 2.0 | 5 votes |
/** * @inheritDoc */ @Override public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) { ConfigurableApplicationContext applicationContext = configure(newApplicationContext(mergedConfig), mergedConfig); applicationContext.registerShutdownHook(); applicationContext.refresh(); return applicationContext; }
Example 3
Source Project: spring4-understanding File: AbstractSpringContextTests.java License: Apache License 2.0 | 5 votes |
/** * Obtain an ApplicationContext for the given key, potentially cached. * @param locations the context key; may be {@code null}. * @return the corresponding ApplicationContext instance (potentially cached), * or {@code null} if the provided {@code key} is <em>empty</em> */ protected final ConfigurableApplicationContext getContext(String... locations) throws Exception { if (ObjectUtils.isEmpty(locations)) { return null; } String key = contextKey(locations); ConfigurableApplicationContext ctx = contextKeyToContextMap.get(key); if (ctx == null) { ctx = loadContext(locations); ctx.registerShutdownHook(); contextKeyToContextMap.put(key, ctx); } return ctx; }
Example 4
Source Project: devicehive-java-server File: DeviceHiveAuthApplication.java License: Apache License 2.0 | 5 votes |
public static void main(String... args) { ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(DeviceHiveAuthApplication.class) .web(true) .run(args); context.registerShutdownHook(); }
Example 5
Source Project: devicehive-java-server File: DeviceHiveFrontendApplication.java License: Apache License 2.0 | 5 votes |
public static void main(String... args) { ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(DeviceHiveFrontendApplication.class) .web(true) .run(args); context.registerShutdownHook(); }
Example 6
Source Project: devicehive-java-server File: DeviceHiveBackendApplication.java License: Apache License 2.0 | 5 votes |
public static void main(String... args) { ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(DeviceHiveBackendApplication.class) .web(false) .run(args); context.registerShutdownHook(); }
Example 7
Source Project: devicehive-java-server File: DeviceHivePluginApplication.java License: Apache License 2.0 | 5 votes |
public static void main(String... args) { ConfigurableApplicationContext context = new SpringApplicationBuilder() .sources(DeviceHivePluginApplication.class) .web(true) .run(args); context.registerShutdownHook(); }
Example 8
Source Project: java-11-examples File: Main.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { ConfigurableApplicationContext run = SpringApplication.run(Main.class, args); run.registerShutdownHook(); }
Example 9
Source Project: NFVO File: Application.java License: Apache License 2.0 | 4 votes |
public static void main(String[] args) { ConfigurableApplicationContext context = SpringApplication.run(Application.class, args); context.registerShutdownHook(); }
Example 10
Source Project: tutorials File: ClasspathXmlApplicationContextIntegrationTest.java License: MIT License | 4 votes |
@Test public void testRegisterShutdownHook() { ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("classpathxmlapplicationcontext-example.xml"); context.registerShutdownHook(); }