org.springframework.boot.context.event.SpringApplicationEvent Java Examples

The following examples show how to use org.springframework.boot.context.event.SpringApplicationEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArkApplicationStartListener.java    From sofa-ark with Apache License 2.0 6 votes vote down vote up
@Override
public void onApplicationEvent(SpringApplicationEvent event) {
    try {
        if (isSpringBoot2()
            && APPLICATION_STARTING_EVENT.equals(event.getClass().getCanonicalName())) {
            startUpArk(event);
        }

        if (isSpringBoot1()
            && APPLICATION_STARTED_EVENT.equals(event.getClass().getCanonicalName())) {
            startUpArk(event);
        }
    } catch (Throwable e) {
        throw new RuntimeException("Meet exception when determine whether to start SOFAArk!", e);
    }
}
 
Example #2
Source File: SpringBuiltInEventsListener.java    From code-examples with MIT License 5 votes vote down vote up
@Override
public void onApplicationEvent(SpringApplicationEvent event) {
	System.out.println("SpringApplicationEvent Received - " + event);

	// Initializing publisher for custom event
	this.initPublisher(event);
}
 
Example #3
Source File: MultipleSpringBootEventsListener.java    From thinking-in-spring-boot-samples with Apache License 2.0 4 votes vote down vote up
@EventListener({ApplicationReadyEvent.class, ApplicationFailedEvent.class})
public void onSpringBootEvent(SpringApplicationEvent event) {
    System.out.println("@EventListener 监听到事件 : " + event.getClass().getSimpleName());
}
 
Example #4
Source File: ArkApplicationStartListener.java    From sofa-ark with Apache License 2.0 4 votes vote down vote up
public void startUpArk(SpringApplicationEvent event) {
    if (LAUNCH_CLASSLOADER_NAME.equals(this.getClass().getClassLoader().getClass().getName())) {
        SofaArkBootstrap.launch(event.getArgs());
    }
}
 
Example #5
Source File: SpringBuiltInEventsListener.java    From code-examples with MIT License 4 votes vote down vote up
private void initPublisher(SpringApplicationEvent event) {
	if (event instanceof ApplicationReadyEvent) {
		this.applicationContext.getBean(Publisher.class).publishEvent();
	}
}