1 package eu.sydisnet.blog.samples.deltaspike.cdi12.control;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5
6 import javax.annotation.PostConstruct;
7 import javax.annotation.PreDestroy;
8 import javax.enterprise.context.Dependent;
9 import java.lang.invoke.MethodHandles;
10
11
12
13
14
15
16
17 @Dependent
18 public class MessageFormatter {
19
20
21
22
23 private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
24
25
26
27
28
29
30 @PostConstruct
31 void initBean() {
32 LOG.info(String.format("##### %s started !", MethodHandles.lookup().lookupClass().getSimpleName()));
33 }
34
35
36
37
38
39
40 @PreDestroy
41 void tearDown() {
42 LOG.info(String.format("##### %s stopped !", MethodHandles.lookup().lookupClass().getSimpleName()));
43 }
44
45
46
47
48
49
50
51
52 public String format(final String template, final String param) {
53 String result = String.format(template, param);
54
55 return result;
56 }
57 }