Package com.cedarsoft.spring.rcp.events

Source Code of com.cedarsoft.spring.rcp.events.EventLogger

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<Class<?>, 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 + ")" );
      }
    }
  }
}
TOP

Related Classes of com.cedarsoft.spring.rcp.events.EventLogger

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.