本文整理汇总了Java中org.springframework.context.ConfigurableApplicationContext.registerShutdownHook方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableApplicationContext.registerShutdownHook方法的具体用法?Java ConfigurableApplicationContext.registerShutdownHook怎么用?Java ConfigurableApplicationContext.registerShutdownHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.context.ConfigurableApplicationContext
的用法示例。
在下文中一共展示了ConfigurableApplicationContext.registerShutdownHook方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContext
import org.springframework.context.ConfigurableApplicationContext; //导入方法依赖的package包/类
/**
* Obtain an ApplicationContext for the given key, potentially cached.
* @param key 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(Object key) throws Exception {
if (isContextKeyEmpty(key)) {
return null;
}
String keyString = contextKeyString(key);
ConfigurableApplicationContext ctx = contextKeyToContextMap.get(keyString);
if (ctx == null) {
ctx = loadContext(key);
ctx.registerShutdownHook();
contextKeyToContextMap.put(keyString, ctx);
}
return ctx;
}