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
Nested ClassesModifier and TypeClassDescriptionprotected static classApplicationListenerto close the context. -
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateContextCloserListener(org.springframework.context.ConfigurableApplicationContext child) Subclasses may override to create their own subclass of ContextCloserListener.intgetOrder()voidvoidsetApplicationContext(org.springframework.context.ApplicationContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
ParentContextCloserApplicationListener
public ParentContextCloserApplicationListener()
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext context) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
onApplicationEvent
public void onApplicationEvent(ParentContextApplicationContextInitializer.ParentContextAvailableEvent event) - Specified by:
onApplicationEventin 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.ContextCloserListenerto use
-