Add EventListener example

This commit is contained in:
Grzegorz Piwowarek 2016-08-18 07:11:23 +02:00
parent f811eacebb
commit dd457fa63a
1 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package org.baeldung.startup;
import org.apache.log4j.Logger;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@Component
public class EventListenerExampleBean {
private static final Logger LOG = Logger.getLogger(EventListenerExampleBean.class);
public static int counter;
@EventListener
public void onApplicationEvent(ContextRefreshedEvent event) {
LOG.info("Increment counter");
counter++;
}
}