Package org.springframework.boot.builder
Class ParentContextCloserApplicationListener
- java.lang.Object
- org.springframework.boot.builder.ParentContextCloserApplicationListener
- All Implemented Interfaces:
EventListener
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.context.ApplicationListener<ParentContextApplicationContextInitializer.ParentContextAvailableEvent>
,org.springframework.core.Ordered
public class ParentContextCloserApplicationListener extends Object implements org.springframework.context.ApplicationListener<ParentContextApplicationContextInitializer.ParentContextAvailableEvent>, org.springframework.context.ApplicationContextAware, org.springframework.core.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.
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ParentContextCloserApplicationListener.ContextCloserListener
ApplicationListener
to close the context.
Constructor Summary
Constructors Constructor Description ParentContextCloserApplicationListener()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ParentContextCloserApplicationListener.ContextCloserListener
createContextCloserListener(org.springframework.context.ConfigurableApplicationContext child)
Subclasses may override to create their own subclass of ContextCloserListener.int
getOrder()
void
onApplicationEvent(ParentContextApplicationContextInitializer.ParentContextAvailableEvent event)
void
setApplicationContext(org.springframework.context.ApplicationContext context)
Constructor Detail
ParentContextCloserApplicationListener
public ParentContextCloserApplicationListener()
Method Detail
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext context) throws org.springframework.beans.BeansException
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
onApplicationEvent
public void onApplicationEvent(ParentContextApplicationContextInitializer.ParentContextAvailableEvent event)
- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<ParentContextApplicationContextInitializer.ParentContextAvailableEvent>
createContextCloserListener
protected ParentContextCloserApplicationListener.ContextCloserListener createContextCloserListener(org.springframework.context.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