Skip to content

Commit 991335d

Browse files
the-java-guypivovarit
authored andcommitted
BAEL-1782 (eugenp#5067)
* Bean Object, server side and client side example for event streaming example * BAEL-1628 Access a File from the Classpath in a Spring Application * inputstream retrieval added * Removed files related to evaluation article * + Aligning code to the article. Removed Utility methods and classes * Precommit fix * PMD fixes * Code Review changes Refactored : whenResourceUtils_thenReadSuccessful * BAEL-1934 * +indentation correction in pom.xml * synced with master * Precommit : rebase * BAEL-1782
1 parent 1256735 commit 991335d

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.baeldung.event.listener;
2+
3+
import org.springframework.context.event.ContextStartedEvent;
4+
import org.springframework.context.event.ContextStoppedEvent;
5+
import org.springframework.context.event.EventListener;
6+
import org.springframework.core.annotation.Order;
7+
import org.springframework.stereotype.Component;
8+
9+
@Component
10+
public class ContextEventListener {
11+
12+
@Order(2)
13+
@EventListener
14+
public void handleContextRefreshEvent(ContextStartedEvent ctxStartEvt) {
15+
System.out.println("Context Start Event received.");
16+
}
17+
18+
@Order(1)
19+
@EventListener(classes = { ContextStartedEvent.class, ContextStoppedEvent.class })
20+
public void handleMultipleEvents() {
21+
System.out.println("Multi-event listener invoked");
22+
}
23+
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.baeldung.event.listener;
2+
3+
import org.springframework.context.annotation.ComponentScan;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
@Configuration
7+
@ComponentScan(basePackages = "com.baeldung.event.listener")
8+
public class EventConfig {
9+
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.baeldung.event.listener;
2+
3+
import org.springframework.context.ConfigurableApplicationContext;
4+
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
5+
6+
public class SpringRunner {
7+
8+
public static void main(String[] args) {
9+
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(EventConfig.class);
10+
ctx.start();
11+
}
12+
}

0 commit comments

Comments
 (0)