All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cedarsoft.spring.rcp.events.EventLogger Maven / Gradle / Ivy

package com.cedarsoft.spring.rcp.events;

import com.cedarsoft.lookup.Lookup;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.richclient.application.event.LifecycleApplicationEvent;
import org.springframework.security.event.authorization.AuthorizedEvent;
import org.springframework.security.event.authorization.PublicInvocationEvent;

/**
 *
 */
public class EventLogger implements ApplicationListener {
  private static final Log log = LogFactory.getLog( EventLogger.class );

  @Override
  public void onApplicationEvent( ApplicationEvent event ) {
    if ( event instanceof PublicInvocationEvent ) {
      return;
    }
    if ( event instanceof AuthorizedEvent ) {
      return;
    }

    //    log.debug( "--> new application event occured from " + event.getSource() + " of type: " + event.getClass().getName() );
    //    log.debug( "\t " + event.toString() );

    if ( event instanceof LifecycleApplicationEvent ) {
      if ( event instanceof SelectionEvent ) {
        Lookup lookup = ( ( SelectionEvent ) event ).getObjects();
        //        log.debug( "\t --- SelectionEvent --- with elements.size: " + lookup.lookups().size() );
        //
        //        for ( Map.Entry, Object> entry : lookup.lookups().entrySet() ) {
        //          log.debug( "\t\t" + entry.getKey().getName() + ": " + entry.getValue() );
        //        }
        //
      } else {
        String type = ( ( LifecycleApplicationEvent ) event ).getEventType();
        Object object = ( ( LifecycleApplicationEvent ) event ).getObject();
        log.debug( "\t --- LifecycleApplicationEvent --- " + type + ": " + object.getClass().getName() + " (" + object + ")" );
      }
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy