Example usage for org.springframework.context.event ApplicationContextEvent getClass

List of usage examples for org.springframework.context.event ApplicationContextEvent getClass

Introduction

In this page you can find the example usage for org.springframework.context.event ApplicationContextEvent getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.alfresco.bm.test.LifecycleController.java

@Override
public void onApplicationEvent(ApplicationContextEvent event) {
    // Ignore events from different application contexts
    if (event.getApplicationContext() != ctx) {
        // Ignore
        return;/* ww w.j  a  v  a 2s  .c  om*/
    }

    String eventName = event.getClass().getSimpleName();
    if (eventName.equals("ContextRefreshedEvent")) {
        // Only start once
        if (!started) {
            start();
            started = true;
        }
    } else if (eventName.equals("ContextClosedEvent")) {
        // Only stop once
        if (started) {
            stop();
            started = false;
        }
    }
}