Example usage for org.springframework.context ApplicationEvent getSource

List of usage examples for org.springframework.context ApplicationEvent getSource

Introduction

In this page you can find the example usage for org.springframework.context ApplicationEvent getSource.

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:org.alfresco.util.OpenOfficeConnectionTester.java

/**
 * @see #checkConnection()/*w w w.j a  v  a  2s  .c  om*/
 */
@Override
protected void onBootstrap(ApplicationEvent event) {
    if (connection instanceof SocketOpenOfficeConnection
            && ((SocketOpenOfficeConnection) connection).isEnabled()) {
        checkConnection();
        ((ApplicationContext) event.getSource())
                .publishEvent(new OpenOfficeConnectionEvent(this.openOfficeMetadata));
    }
}

From source file:org.springframework.cloud.dataflow.yarn.streamappmaster.EmbeddedAppmasterTrackService.java

@Override
public void onApplicationEvent(ApplicationEvent event) {
    Object source = event.getSource();
    if (source instanceof AnnotationConfigEmbeddedWebApplicationContext) {
        embeddedServletContainer = ((AnnotationConfigEmbeddedWebApplicationContext) source)
                .getEmbeddedServletContainer();
    }/*w  w w. j  a  va 2 s  . c o m*/
}

From source file:org.springframework.richclient.security.SecurityAwareConfigurer.java

public void onApplicationEvent(ApplicationEvent event) {

    // All events we care about are subtypes of ClientSecurityEvent
    if (event instanceof ClientSecurityEvent) {
        Authentication authentication = (Authentication) event.getSource();

        if (logger.isDebugEnabled()) {
            logger.debug("RECEIVED ClientSecurityEvent: " + event);
            logger.debug("Authentication token: " + authentication);
        }/*  ww w.  j  a  v a 2 s  .  c  o  m*/

        // Note that we need to inspect the new authentication token and see if it is
        // NO_AUTHENTICATION. If so, then we need to use null instead. This little
        // dance is required because the source of an event can't actually be null.

        if (authentication == ClientSecurityEvent.NO_AUTHENTICATION) {
            if (logger.isDebugEnabled()) {
                logger.debug("Converted NO_AUTHENTICATION to null");
            }
            authentication = null;
        }

        // And dispatch according to the event type.

        if (event instanceof AuthenticationEvent) {
            broadcastAuthentication(authentication);
        } else if (event instanceof LoginEvent) {
            broadcastLogin(authentication);
        } else if (event instanceof LogoutEvent) {
            broadcastLogout(authentication);
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("Unsupported event not processed");
            }
        }
    }
}