Package org.springframework.boot.builder
Class ParentContextCloserApplicationListener
java.lang.Object
org.springframework.boot.builder.ParentContextCloserApplicationListener
- All Implemented Interfaces:
EventListener
,Aware
,ApplicationContextAware
,ApplicationListener<ParentContextApplicationContextInitializer.ParentContextAvailableEvent>
,Ordered
public class ParentContextCloserApplicationListener
extends Object
implements ApplicationListener<ParentContextApplicationContextInitializer.ParentContextAvailableEvent>, ApplicationContextAware, Ordered
Listener that closes the application context if its parent is closed. It listens for
refresh events and grabs the current context from there, and then listens for closed
events and propagates it down the hierarchy.
- Since:
- 1.0.0
- Author:
- Dave Syer, Eric Bottard
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
ApplicationListener
to close the context. -
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionSubclasses may override to create their own subclass of ContextCloserListener.int
getOrder()
void
void
setApplicationContext
(ApplicationContext context)
-
Constructor Details
-
ParentContextCloserApplicationListener
public ParentContextCloserApplicationListener()
-
-
Method Details
-
getOrder
public int getOrder() -
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
onApplicationEvent
public void onApplicationEvent(ParentContextApplicationContextInitializer.ParentContextAvailableEvent event) - Specified by:
onApplicationEvent
in interfaceApplicationListener<ParentContextApplicationContextInitializer.ParentContextAvailableEvent>
-
createContextCloserListener
protected ParentContextCloserApplicationListener.ContextCloserListener createContextCloserListener(ConfigurableApplicationContext child) Subclasses may override to create their own subclass of ContextCloserListener. This still enforces the use of a weak reference.- Parameters:
child
- the child context- Returns:
- the
ParentContextCloserApplicationListener.ContextCloserListener
to use
-