Add EventListener example
This commit is contained in:
parent
f811eacebb
commit
dd457fa63a
|
@ -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++;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue