forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCdiSimple.java
More file actions
27 lines (19 loc) · 850 Bytes
/
CdiSimple.java
File metadata and controls
27 lines (19 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.zetcode;
import com.zetcode.provider.HelloMessageProvider;
import com.zetcode.renderer.ConsoleMessageRenderer;
import com.zetcode.renderer.MessageRenderer;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
public class CdiSimple {
static {
System.setProperty("org.jboss.logging.provider", "slf4j");
}
public static void main(String[] args) {
SeContainerInitializer initializer = SeContainerInitializer.newInstance();
try (SeContainer container = initializer.disableDiscovery()
.addBeanClasses(HelloMessageProvider.class, ConsoleMessageRenderer.class).initialize()) {
MessageRenderer messageRenderer = container.select(ConsoleMessageRenderer.class).get();
messageRenderer.render();
}
}
}