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.
- Since:
- 1.0.0
-
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 TypeMethodDescriptioncreateContextCloserListener
(org.springframework.context.ConfigurableApplicationContext child) Subclasses may override to create their own subclass of ContextCloserListener.int
getOrder()
void
void
setApplicationContext
(org.springframework.context.ApplicationContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
ParentContextCloserApplicationListener
public ParentContextCloserApplicationListener()
-
-
Method Details
-
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
-